X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/285bf989997b8dc94a0783e260fe73787c7ae767..6ecc0b8facfd2f1f13abc03b0f2013112af3430b:/pub/rsa-gen.c?ds=sidebyside diff --git a/pub/rsa-gen.c b/pub/rsa-gen.c index c12be18a..de97644c 100644 --- a/pub/rsa-gen.c +++ b/pub/rsa-gen.c @@ -158,6 +158,8 @@ int rsa_gen(rsa_priv *rp, unsigned nbits, grand *r, unsigned n, mp_gcd(&g.g, 0, &rp->d, phi, rp->e); if (!MP_EQ(g.g, MP_ONE) && MP_LEN(rp->d) * 4 > MP_LEN(rp->n) * 3) goto fail_e; + if (mp_bits(rp->n) != nbits) + goto fail_e; /* --- Work out exponent residues --- */