aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/dsa
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/dsa')
-rw-r--r--crypto/openssl/crypto/dsa/dsa.h6
-rw-r--r--crypto/openssl/crypto/dsa/dsa_err.c2
-rw-r--r--crypto/openssl/crypto/dsa/dsa_ossl.c12
3 files changed, 20 insertions, 0 deletions
diff --git a/crypto/openssl/crypto/dsa/dsa.h b/crypto/openssl/crypto/dsa/dsa.h
index 9b3baadf2c49..d85258b87831 100644
--- a/crypto/openssl/crypto/dsa/dsa.h
+++ b/crypto/openssl/crypto/dsa/dsa.h
@@ -79,6 +79,10 @@
# include <openssl/dh.h>
#endif
+#ifndef OPENSSL_DSA_MAX_MODULUS_BITS
+# define OPENSSL_DSA_MAX_MODULUS_BITS 10000
+#endif
+
#define DSA_FLAG_CACHE_MONT_P 0x01
#ifdef __cplusplus
@@ -241,8 +245,10 @@ void ERR_load_DSA_strings(void);
#define DSA_F_SIG_CB 114
/* Reason codes. */
+#define DSA_R_BAD_Q_VALUE 102
#define DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 100
#define DSA_R_MISSING_PARAMETERS 101
+#define DSA_R_MODULUS_TOO_LARGE 103
#ifdef __cplusplus
}
diff --git a/crypto/openssl/crypto/dsa/dsa_err.c b/crypto/openssl/crypto/dsa/dsa_err.c
index 79aa4ff526c4..bf96765ccd6d 100644
--- a/crypto/openssl/crypto/dsa/dsa_err.c
+++ b/crypto/openssl/crypto/dsa/dsa_err.c
@@ -85,8 +85,10 @@ static ERR_STRING_DATA DSA_str_functs[]=
static ERR_STRING_DATA DSA_str_reasons[]=
{
+{DSA_R_BAD_Q_VALUE ,"bad q value"},
{DSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE ,"data too large for key size"},
{DSA_R_MISSING_PARAMETERS ,"missing parameters"},
+{DSA_R_MODULUS_TOO_LARGE ,"modulus too large"},
{0,NULL}
};
diff --git a/crypto/openssl/crypto/dsa/dsa_ossl.c b/crypto/openssl/crypto/dsa/dsa_ossl.c
index b9e7f3ea5c66..1dfbc250d2b0 100644
--- a/crypto/openssl/crypto/dsa/dsa_ossl.c
+++ b/crypto/openssl/crypto/dsa/dsa_ossl.c
@@ -244,6 +244,18 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len, DSA_SIG *sig,
return -1;
}
+ if (BN_num_bits(dsa->q) != 160)
+ {
+ DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_BAD_Q_VALUE);
+ return -1;
+ }
+
+ if (BN_num_bits(dsa->p) > OPENSSL_DSA_MAX_MODULUS_BITS)
+ {
+ DSAerr(DSA_F_DSA_DO_VERIFY,DSA_R_MODULUS_TOO_LARGE);
+ return -1;
+ }
+
BN_init(&u1);
BN_init(&u2);
BN_init(&t1);