From 084e6c29c1a6e998829db6d0bd825573d4072784 Mon Sep 17 00:00:00 2001 Message-Id: <084e6c29c1a6e998829db6d0bd825573d4072784.1716779945.git.mdw@distorted.org.uk> From: Mark Wooding Date: Thu, 11 May 2017 10:42:15 +0100 Subject: [PATCH] pubkey.c: Allow RSA key generation with user-chosen public exponent. Organization: Straylight/Edgeware From: Mark Wooding New feature in the underlying library. --- pubkey.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pubkey.c b/pubkey.c index f94108f..e0e8dc9 100644 --- a/pubkey.c +++ b/pubkey.c @@ -728,19 +728,24 @@ static PyObject *meth__RSAPriv_generate(PyObject *me, unsigned nbits; unsigned n = 0; rsa_priv rp; + mp *e = 0; pgev evt = { 0 }; - char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", 0 }; + char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "e", 0 }; PyObject *rc = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&:generate", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist, &me, convuint, &nbits, convpgev, &evt, - convgrand, &r, convuint, &n)) + convgrand, &r, convuint, &n, + convmp, &e)) goto end; - if (rsa_gen(&rp, nbits, r, n, evt.proc, evt.ctx)) + 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; rc = rsapriv_pywrap(&rp); end: droppgev(&evt); + mp_drop(e); return (rc); } -- [mdw]