Skip to content

Commit a755968

Browse files
committed
indentation and documentation
1 parent 0e66ad6 commit a755968

File tree

4 files changed

+57
-31
lines changed

4 files changed

+57
-31
lines changed

include/openssl/ssl.h

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,14 +1698,19 @@ OPENSSL_EXPORT size_t SSL_get_all_standard_cipher_names(const char **out,
16981698
// substituted when a cipher string starts with 'DEFAULT'.
16991699
#define SSL_DEFAULT_CIPHER_LIST "ALL"
17001700

1701+
17011702
// SSL_CTX_set_strict_cipher_list configures the cipher list for |ctx|,
17021703
// evaluating |str| as a cipher string and returning error if |str| contains
1703-
// anything meaningless. It returns one on success and zero on failure.
1704+
// anything meaningless. It updates |ctx->cipher_list| with any values in
1705+
// |ctx->tls13_cipher_list|.
1706+
//
1707+
// It returns one on success and zero on failure.
17041708
OPENSSL_EXPORT int SSL_CTX_set_strict_cipher_list(SSL_CTX *ctx,
17051709
const char *str);
17061710

17071711
// SSL_CTX_set_cipher_list configures the cipher list for |ctx|, evaluating
1708-
// |str| as a cipher string. It returns one on success and zero on failure.
1712+
// |str| as a cipher string. It updates |ctx->cipher_list| with any values in
1713+
// |ctx->tls13_cipher_list|. It returns one on success and zero on failure.
17091714
//
17101715
// Prefer to use |SSL_CTX_set_strict_cipher_list|. This function tolerates
17111716
// garbage inputs, unless an empty cipher list results. However, an empty
@@ -1719,24 +1724,34 @@ OPENSSL_EXPORT int SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *str);
17191724

17201725
// SSL_set_strict_cipher_list configures the cipher list for |ssl|, evaluating
17211726
// |str| as a cipher string and returning error if |str| contains anything
1722-
// meaningless. It returns one on success and zero on failure.
1727+
// meaningless.
1728+
// It updates the cipher list |ssl->config->cipher_list| with any configured
1729+
// TLS 1.3 cipher suites by first checking |ssl->config->tls13_cipher_list| and
1730+
// otherwise falling back to |ssl->ctx->tls13_cipher_list|.
1731+
//
1732+
// It returns one on success and zero on failure.
17231733
OPENSSL_EXPORT int SSL_set_strict_cipher_list(SSL *ssl, const char *str);
17241734

1725-
// SSL_CTX_set_ciphersuites configure the available TLSv1.3 ciphersuites for
1726-
// |ctx|, evaluating |str| as a cipher string. It returns one on success and
1735+
// SSL_CTX_set_ciphersuites configures the available TLSv1.3 ciphersuites on
1736+
// |ctx|, evaluating |str| as a cipher string. It updates |ctx->cipher_list|
1737+
// with any values in |ctx->tls13_cipher_list|. It returns one on success and
17271738
// zero on failure.
17281739
OPENSSL_EXPORT int SSL_CTX_set_ciphersuites(SSL_CTX *ctx, const char *str);
17291740

1730-
// SSL_set_ciphersuites sets the available TLSv1.3 ciphersuites on an |ssl|,
1731-
// returning one on success and zero on failure. In OpenSSL, the only
1732-
// difference between |SSL_CTX_set_ciphersuites| and |SSL_set_ciphersuites| is
1733-
// that the latter copies the |SSL|'s |cipher_list| to its associated
1734-
// |SSL_CONNECTION|. In AWS-LC, we track everything on the |ssl|'s |config| so
1735-
// duplication is not necessary.
1741+
// SSL_set_ciphersuites configures the available TLSv1.3 ciphersuites on
1742+
// |ssl|, evaluating |str| as a cipher string. It updates
1743+
// |ssl->config->cipher_list| with any values in
1744+
// |ssl->config->tls13_cipher_list|. It returns one on success and zero on
1745+
// failure.
17361746
OPENSSL_EXPORT int SSL_set_ciphersuites(SSL *ssl, const char *str);
17371747

17381748
// SSL_set_cipher_list configures the cipher list for |ssl|, evaluating |str| as
1739-
// a cipher string. It returns one on success and zero on failure.
1749+
// a cipher string. It updates the cipher list |ssl->config->cipher_list| with
1750+
// any configured TLS 1.3 cipher suites by first checking
1751+
// |ssl->config->tls13_cipher_list| and otherwise falling back to
1752+
// |ssl->ctx->tls13_cipher_list|.
1753+
//
1754+
// It returns one on success and zero on failure.
17401755
//
17411756
// Prefer to use |SSL_set_strict_cipher_list|. This function tolerates garbage
17421757
// inputs, unless an empty cipher list results. However, an empty string which

ssl/handshake_client.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,11 @@ static bool ssl_write_client_cipher_list(const SSL_HANDSHAKE *hs, CBB *out,
273273
OPENSSL_PUT_ERROR(SSL, SSL_R_NO_CIPHERS_AVAILABLE);
274274
return false;
275275
}
276-
} else if (hs->max_version >= TLS1_3_VERSION && ssl->ctx->tls13_cipher_list) {
276+
} else if (hs->max_version >= TLS1_3_VERSION) {
277277
// Only TLS 1.3 ciphers
278-
STACK_OF(SSL_CIPHER) *ciphers = ssl->ctx->tls13_cipher_list->ciphers.get();
278+
STACK_OF(SSL_CIPHER) *ciphers = (ssl->config && ssl->config->tls13_cipher_list) ?
279+
ssl->config->tls13_cipher_list->ciphers.get() : ssl->ctx->tls13_cipher_list->ciphers.get();
280+
279281
bool any_enabled = false;
280282

281283
if (!collect_cipher_protocol_ids(ciphers, &child, mask_k,

ssl/internal.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -715,16 +715,27 @@ const EVP_MD *ssl_get_handshake_digest(uint16_t version,
715715
// rejected. If false, nonsense will be silently ignored. If |config_tls13| is
716716
// true, only TLS 1.3 ciphers are considered in |ssl_cipher_collect_ciphers|. If
717717
// false, TLS 1.2 and below ciphers participate in |ssl_cipher_collect_ciphers|.
718-
// In every invocation, |ctx->cipher_list| is updated with any user-configured
719-
// or default TLS 1.3 cipher suites in |ctx->tls13_cipher_list|.
720-
//
721718
// An empty result is considered an error regardless of |strict| or
722719
// |config_tls13|. |has_aes_hw| indicates if the list should be ordered based on
723720
// having support for AES in hardware or not.
724721
bool ssl_create_cipher_list(UniquePtr<SSLCipherPreferenceList> *out_cipher_list,
725722
const bool has_aes_hw, const char *rule_str,
726723
bool strict, bool config_tls13);
727724

725+
// update_cipher_list creates a new |SSLCipherPreferenceList| containing ciphers
726+
// from both |ciphers| and |tls13_ciphers| and assigns it to |dst|. The function:
727+
//
728+
// 1. Creates a copy of |ciphers|
729+
// 2. Removes any stale TLS 1.3 ciphersuites from the copy
730+
// 3. Adds any configured TLS 1.3 ciphersuites from |tls13_ciphers| to the
731+
// front of the list.
732+
// 3. Combines |in_group_flags| from both input lists into |dst->in_group_flags|
733+
//
734+
// Returns one on success, zero on error.
735+
int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst,
736+
UniquePtr<SSLCipherPreferenceList> &ciphers,
737+
UniquePtr<SSLCipherPreferenceList> &tls13_ciphers);
738+
728739
// ssl_get_certificate_slot_index returns the |SSL_PKEY_*| certificate slot
729740
// index corresponding to the private key type of |pkey|. It returns -1 if not
730741
// supported. This was |ssl_cert_type| in OpenSSL 1.0.2.
@@ -2374,8 +2385,6 @@ bool ssl_write_client_hello_without_extensions(const SSL_HANDSHAKE *hs,
23742385
ssl_client_hello_type_t type,
23752386
bool empty_session_id);
23762387

2377-
int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst, UniquePtr<SSLCipherPreferenceList> &ciphers, UniquePtr<SSLCipherPreferenceList> &tls13_ciphers);
2378-
23792388
// ssl_add_client_hello constructs a ClientHello and adds it to the outgoing
23802389
// flight. It returns true on success and false on error.
23812390
bool ssl_add_client_hello(SSL_HANDSHAKE *hs);
@@ -3249,10 +3258,12 @@ struct SSL_CONFIG {
32493258

32503259
X509_VERIFY_PARAM *param = nullptr;
32513260

3252-
// All ciphersuites
3261+
// cipher_list holds all available cipher suites for tls 1.3,
3262+
// and 1.2 and below
32533263
UniquePtr<SSLCipherPreferenceList> cipher_list;
32543264

3255-
// TLS 1.3 specific ciphersuites
3265+
// tls13_cipher_list holds the default or configured tls1.3 and above
3266+
// cipher suites.
32563267
UniquePtr<SSLCipherPreferenceList> tls13_cipher_list;
32573268

32583269
// This is used to hold the local certificate used (i.e. the server

ssl/ssl_cipher.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,14 +1234,9 @@ static bool is_known_default_alias_keyword_filter_rule(const char *rule,
12341234
return false;
12351235
}
12361236

1237-
// update_cipher_list updates |ctx->cipher_list| by:
1238-
// 1. Removing any existing TLS 1.3 ciphersuites
1239-
// 2. Adding configured ciphersuites from |ctx->tls13_cipher_list|
1240-
// 3. Configuring a new |ctx->cipher_list->in_group_flags|
1241-
// This function maintains the ordering of ciphersuites and places TLS 1.3
1242-
// ciphersuites at the front of the list.
1243-
// Returns one on success and zero on failure.
1244-
int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst, UniquePtr<SSLCipherPreferenceList> &ciphers, UniquePtr<SSLCipherPreferenceList> &tls13_ciphers) {
1237+
int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst,
1238+
UniquePtr<SSLCipherPreferenceList> &ciphers,
1239+
UniquePtr<SSLCipherPreferenceList> &tls13_ciphers) {
12451240
bssl::UniquePtr<STACK_OF(SSL_CIPHER)> tmp_cipher_list;
12461241
int num_removed_tls13_ciphers = 0, num_added_tls13_ciphers = 0;
12471242
Array<bool> updated_in_group_flags;
@@ -1266,6 +1261,7 @@ int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst, UniquePtr<SSLCip
12661261

12671262
int num_updated_tls12_ciphers = sk_SSL_CIPHER_num(tmp_cipher_list.get());
12681263

1264+
// Add any configure tls 1.3 ciphersuites
12691265
if (tls13_ciphers && tls13_ciphers->ciphers) {
12701266
STACK_OF(SSL_CIPHER) *tls13_cipher_stack = tls13_ciphers->ciphers.get();
12711267
num_added_tls13_ciphers = sk_SSL_CIPHER_num(tls13_cipher_stack);
@@ -1278,10 +1274,12 @@ int update_cipher_list(UniquePtr<SSLCipherPreferenceList> &dst, UniquePtr<SSLCip
12781274
}
12791275

12801276

1281-
if (!updated_in_group_flags.Init(num_added_tls13_ciphers + num_updated_tls12_ciphers)) {
1277+
if (!updated_in_group_flags.Init(num_added_tls13_ciphers +
1278+
num_updated_tls12_ciphers)) {
12821279
return 0;
12831280
}
1284-
std::fill(updated_in_group_flags.begin(), updated_in_group_flags.end(), false);
1281+
std::fill(updated_in_group_flags.begin(), updated_in_group_flags.end(),
1282+
false);
12851283

12861284
// Copy in_group_flags from |ctx->tls13_cipher_list|
12871285
if (tls13_ciphers && tls13_ciphers->in_group_flags) {

0 commit comments

Comments
 (0)