X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=rsa.c;h=f7dd69db6f69115e03c94779a2529468b642619f;hp=2db03c9bbdf45453cc37e2e7b3cb910c1cde4448;hb=b85840f2aed63305094eca734f157a0f73d91273;hpb=9941ae2e1f8bd7cb5771527b41d6a2032cd6580f diff --git a/rsa.c b/rsa.c index 2db03c9..f7dd69d 100644 --- a/rsa.c +++ b/rsa.c @@ -199,6 +199,9 @@ static list_t *rsapub_apply(closure_t *self, struct cloc loc, dict_t *context, } else { cfgfatal(loc,"rsa-public","you must provide an encryption key\n"); } + if (mpz_sizeinbase(&st->e, 256) > RSA_MAX_MODBYTES) { + cfgfatal(loc, "rsa-public", "implausibly large public exponent\n"); + } i=list_elem(args,1); if (i) { @@ -213,6 +216,9 @@ static list_t *rsapub_apply(closure_t *self, struct cloc loc, dict_t *context, } else { cfgfatal(loc,"rsa-public","you must provide a modulus\n"); } + if (mpz_sizeinbase(&st->n, 256) > RSA_MAX_MODBYTES) { + cfgfatal(loc, "rsa-public", "implausibly large modulus\n"); + } return new_closure(&st->cl); }