X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb-python/blobdiff_plain/b2687a0a4b3c5e45cad7c5815a6d3805bfc8d4f1..05a8254234de3a315ed1ec33c26b56826678834d:/pubkey.c diff --git a/pubkey.c b/pubkey.c index 1e7e366..8790e40 100644 --- a/pubkey.c +++ b/pubkey.c @@ -1,7 +1,5 @@ /* -*-c-*- * - * $Id$ - * * Public-key cryptography * * (c) 2004 Straylight/Edgeware @@ -555,6 +553,7 @@ static PyObject *rsapub_pynew(PyTypeObject *ty, if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist, convmp, &rp.n, convmp, &rp.e)) goto end; + if (!MP_ODDP(rp.n)) VALERR("RSA modulus must be even"); o = (rsapub_pyobj *)ty->tp_alloc(ty, 0); o->pub = rp; rsa_pubcreate(&o->pubctx, &o->pub); @@ -627,6 +626,10 @@ static PyObject *rsapriv_pynew(PyTypeObject *ty, convmp, &rp.q_inv, &rng)) goto end; + if ((rp.n && !MP_ODDP(rp.n)) || + (rp.p && !MP_ODDP(rp.p)) || + (rp.p && !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)) TYERR("not a random number source");