diff --git a/lib/des/rsa-imath.c b/lib/des/rsa-imath.c index 24243bfb2..6545c849f 100644 --- a/lib/des/rsa-imath.c +++ b/lib/des/rsa-imath.c @@ -188,6 +188,14 @@ imath_rsa_public_decrypt(int flen, const unsigned char* from, return -1; size--; p++; + /* + * Check for Daniel Bleichenbacher an attack on PKCS #1 v1.5 + * signatures. Doesn't work on standard signatures and small key, + * so limit when we check for it. + */ + if (size > 42 && (3 * 8 * size) >= BN_num_bits(rsa->n)) + return -1; + memmove(to, p, size); return size;