1e1051a39Sopenharmony_ci/*
2e1051a39Sopenharmony_ci * Copyright 2016-2023 The OpenSSL Project Authors. All Rights Reserved.
3e1051a39Sopenharmony_ci *
4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License").  You may not use
5e1051a39Sopenharmony_ci * this file except in compliance with the License.  You can obtain a copy
6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at
7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html
8e1051a39Sopenharmony_ci */
9e1051a39Sopenharmony_ci
10e1051a39Sopenharmony_ci#ifndef OSSL_TEST_SSLTESTLIB_H
11e1051a39Sopenharmony_ci# define OSSL_TEST_SSLTESTLIB_H
12e1051a39Sopenharmony_ci
13e1051a39Sopenharmony_ci# include <openssl/ssl.h>
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_ciint create_ssl_ctx_pair(OSSL_LIB_CTX *libctx, const SSL_METHOD *sm,
16e1051a39Sopenharmony_ci                        const SSL_METHOD *cm, int min_proto_version,
17e1051a39Sopenharmony_ci                        int max_proto_version, SSL_CTX **sctx, SSL_CTX **cctx,
18e1051a39Sopenharmony_ci                        char *certfile, char *privkeyfile);
19e1051a39Sopenharmony_ciint create_ssl_objects(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
20e1051a39Sopenharmony_ci                       SSL **cssl, BIO *s_to_c_fbio, BIO *c_to_s_fbio);
21e1051a39Sopenharmony_ciint create_bare_ssl_connection(SSL *serverssl, SSL *clientssl, int want,
22e1051a39Sopenharmony_ci                               int read);
23e1051a39Sopenharmony_ciint create_ssl_objects2(SSL_CTX *serverctx, SSL_CTX *clientctx, SSL **sssl,
24e1051a39Sopenharmony_ci                       SSL **cssl, int sfd, int cfd);
25e1051a39Sopenharmony_ciint create_test_sockets(int *cfd, int *sfd);
26e1051a39Sopenharmony_ciint create_ssl_connection(SSL *serverssl, SSL *clientssl, int want);
27e1051a39Sopenharmony_civoid shutdown_ssl_connection(SSL *serverssl, SSL *clientssl);
28e1051a39Sopenharmony_ci
29e1051a39Sopenharmony_ci/* Note: Not thread safe! */
30e1051a39Sopenharmony_ciconst BIO_METHOD *bio_f_tls_dump_filter(void);
31e1051a39Sopenharmony_civoid bio_f_tls_dump_filter_free(void);
32e1051a39Sopenharmony_ci
33e1051a39Sopenharmony_ciconst BIO_METHOD *bio_s_mempacket_test(void);
34e1051a39Sopenharmony_civoid bio_s_mempacket_test_free(void);
35e1051a39Sopenharmony_ci
36e1051a39Sopenharmony_ciconst BIO_METHOD *bio_s_always_retry(void);
37e1051a39Sopenharmony_civoid bio_s_always_retry_free(void);
38e1051a39Sopenharmony_ci
39e1051a39Sopenharmony_ci/* Packet types - value 0 is reserved */
40e1051a39Sopenharmony_ci#define INJECT_PACKET                   1
41e1051a39Sopenharmony_ci#define INJECT_PACKET_IGNORE_REC_SEQ    2
42e1051a39Sopenharmony_ci
43e1051a39Sopenharmony_ci/*
44e1051a39Sopenharmony_ci * Mempacket BIO ctrls. We make them large enough to not clash with standard BIO
45e1051a39Sopenharmony_ci * ctrl codes.
46e1051a39Sopenharmony_ci */
47e1051a39Sopenharmony_ci#define MEMPACKET_CTRL_SET_DROP_EPOCH       (1 << 15)
48e1051a39Sopenharmony_ci#define MEMPACKET_CTRL_SET_DROP_REC         (2 << 15)
49e1051a39Sopenharmony_ci#define MEMPACKET_CTRL_GET_DROP_REC         (3 << 15)
50e1051a39Sopenharmony_ci#define MEMPACKET_CTRL_SET_DUPLICATE_REC    (4 << 15)
51e1051a39Sopenharmony_ci
52e1051a39Sopenharmony_ciint mempacket_swap_epoch(BIO *bio);
53e1051a39Sopenharmony_ciint mempacket_move_packet(BIO *bio, int d, int s);
54e1051a39Sopenharmony_ciint mempacket_test_inject(BIO *bio, const char *in, int inl, int pktnum,
55e1051a39Sopenharmony_ci                          int type);
56e1051a39Sopenharmony_ci
57e1051a39Sopenharmony_citypedef struct mempacket_st MEMPACKET;
58e1051a39Sopenharmony_ci
59e1051a39Sopenharmony_ciDEFINE_STACK_OF(MEMPACKET)
60e1051a39Sopenharmony_ci
61e1051a39Sopenharmony_ci#endif /* OSSL_TEST_SSLTESTLIB_H */
62