X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/204416123385794c92b7767e7702c0d4fd387468..740847afe208bb8f33e7d6cf642acaf4aa739f6a:/pubkey.c diff --git a/pubkey.c b/pubkey.c index 9c43ca7..5680429 100644 --- a/pubkey.c +++ b/pubkey.c @@ -200,7 +200,7 @@ static PyMethodDef dsapub_pymethods[] = { static PyMethodDef dsapriv_pymethods[] = { #define METHNAME(name) dsameth_##name - KWMETH(sign, "D.sign(MSG, k = K) -> R, S") + KWMETH(sign, "D.sign(MSG, [k = K]) -> R, S") #undef METHNAME { 0 } }; @@ -437,7 +437,7 @@ static PyMethodDef kcdsapub_pymethods[] = { static PyMethodDef kcdsapriv_pymethods[] = { #define METHNAME(name) kcdsameth_##name - KWMETH(sign, "D.sign(MSG, k = K) -> R, S") + KWMETH(sign, "D.sign(MSG, [k = K]) -> R, S") #undef METHNAME { 0 } }; @@ -649,7 +649,7 @@ static PyObject *rsapriv_pynew(PyTypeObject *ty, goto end; if ((rp.n && !MP_ODDP(rp.n)) || (rp.p && !MP_ODDP(rp.p)) || - (rp.p && !MP_ODDP(rp.q))) + (rp.q && !MP_ODDP(rp.q))) VALERR("RSA modulus and factors must be odd"); if (rsa_recover(&rp)) VALERR("couldn't construct private key"); if (rng != Py_None && !GRAND_PYCHECK(rng)) @@ -733,11 +733,13 @@ static PyObject *meth__RSAPriv_generate(PyObject *me, unsigned n = 0; rsa_priv rp; mp *e = 0; - pgev evt = { 0 }; + struct excinfo exc = EXCINFO_INIT; + pypgev evt = { { 0 } }; static const char *const kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "e", 0 }; PyObject *rc = 0; + evt.exc = &exc; if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", KWLIST, &me, convuint, &nbits, convpgev, &evt, convgrand, &r, convuint, &n, @@ -745,8 +747,8 @@ static PyObject *meth__RSAPriv_generate(PyObject *me, goto end; if (e) MP_COPY(e); else e = mp_fromulong(MP_NEW, 65537); - if (rsa_gen_e(&rp, nbits, e, r, n, evt.proc, evt.ctx)) - PGENERR; + if (rsa_gen_e(&rp, nbits, e, r, n, evt.ev.proc, evt.ev.ctx)) + PGENERR(&exc); rc = rsapriv_pywrap(&rp); end: droppgev(&evt); @@ -784,7 +786,7 @@ static PyGetSetDef rsapriv_pygetset[] = { static PyMethodDef rsapriv_pymethods[] = { #define METHNAME(name) rsameth_##name - KWMETH(privop, "R.privop(X, rng = None) -> X^D (mod N)") + KWMETH(privop, "R.privop(X, [rng = None]) -> X^D (mod N)") #undef METHNAME { 0 } }; @@ -1269,7 +1271,7 @@ static PyMethodDef methods[] = { KWMETH(_pss_encode, 0) KWMETH(_pss_decode, 0) KWMETH(_RSAPriv_generate, "\ -generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0]) -> R") +generate(NBITS, [event = pgen_nullev], [rng = rand], [nsteps = 0]) -> R") #define DEFMETH(X, x) \ METH (x, "\ " #x "(KEY, PUBLIC) -> SHARED") @@ -1279,11 +1281,11 @@ generate(NBITS, [event = pgen_nullev, rng = rand, nsteps = 0]) -> R") METH (ed##_pubkey, "\ " #ed "_pubkey(KEY) -> PUBLIC") \ KWMETH(ed##_sign, "\ -" #ed "_sign(KEY, MSG, [pub = PUBLIC, " \ - "perso = STRING, phflag = BOOL]) -> SIG") \ +" #ed "_sign(KEY, MSG, [pub = PUBLIC], " \ + "[perso = STRING], [phflag = BOOL]) -> SIG") \ KWMETH(ed##_verify, "\ " #ed "_verify(PUBLIC, MSG, SIG, " \ - "[perso = STRING, phflag = BOOL]) -> BOOL") + "[perso = STRING], [phflag = BOOL]) -> BOOL") EDDSAS(DEFMETH) #undef DEFMETH #undef METHNAME