Commit 5e3225cc authored by Bodo Möller's avatar Bodo Möller
Browse files

Introduce limits to prevent malicious keys being able to

cause a denial of service.  (CVE-2006-2940)
[Steve Henson, Bodo Moeller]
parent 61118caa
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@
#include <openssl/bn.h>
#endif
	
#ifndef OPENSSL_DH_MAX_MODULUS_BITS
# define OPENSSL_DH_MAX_MODULUS_BITS	10000
#endif

#define DH_FLAG_CACHE_MONT_P     0x01
#define DH_FLAG_NO_EXP_CONSTTIME 0x02 /* new with 0.9.7h; the built-in DH
                                       * implementation now uses constant time
@@ -239,11 +243,12 @@ void ERR_load_DH_strings(void);

/* Reason codes. */
#define DH_R_BAD_GENERATOR				 101
#define DH_R_BN_DECODE_ERROR				 103
#define DH_R_BN_DECODE_ERROR				 109
#define DH_R_BN_ERROR					 106
#define DH_R_DECODE_ERROR				 104
#define DH_R_INVALID_PUBKEY				 102
#define DH_R_KEYS_NOT_SET				 108
#define DH_R_MODULUS_TOO_LARGE				 103
#define DH_R_NO_PARAMETERS_SET				 107
#define DH_R_NO_PRIVATE_VALUE				 100
#define DH_R_PARAMETER_ENCODING_ERROR			 105
+1 −0
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ static ERR_STRING_DATA DH_str_reasons[]=
{ERR_REASON(DH_R_DECODE_ERROR)           ,"decode error"},
{ERR_REASON(DH_R_INVALID_PUBKEY)         ,"invalid public key"},
{ERR_REASON(DH_R_KEYS_NOT_SET)           ,"keys not set"},
{ERR_REASON(DH_R_MODULUS_TOO_LARGE)      ,"modulus too large"},
{ERR_REASON(DH_R_NO_PARAMETERS_SET)      ,"no parameters set"},
{ERR_REASON(DH_R_NO_PRIVATE_VALUE)       ,"no private value"},
{ERR_REASON(DH_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"},
+6 −0
Original line number Diff line number Diff line
@@ -179,6 +179,12 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
	int ret= -1;
        int check_result;

	if (BN_num_bits(dh->p) > OPENSSL_DH_MAX_MODULUS_BITS)
		{
		DHerr(DH_F_COMPUTE_KEY,DH_R_MODULUS_TOO_LARGE);
		goto err;
		}

	ctx = BN_CTX_new();
	if (ctx == NULL) goto err;
	BN_CTX_start(ctx);
+8 −2
Original line number Diff line number Diff line
@@ -84,6 +84,10 @@
#endif
#endif

#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
# define OPENSSL_DSA_MAX_MODULUS_BITS	10000
#endif

#define DSA_FLAG_CACHE_MONT_P	0x01
#define DSA_FLAG_NO_EXP_CONSTTIME       0x02 /* new with 0.9.7h; the built-in DSA
                                              * implementation now uses constant time
@@ -284,12 +288,14 @@ void ERR_load_DSA_strings(void);
#define DSA_F_SIG_CB					 114

/* Reason codes. */
#define DSA_R_BN_DECODE_ERROR				 102
#define DSA_R_BN_ERROR					 103
#define DSA_R_BAD_Q_VALUE				 102
#define DSA_R_BN_DECODE_ERROR				 108
#define DSA_R_BN_ERROR					 109
#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 100
#define DSA_R_DECODE_ERROR				 104
#define DSA_R_INVALID_DIGEST_TYPE			 106
#define DSA_R_MISSING_PARAMETERS			 101
#define DSA_R_MODULUS_TOO_LARGE				 103
#define DSA_R_NO_PARAMETERS_SET				 107
#define DSA_R_PARAMETER_ENCODING_ERROR			 105

+2 −0
Original line number Diff line number Diff line
@@ -97,12 +97,14 @@ static ERR_STRING_DATA DSA_str_functs[]=

static ERR_STRING_DATA DSA_str_reasons[]=
	{
{ERR_REASON(DSA_R_BAD_Q_VALUE)           ,"bad q value"},
{ERR_REASON(DSA_R_BN_DECODE_ERROR)       ,"bn decode error"},
{ERR_REASON(DSA_R_BN_ERROR)              ,"bn error"},
{ERR_REASON(DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE),"data too large for key size"},
{ERR_REASON(DSA_R_DECODE_ERROR)          ,"decode error"},
{ERR_REASON(DSA_R_INVALID_DIGEST_TYPE)   ,"invalid digest type"},
{ERR_REASON(DSA_R_MISSING_PARAMETERS)    ,"missing parameters"},
{ERR_REASON(DSA_R_MODULUS_TOO_LARGE)     ,"modulus too large"},
{ERR_REASON(DSA_R_NO_PARAMETERS_SET)     ,"no parameters set"},
{ERR_REASON(DSA_R_PARAMETER_ENCODING_ERROR),"parameter encoding error"},
{0,NULL}
Loading