diff options
Diffstat (limited to 'src/lib/libcrypto/dh')
-rw-r--r-- | src/lib/libcrypto/dh/dh.h | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/dh/dh_err.c | 1 | ||||
-rw-r--r-- | src/lib/libcrypto/dh/dh_key.c | 6 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/libcrypto/dh/dh.h b/src/lib/libcrypto/dh/dh.h index 8562d16fb7..582b34329f 100644 --- a/src/lib/libcrypto/dh/dh.h +++ b/src/lib/libcrypto/dh/dh.h | |||
@@ -70,6 +70,8 @@ | |||
70 | #include <openssl/crypto.h> | 70 | #include <openssl/crypto.h> |
71 | #include <openssl/ossl_typ.h> | 71 | #include <openssl/ossl_typ.h> |
72 | 72 | ||
73 | #define OPENSSL_DH_MAX_MODULUS_BITS 10000 | ||
74 | |||
73 | #define DH_FLAG_CACHE_MONT_P 0x01 | 75 | #define DH_FLAG_CACHE_MONT_P 0x01 |
74 | #define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH | 76 | #define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH |
75 | * implementation now uses constant time | 77 | * implementation now uses constant time |
@@ -213,6 +215,7 @@ void ERR_load_DH_strings(void); | |||
213 | #define DH_R_BAD_GENERATOR 101 | 215 | #define DH_R_BAD_GENERATOR 101 |
214 | #define DH_R_NO_PRIVATE_VALUE 100 | 216 | #define DH_R_NO_PRIVATE_VALUE 100 |
215 | #define DH_R_INVALID_PUBKEY 102 | 217 | #define DH_R_INVALID_PUBKEY 102 |
218 | #define DH_R_MODULUS_TOO_LARGE 103 | ||
216 | 219 | ||
217 | #ifdef __cplusplus | 220 | #ifdef __cplusplus |
218 | } | 221 | } |
diff --git a/src/lib/libcrypto/dh/dh_err.c b/src/lib/libcrypto/dh/dh_err.c index 9336bfce6b..611067ef4a 100644 --- a/src/lib/libcrypto/dh/dh_err.c +++ b/src/lib/libcrypto/dh/dh_err.c | |||
@@ -84,6 +84,7 @@ static ERR_STRING_DATA DH_str_reasons[]= | |||
84 | {ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, | 84 | {ERR_REASON(DH_R_BAD_GENERATOR) ,"bad generator"}, |
85 | {ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"}, | 85 | {ERR_REASON(DH_R_NO_PRIVATE_VALUE) ,"no private value"}, |
86 | {ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, | 86 | {ERR_REASON(DH_R_INVALID_PUBKEY) ,"invalid public key"}, |
87 | {ERR_REASON(DH_R_MODULUS_TOO_LARGE) ,"modulus too large"}, | ||
87 | {0,NULL} | 88 | {0,NULL} |
88 | }; | 89 | }; |
89 | 90 | ||
diff --git a/src/lib/libcrypto/dh/dh_key.c b/src/lib/libcrypto/dh/dh_key.c index e3641ec468..74de589204 100644 --- a/src/lib/libcrypto/dh/dh_key.c +++ b/src/lib/libcrypto/dh/dh_key.c | |||
@@ -181,6 +181,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) | |||
181 | int ret= -1; | 181 | int ret= -1; |
182 | int check_result; | 182 | int check_result; |
183 | 183 | ||
184 | if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS) | ||
185 | { | ||
186 | DHerr(DH_F_DH_COMPUTE_KEY,DH_R_MODULUS_TOO_LARGE); | ||
187 | return -1; | ||
188 | } | ||
189 | |||
184 | ctx = BN_CTX_new(); | 190 | ctx = BN_CTX_new(); |
185 | if (ctx == NULL) goto err; | 191 | if (ctx == NULL) goto err; |
186 | BN_CTX_start(ctx); | 192 | BN_CTX_start(ctx); |