]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/helpers/quictestlib.h
Implement the QUIC Fault injector support for TLS handshake messages
[thirdparty/openssl.git] / test / helpers / quictestlib.h
CommitLineData
adef87a2
MC
1/*
2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#include <openssl/ssl.h>
11#include <internal/quic_tserver.h>
12
13typedef struct ossl_quic_fault OSSL_QUIC_FAULT;
14
6d1f6933
MC
15typedef struct ossl_qf_encrypted_extensions {
16 unsigned char *extensions;
17 size_t extensionslen;
18} OSSL_QF_ENCRYPTED_EXTENSIONS;
19
adef87a2
MC
20int qtest_create_quic_objects(SSL_CTX *clientctx, char *certfile, char *keyfile,
21 QUIC_TSERVER **qtserv, SSL **cssl,
22 OSSL_QUIC_FAULT **fault);
23int qtest_create_quic_connection(QUIC_TSERVER *qtserv, SSL *clientssl);
2f1d8f85
MC
24
25void ossl_quic_fault_free(OSSL_QUIC_FAULT *fault);
26
27typedef int (*ossl_quic_fault_on_packet_plain_cb)(OSSL_QUIC_FAULT *fault,
28 QUIC_PKT_HDR *hdr,
29 unsigned char *buf,
30 size_t len,
31 void *cbarg);
32
33int ossl_quic_fault_set_packet_plain_listener(OSSL_QUIC_FAULT *fault,
34 ossl_quic_fault_on_packet_plain_cb pplaincb,
35 void *pplaincbarg);
36
37/* To be called from a packet_plain_listener callback */
38int ossl_quic_fault_resize_plain_packet(OSSL_QUIC_FAULT *fault, size_t newlen);
6d1f6933
MC
39
40/*
41 * The general handshake message listener is sent the entire handshake message
42 * data block, including the handshake header itself
43 */
44typedef int (*ossl_quic_fault_on_handshake_cb)(OSSL_QUIC_FAULT *fault,
45 unsigned char *msg,
46 size_t msglen,
47 void *handshakecbarg);
48
49int ossl_quic_fault_set_handshake_listener(OSSL_QUIC_FAULT *fault,
50 ossl_quic_fault_on_handshake_cb handshakecb,
51 void *handshakecbarg);
52
53/*
54 * To be called from a handshake_listener callback. newlen must include the
55 * length of the handshake message header.
56 */
57int ossl_quic_fault_resize_handshake(OSSL_QUIC_FAULT *fault, size_t newlen);
58
59/*
60 * Handshake message specific listeners. Unlike the general handshake message
61 * listener these messages are pre-parsed and supplied with message specific
62 * data and exclude the handshake header
63 */
64typedef int (*ossl_quic_fault_on_enc_ext_cb)(OSSL_QUIC_FAULT *fault,
65 OSSL_QF_ENCRYPTED_EXTENSIONS *ee,
66 size_t eelen,
67 void *encextcbarg);
68
69int ossl_quic_fault_set_hand_enc_ext_listener(OSSL_QUIC_FAULT *fault,
70 ossl_quic_fault_on_enc_ext_cb encextcb,
71 void *encextcbarg);
72
73
74/*
75 * To be called from message specific listener callbacks. newlen is the new
76 * length of the specific message excluding the handshake message header.
77 */
78int ossl_quic_fault_resize_message(OSSL_QUIC_FAULT *fault, size_t newlen);
79
80/*
81 * Delete an extension from an extension block. |exttype| is the type of the
82 * extension to be deleted. |ext| points to the extension block. On entry
83 * |*extlen| contains the length of the extension block. It is updated with the
84 * new length on exit. On entry |*msglen| is the length of the handshake message
85 * (without the header). On exit it is updated with the new message length.
86 * ossl_quic_fault_resize_handshake() is called automatically so there is no
87 * need to call it explicitly.
88 */
89int ossl_quic_fault_delete_extension(OSSL_QUIC_FAULT *fault,
90 unsigned int exttype, unsigned char *ext,
91 size_t *extlen, size_t *msglen);