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"
22 static char *cert = NULL;
23 static char *privkey = NULL;
25 #ifndef OPENSSL_NO_OCSP
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;
34 #define NUM_EXTRA_CERTS 40
36 static int execute_test_large_message(const SSL_METHOD *smeth,
37 const SSL_METHOD *cmeth, int read_ahead)
39 SSL_CTX *cctx = NULL, *sctx = NULL;
40 SSL *clientssl = NULL, *serverssl = NULL;
43 BIO *certbio = BIO_new_file(cert, "r");
44 X509 *chaincert = NULL;
47 if (certbio == NULL) {
48 printf("Can't load the certficate file\n");
51 chaincert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
54 if (chaincert == NULL) {
55 printf("Unable to load certificate for chain\n");
59 if (!create_ssl_ctx_pair(smeth, cmeth, &sctx,
60 &cctx, cert, privkey)) {
61 printf("Unable to create SSL_CTX pair\n");
67 * Test that read_ahead works correctly when dealing with large
70 SSL_CTX_set_read_ahead(cctx, 1);
74 * We assume the supplied certificate is big enough so that if we add
75 * NUM_EXTRA_CERTS it will make the overall message large enough. The
76 * default buffer size is requested to be 16k, but due to the way BUF_MEM
77 * works, it ends up allocing a little over 21k (16 * 4/3). So, in this test
78 * we need to have a message larger than that.
80 certlen = i2d_X509(chaincert, NULL);
81 OPENSSL_assert((certlen * NUM_EXTRA_CERTS)
82 > ((SSL3_RT_MAX_PLAIN_LENGTH * 4) / 3));
83 for (i = 0; i < NUM_EXTRA_CERTS; i++) {
84 if (!X509_up_ref(chaincert)) {
85 printf("Unable to up ref cert\n");
88 if (!SSL_CTX_add_extra_chain_cert(sctx, chaincert)) {
89 printf("Unable to add extra chain cert %d\n", i);
95 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
96 printf("Unable to create SSL objects\n");
100 if (!create_ssl_connection(serverssl, clientssl)) {
101 printf("Unable to create SSL connection\n");
106 * Calling SSL_clear() first is not required but this tests that SSL_clear()
107 * doesn't leak (when using enable-crypto-mdebug).
109 if (!SSL_clear(serverssl)) {
110 printf("Unexpected failure from SSL_clear()\n");
116 X509_free(chaincert);
125 static int test_large_message_tls(void)
127 return execute_test_large_message(TLS_server_method(), TLS_client_method(),
131 static int test_large_message_tls_read_ahead(void)
133 return execute_test_large_message(TLS_server_method(), TLS_client_method(),
137 #ifndef OPENSSL_NO_DTLS
138 static int test_large_message_dtls(void)
141 * read_ahead is not relevant to DTLS because DTLS always acts as if
144 return execute_test_large_message(DTLS_server_method(),
145 DTLS_client_method(), 0);
149 #ifndef OPENSSL_NO_OCSP
150 static int ocsp_server_cb(SSL *s, void *arg)
152 int *argi = (int *)arg;
153 unsigned char *orespdercopy = NULL;
154 STACK_OF(OCSP_RESPID) *ids = NULL;
155 OCSP_RESPID *id = NULL;
158 /* In this test we are expecting exactly 1 OCSP_RESPID */
159 SSL_get_tlsext_status_ids(s, &ids);
160 if (ids == NULL || sk_OCSP_RESPID_num(ids) != 1)
161 return SSL_TLSEXT_ERR_ALERT_FATAL;
163 id = sk_OCSP_RESPID_value(ids, 0);
164 if (id == NULL || !OCSP_RESPID_match(id, ocspcert))
165 return SSL_TLSEXT_ERR_ALERT_FATAL;
166 } else if (*argi != 1) {
167 return SSL_TLSEXT_ERR_ALERT_FATAL;
171 orespdercopy = OPENSSL_memdup(orespder, sizeof(orespder));
172 if (orespdercopy == NULL)
173 return SSL_TLSEXT_ERR_ALERT_FATAL;
175 SSL_set_tlsext_status_ocsp_resp(s, orespdercopy, sizeof(orespder));
177 ocsp_server_called = 1;
179 return SSL_TLSEXT_ERR_OK;
182 static int ocsp_client_cb(SSL *s, void *arg)
184 int *argi = (int *)arg;
185 const unsigned char *respderin;
188 if (*argi != 1 && *argi != 2)
191 len = SSL_get_tlsext_status_ocsp_resp(s, &respderin);
193 if (memcmp(orespder, respderin, len) != 0)
196 ocsp_client_called = 1;
201 static int test_tlsext_status_type(void)
203 SSL_CTX *cctx = NULL, *sctx = NULL;
204 SSL *clientssl = NULL, *serverssl = NULL;
206 STACK_OF(OCSP_RESPID) *ids = NULL;
207 OCSP_RESPID *id = NULL;
210 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
211 &cctx, cert, privkey)) {
212 printf("Unable to create SSL_CTX pair\n");
216 if (SSL_CTX_get_tlsext_status_type(cctx) != -1) {
217 printf("Unexpected initial value for "
218 "SSL_CTX_get_tlsext_status_type()\n");
222 /* First just do various checks getting and setting tlsext_status_type */
224 clientssl = SSL_new(cctx);
225 if (SSL_get_tlsext_status_type(clientssl) != -1) {
226 printf("Unexpected initial value for SSL_get_tlsext_status_type()\n");
230 if (!SSL_set_tlsext_status_type(clientssl, TLSEXT_STATUSTYPE_ocsp)) {
231 printf("Unexpected fail for SSL_set_tlsext_status_type()\n");
235 if (SSL_get_tlsext_status_type(clientssl) != TLSEXT_STATUSTYPE_ocsp) {
236 printf("Unexpected result for SSL_get_tlsext_status_type()\n");
243 if (!SSL_CTX_set_tlsext_status_type(cctx, TLSEXT_STATUSTYPE_ocsp)) {
244 printf("Unexpected fail for SSL_CTX_set_tlsext_status_type()\n");
248 if (SSL_CTX_get_tlsext_status_type(cctx) != TLSEXT_STATUSTYPE_ocsp) {
249 printf("Unexpected result for SSL_CTX_get_tlsext_status_type()\n");
253 clientssl = SSL_new(cctx);
255 if (SSL_get_tlsext_status_type(clientssl) != TLSEXT_STATUSTYPE_ocsp) {
256 printf("Unexpected result for SSL_get_tlsext_status_type() (test 2)\n");
264 * Now actually do a handshake and check OCSP information is exchanged and
265 * the callbacks get called
268 SSL_CTX_set_tlsext_status_cb(cctx, ocsp_client_cb);
269 SSL_CTX_set_tlsext_status_arg(cctx, &cdummyarg);
270 SSL_CTX_set_tlsext_status_cb(sctx, ocsp_server_cb);
271 SSL_CTX_set_tlsext_status_arg(sctx, &cdummyarg);
273 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
274 printf("Unable to create SSL objects\n");
278 if (!create_ssl_connection(serverssl, clientssl)) {
279 printf("Unable to create SSL connection\n");
283 if (!ocsp_client_called || !ocsp_server_called) {
284 printf("OCSP callbacks not called\n");
293 /* Try again but this time force the server side callback to fail */
294 ocsp_client_called = 0;
295 ocsp_server_called = 0;
298 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
299 printf("Unable to create SSL objects\n");
303 /* This should fail because the callback will fail */
304 if (create_ssl_connection(serverssl, clientssl)) {
305 printf("Unexpected success creating the connection\n");
309 if (ocsp_client_called || ocsp_server_called) {
310 printf("OCSP callbacks successfully called unexpectedly\n");
320 * This time we'll get the client to send an OCSP_RESPID that it will
323 ocsp_client_called = 0;
324 ocsp_server_called = 0;
327 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
328 printf("Unable to create SSL objects\n");
333 * We'll just use any old cert for this test - it doesn't have to be an OCSP
334 * specifc one. We'll use the server cert.
336 certbio = BIO_new_file(cert, "r");
337 if (certbio == NULL) {
338 printf("Can't load the certficate file\n");
341 id = OCSP_RESPID_new();
342 ids = sk_OCSP_RESPID_new_null();
343 ocspcert = PEM_read_bio_X509(certbio, NULL, NULL, NULL);
344 if (id == NULL || ids == NULL || ocspcert == NULL
345 || !OCSP_RESPID_set_by_key(id, ocspcert)
346 || !sk_OCSP_RESPID_push(ids, id)) {
347 printf("Unable to set OCSP_RESPIDs\n");
351 SSL_set_tlsext_status_ids(clientssl, ids);
352 /* Control has been transferred */
358 if (!create_ssl_connection(serverssl, clientssl)) {
359 printf("Unable to create SSL connection\n");
363 if (!ocsp_client_called || !ocsp_server_called) {
364 printf("OCSP callbacks not called\n");
375 sk_OCSP_RESPID_pop_free(ids, OCSP_RESPID_free);
376 OCSP_RESPID_free(id);
383 #endif /* ndef OPENSSL_NO_OCSP */
385 typedef struct ssl_session_test_fixture {
386 const char *test_case_name;
389 } SSL_SESSION_TEST_FIXTURE;
391 static int new_called = 0, remove_called = 0;
393 static SSL_SESSION_TEST_FIXTURE
394 ssl_session_set_up(const char *const test_case_name)
396 SSL_SESSION_TEST_FIXTURE fixture;
398 fixture.test_case_name = test_case_name;
399 fixture.use_ext_cache = 1;
400 fixture.use_int_cache = 1;
402 new_called = remove_called = 0;
407 static void ssl_session_tear_down(SSL_SESSION_TEST_FIXTURE fixture)
411 static int new_session_cb(SSL *ssl, SSL_SESSION *sess)
418 static void remove_session_cb(SSL_CTX *ctx, SSL_SESSION *sess)
423 static int execute_test_session(SSL_SESSION_TEST_FIXTURE fix)
425 SSL_CTX *sctx = NULL, *cctx = NULL;
426 SSL *serverssl1 = NULL, *clientssl1 = NULL;
427 SSL *serverssl2 = NULL, *clientssl2 = NULL;
428 #ifndef OPENSSL_NO_TLS1_1
429 SSL *serverssl3 = NULL, *clientssl3 = NULL;
431 SSL_SESSION *sess1 = NULL, *sess2 = NULL;
434 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
435 &cctx, cert, privkey)) {
436 printf("Unable to create SSL_CTX pair\n");
440 #ifndef OPENSSL_NO_TLS1_2
441 /* Only allow TLS1.2 so we can force a connection failure later */
442 SSL_CTX_set_min_proto_version(cctx, TLS1_2_VERSION);
445 /* Set up session cache */
446 if (fix.use_ext_cache) {
447 SSL_CTX_sess_set_new_cb(cctx, new_session_cb);
448 SSL_CTX_sess_set_remove_cb(cctx, remove_session_cb);
450 if (fix.use_int_cache) {
451 /* Also covers instance where both are set */
452 SSL_CTX_set_session_cache_mode(cctx, SSL_SESS_CACHE_CLIENT);
454 SSL_CTX_set_session_cache_mode(cctx,
455 SSL_SESS_CACHE_CLIENT
456 | SSL_SESS_CACHE_NO_INTERNAL_STORE);
459 if (!create_ssl_objects(sctx, cctx, &serverssl1, &clientssl1, NULL,
461 printf("Unable to create SSL objects\n");
465 if (!create_ssl_connection(serverssl1, clientssl1)) {
466 printf("Unable to create SSL connection\n");
469 sess1 = SSL_get1_session(clientssl1);
471 printf("Unexpected NULL session\n");
475 if (fix.use_int_cache && SSL_CTX_add_session(cctx, sess1)) {
476 /* Should have failed because it should already be in the cache */
477 printf("Unexpected success adding session to cache\n");
481 if (fix.use_ext_cache && (new_called != 1 || remove_called != 0)) {
482 printf("Session not added to cache\n");
486 if (!create_ssl_objects(sctx, cctx, &serverssl2, &clientssl2, NULL, NULL)) {
487 printf("Unable to create second SSL objects\n");
491 if (!create_ssl_connection(serverssl2, clientssl2)) {
492 printf("Unable to create second SSL connection\n");
496 sess2 = SSL_get1_session(clientssl2);
498 printf("Unexpected NULL session from clientssl2\n");
502 if (fix.use_ext_cache && (new_called != 2 || remove_called != 0)) {
503 printf("Remove session callback unexpectedly called\n");
508 * This should clear sess2 from the cache because it is a "bad" session. See
509 * SSL_set_session() documentation.
511 if (!SSL_set_session(clientssl2, sess1)) {
512 printf("Unexpected failure setting session\n");
516 if (fix.use_ext_cache && (new_called != 2 || remove_called != 1)) {
517 printf("Failed to call callback to remove session\n");
522 if (SSL_get_session(clientssl2) != sess1) {
523 printf("Unexpected session found\n");
527 if (fix.use_int_cache) {
528 if (!SSL_CTX_add_session(cctx, sess2)) {
530 * Should have succeeded because it should not already be in the cache
532 printf("Unexpected failure adding session to cache\n");
536 if (!SSL_CTX_remove_session(cctx, sess2)) {
537 printf("Unexpected failure removing session from cache\n");
541 /* This is for the purposes of internal cache testing...ignore the
542 * counter for external cache
544 if (fix.use_ext_cache)
548 /* This shouldn't be in the cache so should fail */
549 if (SSL_CTX_remove_session(cctx, sess2)) {
550 printf("Unexpected success removing session from cache\n");
554 if (fix.use_ext_cache && (new_called != 2 || remove_called != 2)) {
555 printf("Failed to call callback to remove session #2\n");
559 #if !defined(OPENSSL_NO_TLS1_1) && !defined(OPENSSL_NO_TLS1_2)
560 /* Force a connection failure */
561 SSL_CTX_set_max_proto_version(sctx, TLS1_1_VERSION);
563 if (!create_ssl_objects(sctx, cctx, &serverssl3, &clientssl3, NULL, NULL)) {
564 printf("Unable to create third SSL objects\n");
568 if (!SSL_set_session(clientssl3, sess1)) {
569 printf("Unable to set session for third connection\n");
573 /* This should fail because of the mismatched protocol versions */
574 if (create_ssl_connection(serverssl3, clientssl3)) {
575 printf("Unable to create third SSL connection\n");
580 /* We should have automatically removed the session from the cache */
581 if (fix.use_ext_cache && (new_called != 2 || remove_called != 3)) {
582 printf("Failed to call callback to remove session #2\n");
586 if (fix.use_int_cache && !SSL_CTX_add_session(cctx, sess2)) {
588 * Should have succeeded because it should not already be in the cache
590 printf("Unexpected failure adding session to cache #2\n");
598 SSL_free(serverssl1);
599 SSL_free(clientssl1);
600 SSL_free(serverssl2);
601 SSL_free(clientssl2);
602 #ifndef OPENSSL_NO_TLS1_1
603 SSL_free(serverssl3);
604 SSL_free(clientssl3);
606 SSL_SESSION_free(sess1);
607 SSL_SESSION_free(sess2);
609 * Check if we need to remove any sessions up-refed for the external cache
612 SSL_SESSION_free(sess1);
614 SSL_SESSION_free(sess2);
621 static int test_session_with_only_int_cache(void)
623 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
625 fixture.use_ext_cache = 0;
627 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
630 static int test_session_with_only_ext_cache(void)
632 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
634 fixture.use_int_cache = 0;
636 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
639 static int test_session_with_both_cache(void)
641 SETUP_TEST_FIXTURE(SSL_SESSION_TEST_FIXTURE, ssl_session_set_up);
643 EXECUTE_TEST(execute_test_session, ssl_session_tear_down);
650 #define TOTAL_SSL_SET_BIO_TESTS (3 * 3 * 3 * 3)
652 static void setupbio(BIO **res, BIO *bio1, BIO *bio2, int type)
667 static int test_ssl_set_bio(int idx)
669 SSL_CTX *ctx = SSL_CTX_new(TLS_method());
672 BIO *irbio = NULL, *iwbio = NULL, *nrbio = NULL, *nwbio = NULL;
674 int initrbio, initwbio, newrbio, newwbio;
678 printf("Failed to allocate SSL_CTX\n");
684 printf("Failed to allocate SSL object\n");
695 OPENSSL_assert(newwbio <= 2);
697 if (initrbio == USE_BIO_1 || initwbio == USE_BIO_1 || newrbio == USE_BIO_1
698 || newwbio == USE_BIO_1) {
699 bio1 = BIO_new(BIO_s_mem());
701 printf("Failed to allocate bio1\n");
706 if (initrbio == USE_BIO_2 || initwbio == USE_BIO_2 || newrbio == USE_BIO_2
707 || newwbio == USE_BIO_2) {
708 bio2 = BIO_new(BIO_s_mem());
710 printf("Failed to allocate bio2\n");
715 setupbio(&irbio, bio1, bio2, initrbio);
716 setupbio(&iwbio, bio1, bio2, initwbio);
719 * We want to maintain our own refs to these BIO, so do an up ref for each
720 * BIO that will have ownersip transferred in the SSL_set_bio() call
724 if (iwbio != NULL && iwbio != irbio)
727 SSL_set_bio(ssl, irbio, iwbio);
729 setupbio(&nrbio, bio1, bio2, newrbio);
730 setupbio(&nwbio, bio1, bio2, newwbio);
733 * We will (maybe) transfer ownership again so do more up refs.
734 * SSL_set_bio() has some really complicated ownership rules where BIOs have
737 if (nrbio != NULL && nrbio != irbio && (nwbio != iwbio || nrbio != nwbio))
739 if (nwbio != NULL && nwbio != nrbio && (nwbio != iwbio || (nwbio == iwbio && irbio == iwbio)))
742 SSL_set_bio(ssl, nrbio, nwbio);
751 * This test is checking that the ref counting for SSL_set_bio is correct.
752 * If we get here and we did too many frees then we will fail in the above
753 * functions. If we haven't done enough then this will only be detected in
754 * a crypto-mdebug build
761 typedef struct ssl_bio_test_fixture {
762 const char *test_case_name;
764 enum { NO_BIO_CHANGE, CHANGE_RBIO, CHANGE_WBIO } change_bio;
765 } SSL_BIO_TEST_FIXTURE;
767 static SSL_BIO_TEST_FIXTURE ssl_bio_set_up(const char *const test_case_name)
769 SSL_BIO_TEST_FIXTURE fixture;
771 fixture.test_case_name = test_case_name;
773 fixture.change_bio = NO_BIO_CHANGE;
778 static void ssl_bio_tear_down(SSL_BIO_TEST_FIXTURE fixture)
782 static int execute_test_ssl_bio(SSL_BIO_TEST_FIXTURE fix)
784 BIO *sslbio = NULL, *membio1 = NULL, *membio2 = NULL;
785 SSL_CTX *ctx = SSL_CTX_new(TLS_method());
790 printf("Failed to allocate SSL_CTX\n");
796 printf("Failed to allocate SSL object\n");
800 sslbio = BIO_new(BIO_f_ssl());
801 membio1 = BIO_new(BIO_s_mem());
803 if (sslbio == NULL || membio1 == NULL) {
804 printf("Malloc failure creating BIOs\n");
808 BIO_set_ssl(sslbio, ssl, BIO_CLOSE);
811 * If anything goes wrong here then we could leak memory, so this will
812 * be caught in a crypto-mdebug build
814 BIO_push(sslbio, membio1);
816 /* Verify chaning the rbio/wbio directly does not cause leaks */
817 if (fix.change_bio != NO_BIO_CHANGE) {
818 membio2 = BIO_new(BIO_s_mem());
819 if (membio2 == NULL) {
820 printf("Malloc failure creating membio2\n");
823 if (fix.change_bio == CHANGE_RBIO)
824 SSL_set0_rbio(ssl, membio2);
826 SSL_set0_wbio(ssl, membio2);
845 static int test_ssl_bio_pop_next_bio(void)
847 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
849 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
852 static int test_ssl_bio_pop_ssl_bio(void)
854 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
858 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
861 static int test_ssl_bio_change_rbio(void)
863 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
865 fixture.change_bio = CHANGE_RBIO;
867 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
870 static int test_ssl_bio_change_wbio(void)
872 SETUP_TEST_FIXTURE(SSL_BIO_TEST_FIXTURE, ssl_bio_set_up);
874 fixture.change_bio = CHANGE_WBIO;
876 EXECUTE_TEST(execute_test_ssl_bio, ssl_bio_tear_down);
880 /* The list of sig algs */
882 /* The length of the list */
884 /* A sigalgs list in string format */
886 /* Whether setting the list should succeed */
888 /* Whether creating a connection with the list should succeed */
892 static const int validlist1[] = {NID_sha256, EVP_PKEY_RSA};
893 static const int validlist2[] = {NID_sha256, EVP_PKEY_RSA, NID_sha512, EVP_PKEY_EC};
894 static const int validlist3[] = {NID_sha512, EVP_PKEY_EC};
895 static const int invalidlist1[] = {NID_undef, EVP_PKEY_RSA};
896 static const int invalidlist2[] = {NID_sha256, NID_undef};
897 static const int invalidlist3[] = {NID_sha256, EVP_PKEY_RSA, NID_sha256};
898 static const int invalidlist4[] = {NID_sha256};
899 static const sigalgs_list testsigalgs[] = {
900 {validlist1, OSSL_NELEM(validlist1), NULL, 1, 1},
901 {validlist2, OSSL_NELEM(validlist2), NULL, 1, 1},
902 {validlist3, OSSL_NELEM(validlist3), NULL, 1, 0},
903 {NULL, 0, "RSA+SHA256", 1, 1},
904 {NULL, 0, "RSA+SHA256:ECDSA+SHA512", 1, 1},
905 {NULL, 0, "ECDSA+SHA512", 1, 0},
906 {invalidlist1, OSSL_NELEM(invalidlist1), NULL, 0, 0},
907 {invalidlist2, OSSL_NELEM(invalidlist2), NULL, 0, 0},
908 {invalidlist3, OSSL_NELEM(invalidlist3), NULL, 0, 0},
909 {invalidlist4, OSSL_NELEM(invalidlist4), NULL, 0, 0},
910 {NULL, 0, "RSA", 0, 0},
911 {NULL, 0, "SHA256", 0, 0},
912 {NULL, 0, "RSA+SHA256:SHA256", 0, 0},
913 {NULL, 0, "Invalid", 0, 0}};
915 static int test_set_sigalgs(int idx)
917 SSL_CTX *cctx = NULL, *sctx = NULL;
918 SSL *clientssl = NULL, *serverssl = NULL;
920 const sigalgs_list *curr;
923 /* Should never happen */
924 if ((size_t)idx >= OSSL_NELEM(testsigalgs) * 2)
927 testctx = ((size_t)idx < OSSL_NELEM(testsigalgs));
928 curr = testctx ? &testsigalgs[idx]
929 : &testsigalgs[idx - OSSL_NELEM(testsigalgs)];
931 if (!create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(), &sctx,
932 &cctx, cert, privkey)) {
933 printf("Unable to create SSL_CTX pair\n");
939 if (curr->list != NULL)
940 ret = SSL_CTX_set1_sigalgs(cctx, curr->list, curr->listlen);
942 ret = SSL_CTX_set1_sigalgs_list(cctx, curr->liststr);
946 printf("Unexpected failure setting sigalgs in SSL_CTX (%d)\n",
953 printf("Unexpected success setting sigalgs in SSL_CTX (%d)\n", idx);
958 if (!create_ssl_objects(sctx, cctx, &serverssl, &clientssl, NULL, NULL)) {
959 printf("Unable to create SSL objects\n");
966 if (curr->list != NULL)
967 ret = SSL_set1_sigalgs(clientssl, curr->list, curr->listlen);
969 ret = SSL_set1_sigalgs_list(clientssl, curr->liststr);
972 printf("Unexpected failure setting sigalgs in SSL (%d)\n", idx);
978 printf("Unexpected success setting sigalgs in SSL (%d)\n", idx);
983 if (curr->connsuccess != create_ssl_connection(serverssl, clientssl)) {
984 printf("Unexpected return value creating SSL connection (%d)\n", idx);
999 int main(int argc, char *argv[])
1005 printf("Invalid argument count\n");
1012 err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
1014 CRYPTO_set_mem_debug(1);
1015 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
1017 ADD_TEST(test_large_message_tls);
1018 ADD_TEST(test_large_message_tls_read_ahead);
1019 #ifndef OPENSSL_NO_DTLS
1020 ADD_TEST(test_large_message_dtls);
1022 #ifndef OPENSSL_NO_OCSP
1023 ADD_TEST(test_tlsext_status_type);
1025 ADD_TEST(test_session_with_only_int_cache);
1026 ADD_TEST(test_session_with_only_ext_cache);
1027 ADD_TEST(test_session_with_both_cache);
1028 ADD_ALL_TESTS(test_ssl_set_bio, TOTAL_SSL_SET_BIO_TESTS);
1029 ADD_TEST(test_ssl_bio_pop_next_bio);
1030 ADD_TEST(test_ssl_bio_pop_ssl_bio);
1031 ADD_TEST(test_ssl_bio_change_rbio);
1032 ADD_TEST(test_ssl_bio_change_wbio);
1033 ADD_ALL_TESTS(test_set_sigalgs, OSSL_NELEM(testsigalgs) * 2);
1035 testresult = run_tests(argv[0]);
1037 bio_s_mempacket_test_free();
1039 #ifndef OPENSSL_NO_CRYPTO_MDEBUG
1040 if (CRYPTO_mem_leaks(err) <= 0)