@@ -19272,6 +19272,39 @@ static int test_wolfSSL_get_ciphers_compat(void)
1927219272 return EXPECT_RESULT();
1927319273}
1927419274
19275+ /* Test that wolfSSL_get_ciphers_compat returns NULL (not an empty stack)
19276+ * when no ciphers are available for a given protocol configuration.
19277+ * wolfSSL_get_ciphers_compat() is mapped to SSL_get_ciphers(), which has
19278+ * an expected return of NULL when no ciphers are available. */
19279+ static int test_wolfSSL_get_ciphers_compat_empty(void)
19280+ {
19281+ EXPECT_DECLS;
19282+ #if !defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT)
19283+ const SSL_METHOD *method = NULL;
19284+ SSL_CTX *ctx = NULL;
19285+ WOLFSSL *ssl = NULL;
19286+ STACK_OF(SSL_CIPHER) *ciphers = NULL;
19287+
19288+ ExpectNotNull(method = SSLv23_client_method());
19289+ ExpectNotNull(ctx = SSL_CTX_new(method));
19290+ ExpectNotNull(ssl = SSL_new(ctx));
19291+
19292+ /* Disable all protocol versions via options mask so that
19293+ * sslCipherMinMaxCheck filters out every cipher suite */
19294+ wolfSSL_set_options(ssl, SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 |
19295+ SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3);
19296+
19297+ ciphers = wolfSSL_get_ciphers_compat(ssl);
19298+
19299+ /* Must be NULL, not a non-NULL empty stack */
19300+ ExpectNull(ciphers);
19301+
19302+ SSL_free(ssl);
19303+ SSL_CTX_free(ctx);
19304+ #endif
19305+ return EXPECT_RESULT();
19306+ }
19307+
1927519308static int test_wolfSSL_CTX_ctrl(void)
1927619309{
1927719310 EXPECT_DECLS;
@@ -34136,6 +34169,7 @@ TEST_CASE testCases[] = {
3413634169#ifdef OPENSSL_ALL
3413734170 TEST_DECL(test_wolfSSL_sk_CIPHER_description),
3413834171 TEST_DECL(test_wolfSSL_get_ciphers_compat),
34172+ TEST_DECL(test_wolfSSL_get_ciphers_compat_empty),
3413934173
3414034174 TEST_DECL(test_wolfSSL_CTX_ctrl),
3414134175#endif /* OPENSSL_ALL */
0 commit comments