summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2024-01-29 15:11:46 +1100
committerDamien George <damien@micropython.org>2024-02-16 10:48:30 +1100
commit2531a15200cab1bd1c3d9bfbb4f5ce95fc561f3f (patch)
tree8ad1cd9ec3057d6c3cf7ae45f0825b444473ff1d
parent8b6e89a8ca87a4ae045f9f1a6a0fdff08984bde0 (diff)
downloadmicropython-2531a15200cab1bd1c3d9bfbb4f5ce95fc561f3f.tar.gz
micropython-2531a15200cab1bd1c3d9bfbb4f5ce95fc561f3f.zip
extmod/modssl_mbedtls: Fix cipher iteration in SSLContext.get_ciphers.
Prior to this commit it would skip every second cipher returned from mbedtls. The corresponding test is also updated and now passes on esp32, rp2, stm32 and unix. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--extmod/modssl_mbedtls.c4
-rw-r--r--tests/extmod/ssl_sslcontext_ciphers.py4
-rw-r--r--tests/extmod/ssl_sslcontext_ciphers.py.exp4
3 files changed, 7 insertions, 5 deletions
diff --git a/extmod/modssl_mbedtls.c b/extmod/modssl_mbedtls.c
index 0190c96a9a..b6275d8d88 100644
--- a/extmod/modssl_mbedtls.c
+++ b/extmod/modssl_mbedtls.c
@@ -311,10 +311,6 @@ STATIC mp_obj_t ssl_context_get_ciphers(mp_obj_t self_in) {
for (const int *cipher_list = mbedtls_ssl_list_ciphersuites(); *cipher_list; ++cipher_list) {
const char *cipher_name = mbedtls_ssl_get_ciphersuite_name(*cipher_list);
mp_obj_list_append(list, MP_OBJ_FROM_PTR(mp_obj_new_str(cipher_name, strlen(cipher_name))));
- cipher_list++;
- if (!*cipher_list) {
- break;
- }
}
return list;
}
diff --git a/tests/extmod/ssl_sslcontext_ciphers.py b/tests/extmod/ssl_sslcontext_ciphers.py
index d87e96afdf..20c00b9176 100644
--- a/tests/extmod/ssl_sslcontext_ciphers.py
+++ b/tests/extmod/ssl_sslcontext_ciphers.py
@@ -12,7 +12,9 @@ ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ciphers = ctx.get_ciphers()
for ci in ciphers:
- print(ci)
+ # Only print those ciphers know to exist on all ports.
+ if ("TLS-ECDHE-ECDSA-WITH-AES" in ci or "TLS-RSA-WITH-AES" in ci) and "CBC" in ci:
+ print(ci)
ctx.set_ciphers(ciphers[:1])
diff --git a/tests/extmod/ssl_sslcontext_ciphers.py.exp b/tests/extmod/ssl_sslcontext_ciphers.py.exp
index 4d243a7883..0d21a3bd25 100644
--- a/tests/extmod/ssl_sslcontext_ciphers.py.exp
+++ b/tests/extmod/ssl_sslcontext_ciphers.py.exp
@@ -1,6 +1,10 @@
TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA384
+TLS-ECDHE-ECDSA-WITH-AES-256-CBC-SHA
TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA256
+TLS-ECDHE-ECDSA-WITH-AES-128-CBC-SHA
TLS-RSA-WITH-AES-256-CBC-SHA256
+TLS-RSA-WITH-AES-256-CBC-SHA
TLS-RSA-WITH-AES-128-CBC-SHA256
+TLS-RSA-WITH-AES-128-CBC-SHA
object 'str' isn't a tuple or list
(-24192, 'MBEDTLS_ERR_SSL_BAD_CONFIG')