Skip to content

Commit

Permalink
add differentiation for AES HW acceleration when ordering ciphers for…
Browse files Browse the repository at this point in the history
… tls 1.3
  • Loading branch information
Mittal committed Jan 6, 2025
1 parent fe430f4 commit 72603cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 12 additions & 5 deletions include/openssl/ssl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1698,11 +1698,18 @@ OPENSSL_EXPORT size_t SSL_get_all_standard_cipher_names(const char **out,
// substituted when a cipher string starts with 'DEFAULT'.
#define SSL_DEFAULT_CIPHER_LIST "ALL"

// TLS13_DEFAULT_CIPHER_LIST is the default TLS 1.3 cipher suite
// configuration.
#define TLS13_DEFAULT_CIPHER_LIST "TLS_AES_128_GCM_SHA256:" \
"TLS_AES_256_GCM_SHA384:" \
"TLS_CHACHA20_POLY1305_SHA256"
// TLS13_DEFAULT_CIPHER_LIST_AES_HW is the default TLS 1.3 cipher suite
// configuration when AES hardware acceleration is enabled.
#define TLS13_DEFAULT_CIPHER_LIST_AES_HW "TLS_AES_128_GCM_SHA256:" \
"TLS_AES_256_GCM_SHA384:" \
"TLS_CHACHA20_POLY1305_SHA256"

// TLS13_DEFAULT_CIPHER_LIST_NO_AES_HW is the default TLS 1.3 cipher suite
// configuration when no AES hardware acceleration is enabled.
#define TLS13_DEFAULT_CIPHER_LIST_NO_AES_HW "TLS_CHACHA20_POLY1305_SHA256:" \
"TLS_AES_128_GCM_SHA256:" \
"TLS_AES_256_GCM_SHA384"


// SSL_CTX_set_strict_cipher_list configures the cipher list for |ctx|,
// evaluating |str| as a cipher string and returning error if |str| contains
Expand Down
10 changes: 9 additions & 1 deletion ssl/ssl_lib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,15 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *method) {
return nullptr;
}

if (!SSL_CTX_set_ciphersuites(ret.get(), TLS13_DEFAULT_CIPHER_LIST) ||
bool has_aes_hw = EVP_has_aes_hardware();
char *cipher_rule;
if (has_aes_hw) {
cipher_rule = TLS13_DEFAULT_CIPHER_LIST_AES_HW;
} else {
cipher_rule = TLS13_DEFAULT_CIPHER_LIST_NO_AES_HW;
}

if (!SSL_CTX_set_ciphersuites(ret.get(), cipher_rule) ||
!SSL_CTX_set_strict_cipher_list(ret.get(), SSL_DEFAULT_CIPHER_LIST) ||
// Lock the SSL_CTX to the specified version, for compatibility with
// legacy uses of SSL_METHOD.
Expand Down

0 comments on commit 72603cc

Please sign in to comment.