2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
12 #include <openssl/opensslconf.h>
13 #include <openssl/bio.h>
14 #include <openssl/crypto.h>
15 #include <openssl/ssl.h>
16 #include <openssl/ocsp.h>
18 #include "ssltestlib.h"
20 #include "test_main_custom.h"
23 static char *cert = NULL;
24 static char *privkey = NULL;
26 static const unsigned char orespder[] = "Dummy OCSP Response";
27 static int ocsp_server_called = 0;
28 static int ocsp_client_called = 0;
30 static int cdummyarg = 1;
31 static X509 *ocspcert = NULL;
33 #define NUM_EXTRA_CERTS 40
35 static int execute_test_large_message(const SSL_METHOD *smeth,
36 const SSL_METHOD *cmeth, int read_ahead)
38 SSL_CTX *cctx = NULL, *sctx = NULL;
39 SSL *clientssl = NULL, *serverssl = NULL;
42 BIO *certbio = BIO_new_file(cert, "r");
43 X509 *chaincert = NULL;
46 if (certbio == NULL) {
47 printf("Can't load the certficate file\n");
50 chaincert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
53 if (chaincert == NULL) {
54 printf("Unable to load certificate for chain\n");
58 if (!create_ssl_ctx_pair(smeth, cmeth, &sctx,
59 &cctx, cert, privkey)) {
60 printf("Unable to create SSL_CTX pair\n");
66 * Test that read_ahead works correctly when dealing with large
69 SSL_CTX_set_read_ahead(cctx, 1);
73 * We assume the supplied certificate is big enough so that if we add
74 * NUM_EXTRA_CERTS it will make the overall message large enough. The
75 * default buffer size is requested to be 16k, but due to the way BUF_MEM
76 * works, it ends up allocing a little over 21k (16 * 4/3). So, in this test
77 * we need to have a message larger than that.
79 certlen = i2d_X509(chaincert, NULL);
80 OPENSSL_assert((certlen * NUM_EXTRA_CERTS)
81 > ((SSL3_RT_MAX_PLAIN_LENGTH * 4) / 3));
82 for (i = 0; i < NUM_EXTRA_CERTS; i++) {
83 if (!X509_up_ref(chaincert)) {
84 printf("Unable to up ref cert\n");
87 if (!SSL_CTX_add_extra_chain_cert(sctx, chaincert)) {
88 printf("Unable to add extra chain cert %d\n", i);
94 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
95 printf("Unable to create SSL objects\n");
99 if (!create_ssl_connection(serverssl, clientssl)) {
100 printf("Unable to create SSL connection\n");
105 * Calling SSL_clear() first is not required but this tests that SSL_clear()
106 * doesn't leak (when using enable-crypto-mdebug).
108 if (!SSL_clear(serverssl)) {
109 printf("Unexpected failure from SSL_clear()\n");
115 X509_free(chaincert);
124 static int test_large_message_tls(void)
126 return execute_test_large_message(TLS_server_method(), TLS_client_method(),
130 static int test_large_message_tls_read_ahead(void)
132 return execute_test_large_message(TLS_server_method(), TLS_client_method(),
136 #ifndef OPENSSL_NO_DTLS
137 static int test_large_message_dtls(void)
140 * read_ahead is not relevant to DTLS because DTLS always acts as if
143 return execute_test_large_message(DTLS_server_method(),
144 DTLS_client_method(), 0);
148 static int ocsp_server_cb(SSL *s, void *arg)
150 int *argi = (int *)arg;
151 unsigned char *orespdercopy = NULL;
152 STACK_OF(OCSP_RESPID) *ids = NULL;
153 OCSP_RESPID *id = NULL;
156 /* In this test we are expecting exactly 1 OCSP_RESPID */
157 SSL_get_tlsext_status_ids(s, &ids);
158 if (ids == NULL || sk_OCSP_RESPID_num(ids) != 1)
159 return SSL_TLSEXT_ERR_ALERT_FATAL;
161 id = sk_OCSP_RESPID_value(ids, 0);
162 if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
163 return SSL_TLSEXT_ERR_ALERT_FATAL;
164 } else if (*argi != 1) {
165 return SSL_TLSEXT_ERR_ALERT_FATAL;
169 orespdercopy = OPENSSL_memdup(orespder, sizeof(orespder));
170 if (orespdercopy == NULL)
171 return SSL_TLSEXT_ERR_ALERT_FATAL;
173 SSL_set_tlsext_status_ocsp_resp(s, orespdercopy, sizeof(orespder));
175 ocsp_server_called = 1;
177 return SSL_TLSEXT_ERR_OK;
180 static int ocsp_client_cb(SSL *s, void *arg)
182 int *argi = (int *)arg;
183 const unsigned char *respderin;
186 if (*argi != 1 && *argi != 2)
189 len = SSL_get_tlsext_status_ocsp_resp(s, &respderin);
191 if (memcmp(orespder, respderin, len) != 0)
194 ocsp_client_called = 1;
199 static int test_tlsext_status_type(void)
201 SSL_CTX *cctx = NULL, *sctx = NULL;
202 SSL *clientssl = NULL, *serverssl = NULL;
204 STACK_OF(OCSP_RESPID) *ids = NULL;
205 OCSP_RESPID *id = NULL;
208 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
209 &cctx, cert, privkey)) {
210 printf("Unable to create SSL_CTX pair\n");
214 if (SSL_CTX_get_tlsext_status_type(cctx) != -1) {
215 printf("Unexpected initial value for "
216 "SSL_CTX_get_tlsext_status_type()\n");
220 /* First just do various checks getting and setting tlsext_status_type */
222 clientssl = SSL_new(cctx);
223 if (SSL_get_tlsext_status_type(clientssl) != -1) {
224 printf("Unexpected initial value for SSL_get_tlsext_status_type()\n");
228 if (!SSL_set_tlsext_status_type(clientssl, TLSEXT_STATUSTYPE_ocsp)) {
229 printf("Unexpected fail for SSL_set_tlsext_status_type()\n");
233 if (SSL_get_tlsext_status_type(clientssl) != TLSEXT_STATUSTYPE_ocsp) {
234 printf("Unexpected result for SSL_get_tlsext_status_type()\n");
241 if (!SSL_CTX_set_tlsext_status_type(cctx, TLSEXT_STATUSTYPE_ocsp)) {
242 printf("Unexpected fail for SSL_CTX_set_tlsext_status_type()\n");
246 if (SSL_CTX_get_tlsext_status_type(cctx) != TLSEXT_STATUSTYPE_ocsp) {
247 printf("Unexpected result for SSL_CTX_get_tlsext_status_type()\n");
251 clientssl = SSL_new(cctx);
253 if (SSL_get_tlsext_status_type(clientssl) != TLSEXT_STATUSTYPE_ocsp) {
254 printf("Unexpected result for SSL_get_tlsext_status_type() (test 2)\n");
262 * Now actually do a handshake and check OCSP information is exchanged and
263 * the callbacks get called
266 SSL_CTX_set_tlsext_status_cb(cctx, ocsp_client_cb);
267 SSL_CTX_set_tlsext_status_arg(cctx, &cdummyarg);
268 SSL_CTX_set_tlsext_status_cb(sctx, ocsp_server_cb);
269 SSL_CTX_set_tlsext_status_arg(sctx, &cdummyarg);
271 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
272 printf("Unable to create SSL objects\n");
276 if (!create_ssl_connection(serverssl, clientssl)) {
277 printf("Unable to create SSL connection\n");
281 if (!ocsp_client_called || !ocsp_server_called) {
282 printf("OCSP callbacks not called\n");
291 /* Try again but this time force the server side callback to fail */
292 ocsp_client_called = 0;
293 ocsp_server_called = 0;
296 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
297 printf("Unable to create SSL objects\n");
301 /* This should fail because the callback will fail */
302 if (create_ssl_connection(serverssl, clientssl)) {
303 printf("Unexpected success creating the connection\n");
307 if (ocsp_client_called || ocsp_server_called) {
308 printf("OCSP callbacks successfully called unexpectedly\n");
318 * This time we'll get the client to send an OCSP_RESPID that it will
321 ocsp_client_called = 0;
322 ocsp_server_called = 0;
325 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
326 printf("Unable to create SSL objects\n");
331 * We'll just use any old cert for this test - it doesn't have to be an OCSP
332 * specifc one. We'll use the server cert.
334 certbio = BIO_new_file(cert, "r");
335 if (certbio == NULL) {
336 printf("Can't load the certficate file\n");
339 id = OCSP_RESPID_new();
340 ids = sk_OCSP_RESPID_new_null();
341 ocspcert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
342 if (id == NULL || ids == NULL || ocspcert == NULL
343 || !OCSP_RESPID_set_by_key(id, ocspcert)
344 || !sk_OCSP_RESPID_push(ids, id)) {
345 printf("Unable to set OCSP_RESPIDs\n");
349 SSL_set_tlsext_status_ids(clientssl, ids);
350 /* Control has been transferred */
356 if (!create_ssl_connection(serverssl, clientssl)) {
357 printf("Unable to create SSL connection\n");
361 if (!ocsp_client_called || !ocsp_server_called) {
362 printf("OCSP callbacks not called\n");
373 sk_OCSP_RESPID_pop_free(ids, OCSP_RESPID_free);
374 OCSP_RESPID_free(id);
382 typedef struct ssl_session_test_fixture {
383 const char *test_case_name;
386 } SSL_SESSION_TEST_FIXTURE;
388 static int new_called = 0, remove_called = 0;
390 static SSL_SESSION_TEST_FIXTURE
391 ssl_session_set_up(const char *const test_case_name)
393 SSL_SESSION_TEST_FIXTURE fixture;
395 fixture.test_case_name = test_case_name;
396 fixture.use_ext_cache = 1;
397 fixture.use_int_cache = 1;
399 new_called = remove_called = 0;
404 static void ssl_session_tear_down(SSL_SESSION_TEST_FIXTURE fixture)
408 static int new_session_cb(SSL *ssl, SSL_SESSION *sess)
415 static void remove_session_cb(SSL_CTX *ctx, SSL_SESSION *sess)
420 static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)
422 SSL_CTX *sctx = NULL, *cctx = NULL;
423 SSL *serverssl1 = NULL, *clientssl1 = NULL;
424 SSL *serverssl2 = NULL, *clientssl2 = NULL;
425 #ifndef OPENSSL_NO_TLS1_1
426 SSL *serverssl3 = NULL, *clientssl3 = NULL;
428 SSL_SESSION *sess1 = NULL, *sess2 = NULL;
431 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
432 &cctx, cert, privkey)) {
433 printf("Unable to create SSL_CTX pair\n");
437 #ifndef OPENSSL_NO_TLS1_2
438 /* Only allow TLS1.2 so we can force a connection failure later */
439 SSL_CTX_set_min_proto_version(cctx, TLS1_2_VERSION);
443 * TODO(TLS1.3): Test temporarily disabled for TLS1.3 until we've
444 * implemented session resumption.
446 SSL_CTX_set_max_proto_version(cctx, TLS1_2_VERSION);
448 /* Set up session cache */
449 if (fix.use_ext_cache) {
450 SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
451 SSL_CTX_sess_set_remove_cb(cctx, remove_session_cb);
453 if (fix.use_int_cache) {
454 /* Also covers instance where both are set */
455 SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT);
457 SSL_CTX_set_session_cache_mode(cctx,
458 SSL_SESS_CACHE_CLIENT
459 | SSL_SESS_CACHE_NO_INTERNAL_STORE);
462 if (!create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1, NULL,
464 printf("Unable to create SSL objects\n");
468 if (!create_ssl_connection(serverssl1, clientssl1)) {
469 printf("Unable to create SSL connection\n");
472 sess1 = SSL_get1_session(clientssl1);
474 printf("Unexpected NULL session\n");
478 if (fix.use_int_cache && SSL_CTX_add_session(cctx, sess1)) {
479 /* Should have failed because it should already be in the cache */
480 printf("Unexpected success adding session to cache\n");
484 if (fix.use_ext_cache && (new_called != 1 || remove_called != 0)) {
485 printf("Session not added to cache\n");
489 if (!create_ssl_objects(sctx, cctx, &serverssl2, &clientssl2, NULL, NULL)) {
490 printf("Unable to create second SSL objects\n");
494 if (!create_ssl_connection(serverssl2, clientssl2)) {
495 printf("Unable to create second SSL connection\n");
499 sess2 = SSL_get1_session(clientssl2);
501 printf("Unexpected NULL session from clientssl2\n");
505 if (fix.use_ext_cache && (new_called != 2 || remove_called != 0)) {
506 printf("Remove session callback unexpectedly called\n");
511 * This should clear sess2 from the cache because it is a "bad" session. See
512 * SSL_set_session() documentation.
514 if (!SSL_set_session(clientssl2, sess1)) {
515 printf("Unexpected failure setting session\n");
519 if (fix.use_ext_cache && (new_called != 2 || remove_called != 1)) {
520 printf("Failed to call callback to remove session\n");
525 if (SSL_get_session(clientssl2) != sess1) {
526 printf("Unexpected session found\n");
530 if (fix.use_int_cache) {
531 if (!SSL_CTX_add_session(cctx, sess2)) {
533 * Should have succeeded because it should not already be in the cache
535 printf("Unexpected failure adding session to cache\n");
539 if (!SSL_CTX_remove_session(cctx, sess2)) {
540 printf("Unexpected failure removing session from cache\n");
544 /* This is for the purposes of internal cache testing...ignore the
545 * counter for external cache
547 if (fix.use_ext_cache)
551 /* This shouldn't be in the cache so should fail */
552 if (SSL_CTX_remove_session(cctx, sess2)) {
553 printf("Unexpected success removing session from cache\n");
557 if (fix.use_ext_cache && (new_called != 2 || remove_called != 2)) {
558 printf("Failed to call callback to remove session #2\n");
562 #if !defined(OPENSSL_NO_TLS1_1) && !defined(OPENSSL_NO_TLS1_2)
563 /* Force a connection failure */
564 SSL_CTX_set_max_proto_version(sctx, TLS1_1_VERSION);
566 if (!create_ssl_objects(sctx, cctx, &serverssl3, &clientssl3, NULL, NULL)) {
567 printf("Unable to create third SSL objects\n");
571 if (!SSL_set_session(clientssl3, sess1)) {
572 printf("Unable to set session for third connection\n");
576 /* This should fail because of the mismatched protocol versions */
577 if (create_ssl_connection(serverssl3, clientssl3)) {
578 printf("Unable to create third SSL connection\n");
583 /* We should have automatically removed the session from the cache */
584 if (fix.use_ext_cache && (new_called != 2 || remove_called != 3)) {
585 printf("Failed to call callback to remove session #2\n");
589 if (fix.use_int_cache && !SSL_CTX_add_session(cctx, sess2)) {
591 * Should have succeeded because it should not already be in the cache
593 printf("Unexpected failure adding session to cache #2\n");
601 SSL_free(serverssl1);
602 SSL_free(clientssl1);
603 SSL_free(serverssl2);
604 SSL_free(clientssl2);
605 #ifndef OPENSSL_NO_TLS1_1
606 SSL_free(serverssl3);
607 SSL_free(clientssl3);
609 SSL_SESSION_free(sess1);
610 SSL_SESSION_free(sess2);
612 * Check if we need to remove any sessions up-refed for the external cache
615 SSL_SESSION_free(sess1);
617 SSL_SESSION_free(sess2);
624 static int test_session_with_only_int_cache(void)
626 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
628 fixture.use_ext_cache = 0;
630 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
633 static int test_session_with_only_ext_cache(void)
635 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
637 fixture.use_int_cache = 0;
639 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
642 static int test_session_with_both_cache(void)
644 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
646 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
653 #define TOTAL_SSL_SET_BIO_TESTS (3 * 3 * 3 * 3)
655 static void setupbio(BIO **res, BIO *bio1, BIO *bio2, int type)
670 static int test_ssl_set_bio(int idx)
672 SSL_CTX *ctx = SSL_CTX_new(TLS_method());
675 BIO *irbio = NULL, *iwbio = NULL, *nrbio = NULL, *nwbio = NULL;
677 int initrbio, initwbio, newrbio, newwbio;
681 printf("Failed to allocate SSL_CTX\n");
687 printf("Failed to allocate SSL object\n");
698 OPENSSL_assert(newwbio <= 2);
700 if (initrbio == USE_BIO_1 || initwbio == USE_BIO_1 || newrbio == USE_BIO_1
701 || newwbio == USE_BIO_1) {
702 bio1 = BIO_new(BIO_s_mem());
704 printf("Failed to allocate bio1\n");
709 if (initrbio == USE_BIO_2 || initwbio == USE_BIO_2 || newrbio == USE_BIO_2
710 || newwbio == USE_BIO_2) {
711 bio2 = BIO_new(BIO_s_mem());
713 printf("Failed to allocate bio2\n");
718 setupbio(&irbio, bio1, bio2, initrbio);
719 setupbio(&iwbio, bio1, bio2, initwbio);
722 * We want to maintain our own refs to these BIO, so do an up ref for each
723 * BIO that will have ownersip transferred in the SSL_set_bio() call
727 if (iwbio != NULL && iwbio != irbio)
730 SSL_set_bio(ssl, irbio, iwbio);
732 setupbio(&nrbio, bio1, bio2, newrbio);
733 setupbio(&nwbio, bio1, bio2, newwbio);
736 * We will (maybe) transfer ownership again so do more up refs.
737 * SSL_set_bio() has some really complicated ownership rules where BIOs have
740 if (nrbio != NULL && nrbio != irbio && (nwbio != iwbio || nrbio != nwbio))
742 if (nwbio != NULL && nwbio != nrbio && (nwbio != iwbio || (nwbio == iwbio && irbio == iwbio)))
745 SSL_set_bio(ssl, nrbio, nwbio);
754 * This test is checking that the ref counting for SSL_set_bio is correct.
755 * If we get here and we did too many frees then we will fail in the above
756 * functions. If we haven't done enough then this will only be detected in
757 * a crypto-mdebug build
764 typedef struct ssl_bio_test_fixture {
765 const char *test_case_name;
767 enum { NO_BIO_CHANGE, CHANGE_RBIO, CHANGE_WBIO } change_bio;
768 } SSL_BIO_TEST_FIXTURE;
770 static SSL_BIO_TEST_FIXTURE ssl_bio_set_up(const char *const test_case_name)
772 SSL_BIO_TEST_FIXTURE fixture;
774 fixture.test_case_name = test_case_name;
776 fixture.change_bio = NO_BIO_CHANGE;
781 static void ssl_bio_tear_down(SSL_BIO_TEST_FIXTURE fixture)
785 static int execute_test_ssl_bio(SSL_BIO_TEST_FIXTURE fix)
787 BIO *sslbio = NULL, *membio1 = NULL, *membio2 = NULL;
788 SSL_CTX *ctx = SSL_CTX_new(TLS_method());
793 printf("Failed to allocate SSL_CTX\n");
799 printf("Failed to allocate SSL object\n");
803 sslbio = BIO_new(BIO_f_ssl());
804 membio1 = BIO_new(BIO_s_mem());
806 if (sslbio == NULL || membio1 == NULL) {
807 printf("Malloc failure creating BIOs\n");
811 BIO_set_ssl(sslbio, ssl, BIO_CLOSE);
814 * If anything goes wrong here then we could leak memory, so this will
815 * be caught in a crypto-mdebug build
817 BIO_push(sslbio, membio1);
819 /* Verify chaning the rbio/wbio directly does not cause leaks */
820 if (fix.change_bio != NO_BIO_CHANGE) {
821 membio2 = BIO_new(BIO_s_mem());
822 if (membio2 == NULL) {
823 printf("Malloc failure creating membio2\n");
826 if (fix.change_bio == CHANGE_RBIO)
827 SSL_set0_rbio(ssl, membio2);
829 SSL_set0_wbio(ssl, membio2);
848 static int test_ssl_bio_pop_next_bio(void)
850 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
852 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
855 static int test_ssl_bio_pop_ssl_bio(void)
857 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
861 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
864 static int test_ssl_bio_change_rbio(void)
866 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
868 fixture.change_bio = CHANGE_RBIO;
870 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
873 static int test_ssl_bio_change_wbio(void)
875 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
877 fixture.change_bio = CHANGE_WBIO;
879 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
883 /* The list of sig algs */
885 /* The length of the list */
887 /* A sigalgs list in string format */
889 /* Whether setting the list should succeed */
891 /* Whether creating a connection with the list should succeed */
895 static const int validlist1[] = {NID_sha256, EVP_PKEY_RSA};
896 static const int validlist2[] = {NID_sha256, EVP_PKEY_RSA, NID_sha512, EVP_PKEY_EC};
897 static const int validlist3[] = {NID_sha512, EVP_PKEY_EC};
898 static const int invalidlist1[] = {NID_undef, EVP_PKEY_RSA};
899 static const int invalidlist2[] = {NID_sha256, NID_undef};
900 static const int invalidlist3[] = {NID_sha256, EVP_PKEY_RSA, NID_sha256};
901 static const int invalidlist4[] = {NID_sha256};
902 static const sigalgs_list testsigalgs[] = {
903 {validlist1, OSSL_NELEM(validlist1), NULL, 1, 1},
904 {validlist2, OSSL_NELEM(validlist2), NULL, 1, 1},
905 {validlist3, OSSL_NELEM(validlist3), NULL, 1, 0},
906 {NULL, 0, "RSA+SHA256", 1, 1},
907 {NULL, 0, "RSA+SHA256:ECDSA+SHA512", 1, 1},
908 {NULL, 0, "ECDSA+SHA512", 1, 0},
909 {invalidlist1, OSSL_NELEM(invalidlist1), NULL, 0, 0},
910 {invalidlist2, OSSL_NELEM(invalidlist2), NULL, 0, 0},
911 {invalidlist3, OSSL_NELEM(invalidlist3), NULL, 0, 0},
912 {invalidlist4, OSSL_NELEM(invalidlist4), NULL, 0, 0},
913 {NULL, 0, "RSA", 0, 0},
914 {NULL, 0, "SHA256", 0, 0},
915 {NULL, 0, "RSA+SHA256:SHA256", 0, 0},
916 {NULL, 0, "Invalid", 0, 0}};
918 static int test_set_sigalgs(int idx)
920 SSL_CTX *cctx = NULL, *sctx = NULL;
921 SSL *clientssl = NULL, *serverssl = NULL;
923 const sigalgs_list *curr;
926 /* Should never happen */
927 if ((size_t)idx >= OSSL_NELEM(testsigalgs) * 2)
930 testctx = ((size_t)idx < OSSL_NELEM(testsigalgs));
931 curr = testctx ? &testsigalgs[idx]
932 : &testsigalgs[idx - OSSL_NELEM(testsigalgs)];
934 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
935 &cctx, cert, privkey)) {
936 printf("Unable to create SSL_CTX pair\n");
942 if (curr->list != NULL)
943 ret = SSL_CTX_set1_sigalgs(cctx, curr->list, curr->listlen);
945 ret = SSL_CTX_set1_sigalgs_list(cctx, curr->liststr);
949 printf("Unexpected failure setting sigalgs in SSL_CTX (%d)\n",
956 printf("Unexpected success setting sigalgs in SSL_CTX (%d)\n", idx);
961 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
962 printf("Unable to create SSL objects\n");
969 if (curr->list != NULL)
970 ret = SSL_set1_sigalgs(clientssl, curr->list, curr->listlen);
972 ret = SSL_set1_sigalgs_list(clientssl, curr->liststr);
975 printf("Unexpected failure setting sigalgs in SSL (%d)\n", idx);
981 printf("Unexpected success setting sigalgs in SSL (%d)\n", idx);
986 if (curr->connsuccess != create_ssl_connection(serverssl, clientssl)) {
987 printf("Unexpected return value creating SSL connection (%d)\n", idx);
1002 int test_main(int argc, char *argv[])
1007 printf("Invalid argument count\n");
1014 ADD_TEST(test_large_message_tls);
1015 ADD_TEST(test_large_message_tls_read_ahead);
1016 #ifndef OPENSSL_NO_DTLS
1017 ADD_TEST(test_large_message_dtls);
1019 ADD_TEST(test_tlsext_status_type);
1020 ADD_TEST(test_session_with_only_int_cache);
1021 ADD_TEST(test_session_with_only_ext_cache);
1022 ADD_TEST(test_session_with_both_cache);
1023 ADD_ALL_TESTS(test_ssl_set_bio, TOTAL_SSL_SET_BIO_TESTS);
1024 ADD_TEST(test_ssl_bio_pop_next_bio);
1025 ADD_TEST(test_ssl_bio_pop_ssl_bio);
1026 ADD_TEST(test_ssl_bio_change_rbio);
1027 ADD_TEST(test_ssl_bio_change_wbio);
1028 ADD_ALL_TESTS(test_set_sigalgs, OSSL_NELEM(testsigalgs) * 2);
1030 testresult = run_tests(argv[0]);
1032 bio_s_mempacket_test_free();