Correctly check for export size limit
authorKurt Roeckx <kurt@roeckx.be>
Sat, 18 Apr 2015 10:50:25 +0000 (12:50 +0200)
committerKurt Roeckx <kurt@roeckx.be>
Wed, 20 May 2015 20:19:34 +0000 (22:19 +0200)
40 bit ciphers are limited to 512 bit RSA, 56 bit ciphers to 1024 bit.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit ac38115c1a4fb61c66c2a8cd2a9800751828d328)

crypto/evp/evp.h
crypto/x509/x509type.c
ssl/s3_clnt.c

index 4891133daeda99c2686d9f5281bd796e8ada6a91..1d705cd5defacb118ab93d81783d524c98ba9f65 100644 (file)
 # define EVP_PKS_RSA     0x0100
 # define EVP_PKS_DSA     0x0200
 # define EVP_PKS_EC      0x0400
-# define EVP_PKT_EXP     0x1000 /* <= 512 bit key */
 
 # define EVP_PKEY_NONE   NID_undef
 # define EVP_PKEY_RSA    NID_rsaEncryption
index 033175257a7738bdf61175f571dca37db252b2fc..9219f753bf9327afbdf9ed1a6201c8ba657468a8 100644 (file)
@@ -121,9 +121,6 @@ int X509_certificate_type(X509 *x, EVP_PKEY *pkey)
         }
     }
 
-    /* /8 because it's 1024 bits we look for, not bytes */
-    if (EVP_PKEY_size(pk) <= 1024 / 8)
-        ret |= EVP_PKT_EXP;
     if (pkey == NULL)
         EVP_PKEY_free(pk);
     return (ret);
index c25e077288fbc350d5314f468733682b3af87443..98c7b9e3f0dbb969e3c14a8ee362e677c3067910 100644 (file)
@@ -3398,6 +3398,7 @@ int ssl3_check_cert_and_algorithm(SSL *s)
     int i, idx;
     long alg_k, alg_a;
     EVP_PKEY *pkey = NULL;
+    int pkey_bits;
     SESS_CERT *sc;
 #ifndef OPENSSL_NO_RSA
     RSA *rsa;
@@ -3447,6 +3448,7 @@ int ssl3_check_cert_and_algorithm(SSL *s)
     }
 #endif
     pkey = X509_get_pubkey(sc->peer_pkeys[idx].x509);
+    pkey_bits = EVP_PKEY_bits(pkey);
     i = X509_certificate_type(sc->peer_pkeys[idx].x509, pkey);
     EVP_PKEY_free(pkey);
 
@@ -3511,7 +3513,8 @@ int ssl3_check_cert_and_algorithm(SSL *s)
     }
 #endif  /* !OPENSSL_NO_DH */
 
-    if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) && !has_bits(i, EVP_PKT_EXP)) {
+    if (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher) &&
+        pkey_bits > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)) {
 #ifndef OPENSSL_NO_RSA
         if (alg_k & SSL_kRSA) {
             if (rsa == NULL