2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
13 #include <openssl/opensslconf.h>
14 #include <openssl/quic.h>
16 #include "helpers/ssltestlib.h"
18 #include "testutil/output.h"
20 static OSSL_LIB_CTX *libctx = NULL;
21 static OSSL_PROVIDER *defctxnull = NULL;
23 static int is_fips = 0;
26 * Test that we read what we've written.
28 static int test_quic_write_read(void)
30 SSL_CTX *cctx = NULL, *sctx = NULL;
31 SSL *clientquic = NULL, *serverquic = NULL;
34 static char *msg = "A test message";
35 size_t msglen = strlen(msg);
38 if (!TEST_true(create_ssl_ctx_pair(libctx, OSSL_QUIC_server_method(),
39 OSSL_QUIC_client_method(),
42 &sctx, &cctx, NULL, NULL))
43 || !TEST_true(create_ssl_objects(sctx, cctx, &serverquic, &clientquic,
45 || !TEST_true(create_bare_ssl_connection(serverquic, clientquic,
46 SSL_ERROR_NONE, 0, 0)))
49 for (j = 0; j < 2; j++) {
50 /* Check that sending and receiving app data is ok */
51 if (!TEST_true(SSL_write_ex(clientquic, msg, msglen, &numbytes))
52 || !TEST_true(SSL_read_ex(serverquic, buf, sizeof(buf),
54 || !TEST_mem_eq(buf, numbytes, msg, msglen))
57 if (!TEST_true(SSL_write_ex(serverquic, msg, msglen, &numbytes))
58 || !TEST_true(SSL_read_ex(clientquic, buf, sizeof(buf),
60 || !TEST_mem_eq(buf, numbytes, msg, msglen))
75 OPT_TEST_DECLARE_USAGE("provider config\n")
82 libctx = OSSL_LIB_CTX_new();
83 if (!TEST_ptr(libctx))
86 defctxnull = OSSL_PROVIDER_load(NULL, "null");
89 * Verify that the default and fips providers in the default libctx are not
92 if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
93 || !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
96 if (!test_skip_common_options()) {
97 TEST_error("Error parsing test options\n");
101 if (!TEST_ptr(modulename = test_get_argument(0))
102 || !TEST_ptr(configfile = test_get_argument(1)))
105 if (!TEST_true(OSSL_LIB_CTX_load_config(libctx, configfile)))
108 /* Check we have the expected provider available */
109 if (!TEST_true(OSSL_PROVIDER_available(libctx, modulename)))
112 /* Check the default provider is not available */
113 if (strcmp(modulename, "default") != 0
114 && !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
117 if (strcmp(modulename, "fips") == 0)
120 ADD_TEST(test_quic_write_read);
124 void cleanup_tests(void)
126 OSSL_PROVIDER_unload(defctxnull);
127 OSSL_LIB_CTX_free(libctx);