summaryrefslogtreecommitdiff
path: root/test/quicapitest.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-09-08 11:22:36 +0100
committerTomas Mraz <tomas@openssl.org>2023-09-12 15:29:00 +0200
commit9912dfb98c9c2b10c83c5ca4b5136232568ad664 (patch)
treead0570a4e175fd6dd82c04322d2c126a84a89d86 /test/quicapitest.c
parent547ea58821644bdc9089b2dcb163286d789f732a (diff)
Add a test for SSL_CIPHER_find() when used with a QUIC SSL object
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22011)
Diffstat (limited to 'test/quicapitest.c')
-rw-r--r--test/quicapitest.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/quicapitest.c b/test/quicapitest.c
index a24946a649..8c78e14de9 100644
--- a/test/quicapitest.c
+++ b/test/quicapitest.c
@@ -321,6 +321,49 @@ static int test_ciphersuites(void)
return testresult;
}
+static int test_cipher_find(void)
+{
+ SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
+ SSL *clientquic = NULL;
+ struct {
+ const unsigned char *cipherbytes;
+ int ok;
+ } testciphers[] = {
+ { TLS13_AES_128_GCM_SHA256_BYTES, 1 },
+ { TLS13_AES_256_GCM_SHA384_BYTES, 1 },
+ { TLS13_CHACHA20_POLY1305_SHA256_BYTES, 1 },
+ { TLS13_AES_128_CCM_SHA256_BYTES, 0 },
+ { TLS13_AES_128_CCM_8_SHA256_BYTES, 0 }
+ };
+ size_t i;
+ int testresult = 0;
+
+ if (!TEST_ptr(cctx))
+ goto err;
+
+ clientquic = SSL_new(cctx);
+ if (!TEST_ptr(clientquic))
+ goto err;
+
+ for (i = 0; i < OSSL_NELEM(testciphers); i++)
+ if (testciphers[i].ok) {
+ if (!TEST_ptr(SSL_CIPHER_find(clientquic,
+ testciphers[i].cipherbytes)))
+ goto err;
+ } else {
+ if (!TEST_ptr_null(SSL_CIPHER_find(clientquic,
+ testciphers[i].cipherbytes)))
+ goto err;
+ }
+
+ testresult = 1;
+ err:
+ SSL_free(clientquic);
+ SSL_CTX_free(cctx);
+
+ return testresult;
+}
+
/*
* Test that SSL_version, SSL_get_version, SSL_is_quic, SSL_is_tls and
* SSL_is_dtls return the expected results for a QUIC connection. Compare with
@@ -1205,6 +1248,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_quic_write_read, 3);
ADD_TEST(test_fin_only_blocking);
ADD_TEST(test_ciphersuites);
+ ADD_TEST(test_cipher_find);
ADD_TEST(test_version);
#if defined(DO_SSL_TRACE_TEST)
ADD_TEST(test_ssl_trace);