diff options
author | Alexander Sosedkin <asosedkin@redhat.com> | 2021-10-20 14:34:58 +0200 |
---|---|---|
committer | Alexander Sosedkin <asosedkin@redhat.com> | 2021-10-21 10:47:08 +0200 |
commit | 3ee3508a123a87dbaafd65882dd98381bc2cc0f1 (patch) | |
tree | 5b87de11d2b4c7168186ac6d04e6431a11217029 | |
parent | fea473a90351004fe2b84b4d722994bbc899d4ab (diff) | |
download | gnutls-3ee3508a123a87dbaafd65882dd98381bc2cc0f1.tar.gz |
priority: refactor ciphersuite filtering
Signed-off-by: Alexander Sosedkin <asosedkin@redhat.com>
-rw-r--r-- | lib/priority.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/priority.c b/lib/priority.c index f043e9dd6f..0530bcb9e5 100644 --- a/lib/priority.c +++ b/lib/priority.c @@ -1682,10 +1682,11 @@ static int set_ciphersuite_list(gnutls_priority_t priority_cache) ce = cipher_suite_get( 0, priority_cache->_cipher.priorities[j], priority_cache->_mac.priorities[z]); + if (ce == NULL) + continue; - if (ce != NULL && priority_cache->cs.size < MAX_CIPHERSUITE_SIZE) { + if (priority_cache->cs.size < MAX_CIPHERSUITE_SIZE) priority_cache->cs.entry[priority_cache->cs.size++] = ce; - } } } @@ -1696,18 +1697,20 @@ static int set_ciphersuite_list(gnutls_priority_t priority_cache) priority_cache->_kx.priorities[i], priority_cache->_cipher.priorities[j], priority_cache->_mac.priorities[z]); + if (ce == NULL) + continue; - if (ce != NULL && priority_cache->cs.size < MAX_CIPHERSUITE_SIZE) { - priority_cache->cs.entry[priority_cache->cs.size++] = ce; - if (!have_ec && (_gnutls_kx_is_ecc(ce->kx_algorithm) || - _gnutls_kx_is_vko_gost(ce->kx_algorithm))) { - have_ec = 1; - add_ec(priority_cache); - } - if (!have_dh && _gnutls_kx_is_dhe(ce->kx_algorithm)) { - have_dh = 1; - add_dh(priority_cache); - } + if (priority_cache->cs.size == MAX_CIPHERSUITE_SIZE) + continue; + priority_cache->cs.entry[priority_cache->cs.size++] = ce; + if (!have_ec && (_gnutls_kx_is_ecc(ce->kx_algorithm) || + _gnutls_kx_is_vko_gost(ce->kx_algorithm))) { + have_ec = 1; + add_ec(priority_cache); + } + if (!have_dh && _gnutls_kx_is_dhe(ce->kx_algorithm)) { + have_dh = 1; + add_dh(priority_cache); } } } |