]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/quicapitest.c
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 /* TODO(QUIC): Temporarily disabled during front-end I/O API finalization. */
29 * Test that we read what we've written.
31 static int test_quic_write_read(void)
33 SSL_CTX
*cctx
= NULL
, *sctx
= NULL
;
34 SSL
*clientquic
= NULL
, *serverquic
= NULL
;
37 static char *msg
= "A test message";
38 size_t msglen
= strlen(msg
);
41 if (!TEST_true(create_ssl_ctx_pair(libctx
, OSSL_QUIC_server_method(),
42 OSSL_QUIC_client_method(),
45 &sctx
, &cctx
, NULL
, NULL
))
46 || !TEST_true(create_ssl_objects(sctx
, cctx
, &serverquic
, &clientquic
,
48 || !TEST_true(create_bare_ssl_connection(serverquic
, clientquic
,
49 SSL_ERROR_NONE
, 0, 0)))
52 for (j
= 0; j
< 2; j
++) {
53 /* Check that sending and receiving app data is ok */
54 if (!TEST_true(SSL_write_ex(clientquic
, msg
, msglen
, &numbytes
))
55 || !TEST_true(SSL_read_ex(serverquic
, buf
, sizeof(buf
),
57 || !TEST_mem_eq(buf
, numbytes
, msg
, msglen
))
60 if (!TEST_true(SSL_write_ex(serverquic
, msg
, msglen
, &numbytes
))
61 || !TEST_true(SSL_read_ex(clientquic
, buf
, sizeof(buf
),
63 || !TEST_mem_eq(buf
, numbytes
, msg
, msglen
))
79 OPT_TEST_DECLARE_USAGE("provider config\n")
86 libctx
= OSSL_LIB_CTX_new();
87 if (!TEST_ptr(libctx
))
90 defctxnull
= OSSL_PROVIDER_load(NULL
, "null");
93 * Verify that the default and fips providers in the default libctx are not
96 if (!TEST_false(OSSL_PROVIDER_available(NULL
, "default"))
97 || !TEST_false(OSSL_PROVIDER_available(NULL
, "fips")))
100 if (!test_skip_common_options()) {
101 TEST_error("Error parsing test options\n");
105 if (!TEST_ptr(modulename
= test_get_argument(0))
106 || !TEST_ptr(configfile
= test_get_argument(1)))
109 if (!TEST_true(OSSL_LIB_CTX_load_config(libctx
, configfile
)))
112 /* Check we have the expected provider available */
113 if (!TEST_true(OSSL_PROVIDER_available(libctx
, modulename
)))
116 /* Check the default provider is not available */
117 if (strcmp(modulename
, "default") != 0
118 && !TEST_false(OSSL_PROVIDER_available(libctx
, "default")))
121 if (strcmp(modulename
, "fips") == 0)
124 /* TODO(QUIC): Temporarily disabled during front-end I/O API finalization. */
126 ADD_TEST(test_quic_write_read
);
131 void cleanup_tests(void)
133 OSSL_PROVIDER_unload(defctxnull
);
134 OSSL_LIB_CTX_free(libctx
);