X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=keyconvert%2Fkeyconvertext.c;fp=keyconvert%2Fkeyconvertext.c;h=d2c9e13a0f2d144e8ed5b03148d233e45dfbe812;hb=c7598e8c83de574816c8198b9f99d6435bd62359;hp=0000000000000000000000000000000000000000;hpb=de2b0cc5fd0f634c3ebee0d8ec1d6d1c00887a9f;p=sfa.git diff --git a/keyconvert/keyconvertext.c b/keyconvert/keyconvertext.c new file mode 100644 index 00000000..d2c9e13a --- /dev/null +++ b/keyconvert/keyconvertext.c @@ -0,0 +1,34 @@ +#include + +#include "keyconvert.h" + +static PyObject *keyconvert_opensshtoopenssl(PyObject *self, PyObject *args) +{ + const char *fn; + const char *s; + int len; + FILE *fout; + + PyArg_ParseTuple(args, "ss#", &fn, &s, &len); + + fout = fopen(fn, "wt"); + if (fout == NULL) { + return Py_BuildValue("i", 0); + } else { + fprintf(stdout, "len = %d\n", len); + openssh_binary_to_openssl(s, len, fout); + fclose(fout); + } + + return Py_BuildValue("i", 1); +} + +static PyMethodDef KeyConvertMethods[] = { + {"opensshtoopenssl", keyconvert_opensshtoopenssl, METH_VARARGS, "convert an openssh key to an openssl key"}, + {NULL, NULL, 0, NULL}}; + +PyMODINIT_FUNC initkeyconvert(void) +{ + (void) Py_InitModule("keyconvert", KeyConvertMethods); +} +