Minor cleanup of the rsa mp limits code
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Mon, 11 Dec 2017 15:10:36 +0000 (16:10 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Wed, 13 Dec 2017 16:29:01 +0000 (17:29 +0100)
Reduce RSA_MAX_PRIME_NUM to 5.
Remove no longer used RSA_MIN_PRIME_SIZE.
Make rsa_multip_cap honor RSA_MAX_PRIME_NUM.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4905)

crypto/rsa/rsa_locl.h
crypto/rsa/rsa_mp.c

index 9bd53bec5a579f7bf8f592d22f2b391e44258834..2b94462a94c6f542ee80f0fc26dd154b38387683 100644 (file)
@@ -10,9 +10,8 @@
 #include <openssl/rsa.h>
 #include "internal/refcount.h"
 
-#define RSA_MAX_PRIME_NUM 16
-#define RSA_MIN_PRIME_SIZE 64
-#define RSA_MIN_MODULUS_BITS   512
+#define RSA_MAX_PRIME_NUM       5
+#define RSA_MIN_MODULUS_BITS    512
 
 typedef struct rsa_prime_info_st {
     BIGNUM *r;
index 8ff4b636256d9e01f4ce7d56b5a78c6c09fe2446..97a09f1387774927d803c0526b116574a5a5078a 100644 (file)
@@ -105,5 +105,8 @@ int rsa_multip_cap(int bits)
     else if (bits < 8192)
         cap = 4;
 
+    if (cap > RSA_MAX_PRIME_NUM)
+        cap = RSA_MAX_PRIME_NUM;
+
     return cap;
 }