diff options
| author | Frederik Wedel-Heinen <[email protected]> | 2026-07-23 07:42:17 +0200 |
|---|---|---|
| committer | Tomas Mraz <[email protected]> | 2026-10-21 18:22:53 +0200 |
| commit | f8e81321519421dda2de315e6e7ab9653d809e4f (patch) | |
| tree | f6d1ca8de3c2554c698db4507e772107a1751593 | |
| parent | aes: fix riscv64 constant-time fallback selection (diff) | |
| download | openssl-f8e81321519421dda2de315e6e7ab9653d809e4f.tar.gz openssl-f8e81321519421dda2de315e6e7ab9653d809e4f.zip | |
Removes clean DES and RC2 as encryption methods for TLS ciphersuites and refactors the fetching of NULL cipher to be consistent.
Reviewed-by: Mounir Idrassi <[email protected]>
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Merge-date: Wed Oct 21 16:22:59 2026
Merged-from: https://github.com/openssl/openssl/pull/32051
| -rw-r--r-- | doc/man1/openssl-ciphers.pod.in | 4 | ||||
| -rw-r--r-- | ssl/ssl_ciph.c | 131 | ||||
| -rw-r--r-- | ssl/ssl_lib.c | 2 | ||||
| -rw-r--r-- | ssl/ssl_local.h | 83 |
4 files changed, 85 insertions, 135 deletions
diff --git a/doc/man1/openssl-ciphers.pod.in b/doc/man1/openssl-ciphers.pod.in index db8b6e55e13..45a66831742 100644 --- a/doc/man1/openssl-ciphers.pod.in +++ b/doc/man1/openssl-ciphers.pod.in @@ -432,8 +432,8 @@ permissible. All cipher suites using encryption algorithm in Cipher Block Chaining (CBC) mode. These cipher suites are only supported in TLS v1.2 and earlier. Currently -it's an alias for the following cipherstrings: B<SSL_DES>, B<SSL_3DES>, B<SSL_RC2>, -B<SSL_IDEA>, B<SSL_AES128>, B<SSL_AES256>, B<SSL_CAMELLIA128>, B<SSL_CAMELLIA256>, B<SSL_SEED>. +it's an alias for the following cipherstrings: B<3DES>, B<IDEA>, B<AES128>, +B<AES256>, B<CAMELLIA128>, B<CAMELLIA256>, B<SEED>. =back diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 7e1ec200dad..bb2c2e5eddf 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -37,32 +37,30 @@ typedef struct { /* Table of NIDs for each cipher */ static const ssl_cipher_table ssl_cipher_table_cipher[SSL_ENC_NUM_IDX] = { - { SSL_DES, NID_des_cbc }, /* SSL_ENC_DES_IDX 0 */ - { SSL_3DES, NID_des_ede3_cbc }, /* SSL_ENC_3DES_IDX 1 */ - { SSL_RC4, NID_rc4 }, /* SSL_ENC_RC4_IDX 2 */ - { SSL_RC2, NID_rc2_cbc }, /* SSL_ENC_RC2_IDX 3 */ - { SSL_IDEA, NID_idea_cbc }, /* SSL_ENC_IDEA_IDX 4 */ - { SSL_eNULL, NID_undef }, /* SSL_ENC_NULL_IDX 5 */ - { SSL_AES128, NID_aes_128_cbc }, /* SSL_ENC_AES128_IDX 6 */ - { SSL_AES256, NID_aes_256_cbc }, /* SSL_ENC_AES256_IDX 7 */ - { SSL_CAMELLIA128, NID_camellia_128_cbc }, /* SSL_ENC_CAMELLIA128_IDX 8 */ - { SSL_CAMELLIA256, NID_camellia_256_cbc }, /* SSL_ENC_CAMELLIA256_IDX 9 */ - { SSL_eGOST2814789CNT, NID_gost89_cnt }, /* SSL_ENC_GOST89_IDX 10 */ - { SSL_SEED, NID_seed_cbc }, /* SSL_ENC_SEED_IDX 11 */ - { SSL_AES128GCM, NID_aes_128_gcm }, /* SSL_ENC_AES128GCM_IDX 12 */ - { SSL_AES256GCM, NID_aes_256_gcm }, /* SSL_ENC_AES256GCM_IDX 13 */ - { SSL_AES128CCM, NID_aes_128_ccm }, /* SSL_ENC_AES128CCM_IDX 14 */ - { SSL_AES256CCM, NID_aes_256_ccm }, /* SSL_ENC_AES256CCM_IDX 15 */ - { SSL_AES128CCM8, NID_aes_128_ccm }, /* SSL_ENC_AES128CCM8_IDX 16 */ - { SSL_AES256CCM8, NID_aes_256_ccm }, /* SSL_ENC_AES256CCM8_IDX 17 */ - { SSL_eGOST2814789CNT12, NID_gost89_cnt_12 }, /* SSL_ENC_GOST8912_IDX 18 */ - { SSL_CHACHA20POLY1305, NID_chacha20_poly1305 }, /* SSL_ENC_CHACHA_IDX 19 */ - { SSL_ARIA128GCM, NID_aria_128_gcm }, /* SSL_ENC_ARIA128GCM_IDX 20 */ - { SSL_ARIA256GCM, NID_aria_256_gcm }, /* SSL_ENC_ARIA256GCM_IDX 21 */ - { SSL_MAGMA, NID_magma_ctr_acpkm }, /* SSL_ENC_MAGMA_IDX 22 */ - { SSL_KUZNYECHIK, NID_kuznyechik_ctr_acpkm }, /* SSL_ENC_KUZNYECHIK_IDX 23 */ - { SSL_SM4GCM, NID_sm4_gcm }, /* SSL_ENC_SM4GCM_IDX 24 */ - { SSL_SM4CCM, NID_sm4_ccm }, /* SSL_ENC_SM4CCM_IDX 25 */ + { SSL_3DES, NID_des_ede3_cbc }, + { SSL_RC4, NID_rc4 }, + { SSL_IDEA, NID_idea_cbc }, + { SSL_eNULL, NID_undef }, + { SSL_AES128, NID_aes_128_cbc }, + { SSL_AES256, NID_aes_256_cbc }, + { SSL_CAMELLIA128, NID_camellia_128_cbc }, + { SSL_CAMELLIA256, NID_camellia_256_cbc }, + { SSL_eGOST2814789CNT, NID_gost89_cnt }, + { SSL_SEED, NID_seed_cbc }, + { SSL_AES128GCM, NID_aes_128_gcm }, + { SSL_AES256GCM, NID_aes_256_gcm }, + { SSL_AES128CCM, NID_aes_128_ccm }, + { SSL_AES256CCM, NID_aes_256_ccm }, + { SSL_AES128CCM8, NID_aes_128_ccm }, + { SSL_AES256CCM8, NID_aes_256_ccm }, + { SSL_eGOST2814789CNT12, NID_gost89_cnt_12 }, + { SSL_CHACHA20POLY1305, NID_chacha20_poly1305 }, + { SSL_ARIA128GCM, NID_aria_128_gcm }, + { SSL_ARIA256GCM, NID_aria_256_gcm }, + { SSL_MAGMA, NID_magma_ctr_acpkm }, + { SSL_KUZNYECHIK, NID_kuznyechik_ctr_acpkm }, + { SSL_SM4GCM, NID_sm4_gcm }, + { SSL_SM4CCM, NID_sm4_ccm }, }; /* NB: make sure indices in this table matches values above */ @@ -152,7 +150,6 @@ static const int default_mac_pkey_id[SSL_MD_NUM_IDX] = { typedef struct cipher_order_st { const SSL_CIPHER *cipher; int active; - int dead; struct cipher_order_st *next, *prev; } CIPHER_ORDER; @@ -219,7 +216,6 @@ static const SSL_CIPHER cipher_aliases[] = { /* symmetric encryption aliases */ { 0, SSL_TXT_3DES, NULL, 0, 0, 0, SSL_3DES }, { 0, SSL_TXT_RC4, NULL, 0, 0, 0, SSL_RC4 }, - { 0, SSL_TXT_RC2, NULL, 0, 0, 0, SSL_RC2 }, { 0, SSL_TXT_IDEA, NULL, 0, 0, 0, SSL_IDEA }, { 0, SSL_TXT_SEED, NULL, 0, 0, 0, SSL_SEED }, { 0, SSL_TXT_eNULL, NULL, 0, 0, 0, SSL_eNULL }, @@ -283,15 +279,20 @@ int ssl_load_ciphers(SSL_CTX *ctx) ctx->disabled_enc_mask = 0; for (i = 0, t = ssl_cipher_table_cipher; i < SSL_ENC_NUM_IDX; i++, t++) { - if (t->nid != NID_undef) { - const EVP_CIPHER *cipher = ssl_evp_cipher_fetch(ctx->libctx, - OBJ_nid2sn(t->nid), - ctx->propq); + const EVP_CIPHER *cipher = NULL; + const char *sn = NULL; - ctx->ssl_cipher_methods[i] = cipher; - if (cipher == NULL) - ctx->disabled_enc_mask |= t->mask; - } + if (t->mask == SSL_eNULL) + sn = "NULL"; + else if (ossl_assert(t->nid != NID_undef)) + sn = OBJ_nid2sn(t->nid); + + if (sn != NULL) + cipher = ssl_evp_cipher_fetch(ctx->libctx, sn, ctx->propq); + + ctx->ssl_cipher_methods[i] = cipher; + if (cipher == NULL) + ctx->disabled_enc_mask |= t->mask; } ctx->disabled_mac_mask = 0; for (i = 0, t = ssl_cipher_table_mac; i < SSL_MD_NUM_IDX; i++, t++) { @@ -410,22 +411,12 @@ int ssl_cipher_get_evp_cipher(SSL_CTX *ctx, const SSL_CIPHER *sslc, if (i == -1) { *enc = NULL; } else { - if (i == SSL_ENC_NULL_IDX) { - /* - * This does not need any special handling. Use EVP_CIPHER_fetch() - * directly. - */ - *enc = EVP_CIPHER_fetch(ctx->libctx, "NULL", ctx->propq); - if (*enc == NULL) - return 0; - } else { - const EVP_CIPHER *cipher = ctx->ssl_cipher_methods[i]; + const EVP_CIPHER *cipher = ctx->ssl_cipher_methods[i]; - if (cipher == NULL - || !ssl_evp_cipher_up_ref(cipher)) - return 0; - *enc = ctx->ssl_cipher_methods[i]; - } + if (cipher == NULL + || !ssl_evp_cipher_up_ref(cipher)) + return 0; + *enc = ctx->ssl_cipher_methods[i]; } return 1; } @@ -465,28 +456,22 @@ int ssl_cipher_get_evp_cipher_sn(SSL_CTX *ctx, const SSL_CIPHER *sslc, if (i == -1) { *enc = NULL; } else { - if (i == SSL_ENC_NULL_IDX) { - /* - * We assume we don't care about this coming from an ENGINE so - * just do a normal EVP_CIPHER_fetch instead of - * ssl_evp_cipher_fetch() - */ - *enc = EVP_CIPHER_fetch(ctx->libctx, "NULL", ctx->propq); - } else { - int ecbnid = NID_undef; + const char *sn = NULL; - *enc = NULL; + *enc = NULL; - if ((sslc->algorithm_enc & SSL_AES128_ANY) != 0) - ecbnid = NID_aes_128_ecb; - else if ((sslc->algorithm_enc & SSL_AES256_ANY) != 0) - ecbnid = NID_aes_256_ecb; - else if (ossl_assert((sslc->algorithm_enc & SSL_CHACHA20) != 0)) - ecbnid = NID_chacha20; + if ((sslc->algorithm_enc & SSL_AES128_ANY) != 0) + sn = OBJ_nid2sn(NID_aes_128_ecb); + else if ((sslc->algorithm_enc & SSL_AES256_ANY) != 0) + sn = OBJ_nid2sn(NID_aes_256_ecb); + else if (sslc->algorithm_enc == SSL_eNULL) + sn = "NULL"; + else if (ossl_assert((sslc->algorithm_enc & SSL_CHACHA20) != 0)) + sn = OBJ_nid2sn(NID_chacha20); + else + return 0; - if (ecbnid != NID_undef) - *enc = ssl_evp_cipher_fetch(ctx->libctx, OBJ_nid2sn(ecbnid), ctx->propq); - } + *enc = EVP_CIPHER_fetch(ctx->libctx, sn, ctx->propq); if (*enc == NULL) return 0; @@ -1780,18 +1765,12 @@ char *SSL_CIPHER_description(const SSL_CIPHER *cipher, char *buf, int len) } switch (alg_enc) { - case SSL_DES: - enc = "DES(56)"; - break; case SSL_3DES: enc = "3DES(168)"; break; case SSL_RC4: enc = "RC4(128)"; break; - case SSL_RC2: - enc = "RC2(128)"; - break; case SSL_IDEA: enc = "IDEA(128)"; break; diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 03914f1c1aa..9b39de702c2 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -4778,7 +4778,7 @@ void SSL_CTX_free(SSL_CTX *a) OPENSSL_free(a->ext.alpn); OPENSSL_secure_clear_free(a->ext.secure, sizeof(*a->ext.secure)); - for (j = 0; j < SSL_ENC_NUM_IDX; j++) + for (j = 0; j < OSSL_NELEM(a->ssl_cipher_methods); j++) ssl_evp_cipher_free(a->ssl_cipher_methods[j]); for (j = 0; j < SSL_MD_NUM_IDX; j++) ssl_evp_md_free(a->ssl_digest_methods[j]); diff --git a/ssl/ssl_local.h b/ssl/ssl_local.h index dc375b3f593..205f4d2275b 100644 --- a/ssl/ssl_local.h +++ b/ssl/ssl_local.h @@ -195,32 +195,31 @@ typedef struct dgram_conn_lookup_st DGRAM_CONN_LOOKUP; (SSL_aRSA | SSL_aDSS | SSL_aECDSA | SSL_aGOST01 | SSL_aGOST12) /* Bits for algorithm_enc (symmetric encryption) */ -#define SSL_DES 0x00000001U -#define SSL_3DES 0x00000002U -#define SSL_RC4 0x00000004U -#define SSL_RC2 0x00000008U -#define SSL_IDEA 0x00000010U -#define SSL_eNULL 0x00000020U -#define SSL_AES128 0x00000040U -#define SSL_AES256 0x00000080U -#define SSL_CAMELLIA128 0x00000100U -#define SSL_CAMELLIA256 0x00000200U -#define SSL_eGOST2814789CNT 0x00000400U -#define SSL_SEED 0x00000800U -#define SSL_AES128GCM 0x00001000U -#define SSL_AES256GCM 0x00002000U -#define SSL_AES128CCM 0x00004000U -#define SSL_AES256CCM 0x00008000U -#define SSL_AES128CCM8 0x00010000U -#define SSL_AES256CCM8 0x00020000U -#define SSL_eGOST2814789CNT12 0x00040000U -#define SSL_CHACHA20POLY1305 0x00080000U -#define SSL_ARIA128GCM 0x00100000U -#define SSL_ARIA256GCM 0x00200000U -#define SSL_MAGMA 0x00400000U -#define SSL_KUZNYECHIK 0x00800000U -#define SSL_SM4GCM 0x01000000U -#define SSL_SM4CCM 0x02000000U +#define SSL_3DES 1U +#define SSL_RC4 (1U << 1) +#define SSL_IDEA (1U << 2) +#define SSL_eNULL (1U << 3) +#define SSL_AES128 (1U << 4) +#define SSL_AES256 (1U << 5) +#define SSL_CAMELLIA128 (1U << 6) +#define SSL_CAMELLIA256 (1U << 7) +#define SSL_eGOST2814789CNT (1U << 8) +#define SSL_SEED (1U << 9) +#define SSL_AES128GCM (1U << 10) +#define SSL_AES256GCM (1U << 11) +#define SSL_AES128CCM (1U << 12) +#define SSL_AES256CCM (1U << 13) +#define SSL_AES128CCM8 (1U << 14) +#define SSL_AES256CCM8 (1U << 15) +#define SSL_eGOST2814789CNT12 (1U << 16) +#define SSL_CHACHA20POLY1305 (1U << 17) +#define SSL_ARIA128GCM (1U << 18) +#define SSL_ARIA256GCM (1U << 19) +#define SSL_MAGMA (1U << 20) +#define SSL_KUZNYECHIK (1U << 21) +#define SSL_SM4GCM (1U << 22) +#define SSL_SM4CCM (1U << 23) +#define SSL_ENC_NUM_IDX 24 #define SSL_AESGCM (SSL_AES128GCM | SSL_AES256GCM) #define SSL_AESCCM (SSL_AES128CCM | SSL_AES256CCM | SSL_AES128CCM8 | SSL_AES256CCM8) @@ -233,8 +232,8 @@ typedef struct dgram_conn_lookup_st DGRAM_CONN_LOOKUP; #define SSL_CHACHA20 (SSL_CHACHA20POLY1305) #define SSL_ARIAGCM (SSL_ARIA128GCM | SSL_ARIA256GCM) #define SSL_ARIA (SSL_ARIAGCM) -#define SSL_CBC (SSL_DES | SSL_3DES | SSL_RC2 | SSL_IDEA \ - | SSL_AES128 | SSL_AES256 | SSL_CAMELLIA128 \ +#define SSL_CBC (SSL_3DES | SSL_IDEA \ + | SSL_AES128 | SSL_AES256 | SSL_CAMELLIA128 \ | SSL_CAMELLIA256 | SSL_SEED) /* Bits for algorithm_mac (symmetric authentication) */ @@ -411,34 +410,6 @@ typedef struct dgram_conn_lookup_st DGRAM_CONN_LOOKUP; #define SSL_PKEY_ED448 8 #define SSL_PKEY_NUM 9 -#define SSL_ENC_DES_IDX 0 -#define SSL_ENC_3DES_IDX 1 -#define SSL_ENC_RC4_IDX 2 -#define SSL_ENC_RC2_IDX 3 -#define SSL_ENC_IDEA_IDX 4 -#define SSL_ENC_NULL_IDX 5 -#define SSL_ENC_AES128_IDX 6 -#define SSL_ENC_AES256_IDX 7 -#define SSL_ENC_CAMELLIA128_IDX 8 -#define SSL_ENC_CAMELLIA256_IDX 9 -#define SSL_ENC_GOST89_IDX 10 -#define SSL_ENC_SEED_IDX 11 -#define SSL_ENC_AES128GCM_IDX 12 -#define SSL_ENC_AES256GCM_IDX 13 -#define SSL_ENC_AES128CCM_IDX 14 -#define SSL_ENC_AES256CCM_IDX 15 -#define SSL_ENC_AES128CCM8_IDX 16 -#define SSL_ENC_AES256CCM8_IDX 17 -#define SSL_ENC_GOST8912_IDX 18 -#define SSL_ENC_CHACHA_IDX 19 -#define SSL_ENC_ARIA128GCM_IDX 20 -#define SSL_ENC_ARIA256GCM_IDX 21 -#define SSL_ENC_MAGMA_IDX 22 -#define SSL_ENC_KUZNYECHIK_IDX 23 -#define SSL_ENC_SM4GCM_IDX 24 -#define SSL_ENC_SM4CCM_IDX 25 -#define SSL_ENC_NUM_IDX 26 - /*- * SSL_kRSA <- RSA_ENC * SSL_kDH <- DH_ENC & (RSA_ENC | RSA_SIGN | DSA_SIGN) |
