Remove cipher table lookup from EVP_CipherInit_ex
authorShane Lontis <shane.lontis@oracle.com>
Tue, 5 May 2020 06:51:32 +0000 (16:51 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Thu, 7 May 2020 05:25:48 +0000 (15:25 +1000)
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11731)

crypto/evp/evp_enc.c

index 0f7b0a7ddede64b621a072dcdf1e9d9b16250e87..0f6fbb64ecff04b5e7fa05e94e981b35fe7c9a35 100644 (file)
@@ -84,8 +84,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
     ENGINE *tmpimpl = NULL;
 #endif
 #if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
     ENGINE *tmpimpl = NULL;
 #endif
-    const EVP_CIPHER *tmpcipher;
-
     /*
      * enc == 1 means we are encrypting.
      * enc == 0 means we are decrypting.
     /*
      * enc == 1 means we are encrypting.
      * enc == 0 means we are decrypting.
@@ -137,164 +135,6 @@ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
         ctx->fetched_cipher = NULL;
         goto legacy;
     }
         ctx->fetched_cipher = NULL;
         goto legacy;
     }
-
-    tmpcipher = (cipher == NULL) ? ctx->cipher : cipher;
-
-    if (tmpcipher->prov == NULL) {
-        switch(tmpcipher->nid) {
-        case NID_undef:
-        case NID_aes_256_ecb:
-        case NID_aes_192_ecb:
-        case NID_aes_128_ecb:
-        case NID_aes_256_cbc:
-        case NID_aes_192_cbc:
-        case NID_aes_128_cbc:
-        case NID_aes_256_ofb128:
-        case NID_aes_192_ofb128:
-        case NID_aes_128_ofb128:
-        case NID_aes_256_cfb128:
-        case NID_aes_192_cfb128:
-        case NID_aes_128_cfb128:
-        case NID_aes_256_cfb1:
-        case NID_aes_192_cfb1:
-        case NID_aes_128_cfb1:
-        case NID_aes_256_cfb8:
-        case NID_aes_192_cfb8:
-        case NID_aes_128_cfb8:
-        case NID_aes_256_ctr:
-        case NID_aes_192_ctr:
-        case NID_aes_128_ctr:
-        case NID_aes_128_xts:
-        case NID_aes_256_xts:
-        case NID_aes_256_ocb:
-        case NID_aes_192_ocb:
-        case NID_aes_128_ocb:
-        case NID_aes_256_gcm:
-        case NID_aes_192_gcm:
-        case NID_aes_128_gcm:
-        case NID_aes_256_siv:
-        case NID_aes_192_siv:
-        case NID_aes_128_siv:
-        case NID_aes_256_cbc_hmac_sha256:
-        case NID_aes_128_cbc_hmac_sha256:
-        case NID_aes_256_cbc_hmac_sha1:
-        case NID_aes_128_cbc_hmac_sha1:
-        case NID_id_aes256_wrap:
-        case NID_id_aes256_wrap_pad:
-        case NID_id_aes192_wrap:
-        case NID_id_aes192_wrap_pad:
-        case NID_id_aes128_wrap:
-        case NID_id_aes128_wrap_pad:
-        case NID_aria_256_gcm:
-        case NID_aria_192_gcm:
-        case NID_aria_128_gcm:
-        case NID_aes_256_ccm:
-        case NID_aes_192_ccm:
-        case NID_aes_128_ccm:
-        case NID_aria_256_ccm:
-        case NID_aria_192_ccm:
-        case NID_aria_128_ccm:
-        case NID_aria_256_ecb:
-        case NID_aria_192_ecb:
-        case NID_aria_128_ecb:
-        case NID_aria_256_cbc:
-        case NID_aria_192_cbc:
-        case NID_aria_128_cbc:
-        case NID_aria_256_ofb128:
-        case NID_aria_192_ofb128:
-        case NID_aria_128_ofb128:
-        case NID_aria_256_cfb128:
-        case NID_aria_192_cfb128:
-        case NID_aria_128_cfb128:
-        case NID_aria_256_cfb1:
-        case NID_aria_192_cfb1:
-        case NID_aria_128_cfb1:
-        case NID_aria_256_cfb8:
-        case NID_aria_192_cfb8:
-        case NID_aria_128_cfb8:
-        case NID_aria_256_ctr:
-        case NID_aria_192_ctr:
-        case NID_aria_128_ctr:
-        case NID_camellia_256_ecb:
-        case NID_camellia_192_ecb:
-        case NID_camellia_128_ecb:
-        case NID_camellia_256_cbc:
-        case NID_camellia_192_cbc:
-        case NID_camellia_128_cbc:
-        case NID_camellia_256_ofb128:
-        case NID_camellia_192_ofb128:
-        case NID_camellia_128_ofb128:
-        case NID_camellia_256_cfb128:
-        case NID_camellia_192_cfb128:
-        case NID_camellia_128_cfb128:
-        case NID_camellia_256_cfb1:
-        case NID_camellia_192_cfb1:
-        case NID_camellia_128_cfb1:
-        case NID_camellia_256_cfb8:
-        case NID_camellia_192_cfb8:
-        case NID_camellia_128_cfb8:
-        case NID_camellia_256_ctr:
-        case NID_camellia_192_ctr:
-        case NID_camellia_128_ctr:
-        case NID_des_ede3_cbc:
-        case NID_des_ede3_ecb:
-        case NID_des_ede3_ofb64:
-        case NID_des_ede3_cfb64:
-        case NID_des_ede3_cfb8:
-        case NID_des_ede3_cfb1:
-        case NID_des_ede_cbc:
-        case NID_des_ede_ecb:
-        case NID_des_ede_ofb64:
-        case NID_des_ede_cfb64:
-        case NID_desx_cbc:
-        case NID_des_cbc:
-        case NID_des_ecb:
-        case NID_des_cfb1:
-        case NID_des_cfb8:
-        case NID_des_cfb64:
-        case NID_des_ofb64:
-        case NID_id_smime_alg_CMS3DESwrap:
-        case NID_bf_cbc:
-        case NID_bf_ecb:
-        case NID_bf_cfb64:
-        case NID_bf_ofb64:
-        case NID_idea_cbc:
-        case NID_idea_ecb:
-        case NID_idea_cfb64:
-        case NID_idea_ofb64:
-        case NID_cast5_cbc:
-        case NID_cast5_ecb:
-        case NID_cast5_cfb64:
-        case NID_cast5_ofb64:
-        case NID_seed_cbc:
-        case NID_seed_ecb:
-        case NID_seed_cfb128:
-        case NID_seed_ofb128:
-        case NID_sm4_cbc:
-        case NID_sm4_ecb:
-        case NID_sm4_ctr:
-        case NID_sm4_cfb128:
-        case NID_sm4_ofb128:
-        case NID_rc4:
-        case NID_rc4_40:
-        case NID_rc5_cbc:
-        case NID_rc5_ecb:
-        case NID_rc5_cfb64:
-        case NID_rc5_ofb64:
-        case NID_rc2_cbc:
-        case NID_rc2_40_cbc:
-        case NID_rc2_64_cbc:
-        case NID_rc2_cfb64:
-        case NID_rc2_ofb64:
-        case NID_chacha20:
-        case NID_chacha20_poly1305:
-        case NID_rc4_hmac_md5:
-            break;
-        default:
-            goto legacy;
-        }
-    }
-
     /*
      * Ensure a context left lying around from last time is cleared
      * (legacy code)
     /*
      * Ensure a context left lying around from last time is cleared
      * (legacy code)