X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/084e6c29c1a6e998829db6d0bd825573d4072784..183e9cd31b1ac2f14b86c5de6ac2643b8a4364a2:/pubkey.c diff --git a/pubkey.c b/pubkey.c index e0e8dc9..56b7d9c 100644 --- a/pubkey.c +++ b/pubkey.c @@ -65,8 +65,12 @@ static PyObject *dsa_setup(PyTypeObject *ty, PyObject *G, PyObject *u, if (!u) { g->d.u = 0; u = Py_None; - } else if ((g->d.u = getmp(u)) == 0) - goto end; + } else { + if ((g->d.u = getmp(u)) == 0) + goto end; + if (MP_PYCHECK(u)) Py_INCREF(u); + else u = mp_pywrap(g->d.u); + } if (!p) { assert(g->d.u); assert(calcpub); pp = G_CREATE(GROUP_G(G)); @@ -78,7 +82,7 @@ static PyObject *dsa_setup(PyTypeObject *ty, PyObject *G, PyObject *u, g->d.p = GE_X(p); g->d.r = GRAND_R(rng); g->d.h = GCHASH_CH(hash); - g->G = G; Py_INCREF(G); g->u = u; Py_INCREF(u); g->p = p; + g->G = G; Py_INCREF(G); g->u = u; g->p = p; g->rng = rng; Py_INCREF(rng); g->hash = hash; Py_INCREF(hash); return ((PyObject *)g); end: @@ -243,7 +247,7 @@ static PyTypeObject dsapub_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"DSA public key information.", +"DSAPub(GROUP, P, [hash = sha], [rng = rand]): DSA public key.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -291,7 +295,7 @@ static PyTypeObject dsapriv_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"DSA private key information.", +"DSAPriv(GROUP, U, [p = u G], [hash = sha], [rng = rand]): DSA private key.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -344,7 +348,7 @@ static PyObject *kcdsapriv_pynew(PyTypeObject *ty, { PyObject *G, *u, *p = 0, *rng = rand_pyobj, *hash = has160_pyobj; PyObject *rc = 0; - char *kwlist[] = { "G", "p", "u", "hash", "rng", 0 }; + char *kwlist[] = { "G", "u", "p", "hash", "rng", 0 }; if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", kwlist, group_pytype, &G, @@ -463,7 +467,7 @@ static PyTypeObject kcdsapub_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"KCDSA public key information.", +"KCDSAPub(GROUP, P, [hash = sha], [rng = rand]): KCDSA public key.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -511,7 +515,7 @@ static PyTypeObject kcdsapriv_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"KCDSA private key information.", +"KCDSAPriv(GROUP, U, [p = u G], [hash = sha], [rng = rand]): KCDSA private key.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -809,7 +813,7 @@ static PyTypeObject rsapub_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"RSA public key information.", +"RSAPub(N, E): RSA public key.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ @@ -857,7 +861,8 @@ static PyTypeObject rsapriv_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"RSA private key information.", +"RSAPriv(..., [rng = rand]): RSA private key.\n\ + Keywords: n, e, d, p, q, dp, dq, q_inv; must provide enough", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */