Skip to content

SSL_get_cipher_list: enumerate the configured cipher list - #11003

Draft
julek-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
julek-wolfssl:ssl-get-cipher-list-compat
Draft

SSL_get_cipher_list: enumerate the configured cipher list#11003
julek-wolfssl wants to merge 1 commit into
wolfSSL:masterfrom
julek-wolfssl:ssl-get-cipher-list-compat

Conversation

@julek-wolfssl

Copy link
Copy Markdown
Member

SSL_get_cipher_list() was mapped to wolfSSL_get_cipher_list_ex(), which
only returned the negotiated cipher at index 0 and NULL for every other
index, so callers walking the list saw a single entry instead of the full
configured list as OpenSSL does.

wolfSSL_get_cipher_list_ex() had a fallback meant to enumerate the list,
but it was unreachable (it only triggers when the internal cipher name
lookup returns NULL, which hasn't happened since the lookup started
returning the literal "None" instead). Even if reached, it indexed the
global cipher_names[] table rather than the suites actually configured on
the SSL, so it wouldn't have matched OpenSSL's behavior anyway.

Add wolfSSL_get_cipher_list_compat() and point the SSL_get_cipher_list
macro at it instead. It walks WOLFSSL_SUITES(ssl) with the same SCSV and
min/max version filtering used by wolfSSL_get_ciphers_compat(), so
SSL_get_cipher_list() and SSL_get_ciphers() now report the same suites
in the same order, named the way SSL_CIPHER_get_name() does.
wolfSSL_get_cipher_list_ex() itself is left unchanged for direct callers.

SSL_get_cipher_list() mapped to wolfSSL_get_cipher_list_ex(), which returns
the negotiated cipher at index 0 and NULL at every other index. OpenSSL
returns the name of the n-th cipher in the SSL's configured list, so callers
walking the list only ever saw one entry.

wolfSSL_get_cipher_list_ex() has a fallback that enumerates, but it is
unreachable. It triggers when wolfSSL_get_cipher_name_internal() returns
NULL, and GetCipherNameInternal() has returned the literal "None" instead of
NULL since ee13dfd. Before a handshake that made SSL_get_cipher_list(ssl, 0)
report "None". The fallback also indexed the global cipher_names[] table
rather than the suites configured on the SSL, so it did not match OpenSSL
either.

Add wolfSSL_get_cipher_list_compat() and point the macro at it. It walks
WOLFSSL_SUITES(ssl) with the same SCSV and min/max version filtering
wolfSSL_get_ciphers_compat() uses, so SSL_get_cipher_list() and
SSL_get_ciphers() report the same suites in the same order, and it names them
the way SSL_CIPHER_get_name() does. wolfSSL_get_cipher_list_ex() is left
unchanged for direct callers.
Copilot AI review requested due to automatic review settings July 29, 2026 15:00
@julek-wolfssl julek-wolfssl self-assigned this Jul 29, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the OpenSSL-compat behavior of SSL_get_cipher_list() so it enumerates the configured cipher list (not just the negotiated cipher at index 0), aligning its output and ordering with SSL_get_ciphers()/SSL_CIPHER_get_name().

Changes:

  • Added wolfSSL_get_cipher_list_compat() that iterates WOLFSSL_SUITES(ssl) with the same filtering used by wolfSSL_get_ciphers_compat().
  • Remapped the SSL_get_cipher_list macro to use the new compat function.
  • Added an API test verifying SSL_get_cipher_list() matches the entries returned by SSL_get_ciphers().

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
wolfssl/ssl.h Declares the new wolfSSL_get_cipher_list_compat() API under OpenSSL-compat feature guards.
wolfssl/openssl/ssl.h Updates SSL_get_cipher_list macro mapping to the new compat enumerator.
src/ssl.c Implements wolfSSL_get_cipher_list_compat() to enumerate configured suites with filtering and OpenSSL-compatible naming.
tests/api.c Adds a test ensuring SSL_get_cipher_list() walks the configured list and matches SSL_get_ciphers() entry-for-entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wolfssl/openssl/ssl.h
Comment on lines 248 to 252
#define SSL_get_client_random(ssl,out,outSz) \
wolfSSL_get_client_random((ssl),(out),(outSz))
#define SSL_get_cipher_list(ctx,i) wolfSSL_get_cipher_list_ex((ctx),(i))
#define SSL_get_cipher_list(ssl,i) \
wolfSSL_get_cipher_list_compat((ssl),(i))
#define SSL_get_cipher_name(ctx) wolfSSL_get_cipher((ctx))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants