The private key is checked quite carefully -- even to a fault -- for
being sensibly sized, but the corresponding function for public keys
appears to have no checking at all. This is a shame since message-
representative construction assumes that the message representative will
fit in a fixed-size buffer.
Fix this situation by checking public key sizes in `rsapub_apply'.
Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
} 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) {
} 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);
}