diff options
author | Matt Caswell <matt@openssl.org> | 2023-02-06 15:34:05 +0000 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-02-22 05:34:06 +0000 |
commit | c12e11133625569f5b92a2a78486ecb70cd23df7 (patch) | |
tree | 191dd5e0f8c4bf28017de91adf61171b0864e5ef /test/helpers | |
parent | d6cf4b59a0f3c32d61828ee82c193494e13ff969 (diff) | |
download | openssl-new-c12e11133625569f5b92a2a78486ecb70cd23df7.tar.gz |
Rename various functions OSSL_QUIC_FAULT -> QTEST_FAULT
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20030)
Diffstat (limited to 'test/helpers')
-rw-r--r-- | test/helpers/quictestlib.c | 92 | ||||
-rw-r--r-- | test/helpers/quictestlib.h | 108 |
2 files changed, 98 insertions, 102 deletions
diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 7fdd9cab31..657fcd257c 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -18,7 +18,7 @@ #define GROWTH_ALLOWANCE 1024 -struct ossl_quic_fault { +struct qtest_fault { QUIC_TSERVER *qtserv; /* Plain packet mutations */ @@ -28,7 +28,7 @@ struct ossl_quic_fault { OSSL_QTX_IOVEC pplainio; /* Allocted size of the plaintext packet data buffer */ size_t pplainbuf_alloc; - ossl_quic_fault_on_packet_plain_cb pplaincb; + qtest_fault_on_packet_plain_cb pplaincb; void *pplaincbarg; /* Handshake message mutations */ @@ -38,17 +38,17 @@ struct ossl_quic_fault { size_t handbufalloc; /* Actual length of the handshake message */ size_t handbuflen; - ossl_quic_fault_on_handshake_cb handshakecb; + qtest_fault_on_handshake_cb handshakecb; void *handshakecbarg; - ossl_quic_fault_on_enc_ext_cb encextcb; + qtest_fault_on_enc_ext_cb encextcb; void *encextcbarg; /* Cipher packet mutations */ - ossl_quic_fault_on_packet_cipher_cb pciphercb; + qtest_fault_on_packet_cipher_cb pciphercb; void *pciphercbarg; /* Datagram mutations */ - ossl_quic_fault_on_datagram_cb datagramcb; + qtest_fault_on_datagram_cb datagramcb; void *datagramcbarg; /* The currently processed message */ BIO_MSG msg; @@ -63,7 +63,7 @@ static BIO_METHOD *get_bio_method(void); int qtest_create_quic_objects(SSL_CTX *clientctx, char *certfile, char *keyfile, QUIC_TSERVER **qtserv, SSL **cssl, - OSSL_QUIC_FAULT **fault) + QTEST_FAULT **fault) { /* ALPN value as recognised by QUIC_TSERVER */ unsigned char alpn[] = { 8, 'o', 's', 's', 'l', 't', 'e', 's', 't' }; @@ -183,7 +183,7 @@ int qtest_create_quic_connection(QUIC_TSERVER *qtserv, SSL *clientssl) SSL_tick(clientssl); if (!servererr && rets <= 0) { ossl_quic_tserver_tick(qtserv); - servererr = ossl_quic_tserver_is_term_any(qtserv, NULL); + servererr = ossl_quic_tserver_is_term_any(qtserv); if (!servererr) rets = ossl_quic_tserver_is_handshake_confirmed(qtserv); } @@ -228,7 +228,7 @@ int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv) return qtest_check_server_transport_err(qtserv, QUIC_ERR_PROTOCOL_VIOLATION); } -void ossl_quic_fault_free(OSSL_QUIC_FAULT *fault) +void qtest_fault_free(QTEST_FAULT *fault) { if (fault == NULL) return; @@ -246,7 +246,7 @@ static int packet_plain_mutate(const QUIC_PKT_HDR *hdrin, size_t *numout, void *arg) { - OSSL_QUIC_FAULT *fault = arg; + QTEST_FAULT *fault = arg; size_t i, bufsz = 0; unsigned char *cur; @@ -293,7 +293,7 @@ static int packet_plain_mutate(const QUIC_PKT_HDR *hdrin, static void packet_plain_finish(void *arg) { - OSSL_QUIC_FAULT *fault = arg; + QTEST_FAULT *fault = arg; /* Cast below is safe because we allocated the buffer */ OPENSSL_free((unsigned char *)fault->pplainio.buf); @@ -302,9 +302,9 @@ static void packet_plain_finish(void *arg) fault->pplainio.buf = NULL; } -int ossl_quic_fault_set_packet_plain_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_packet_plain_cb pplaincb, - void *pplaincbarg) +int qtest_fault_set_packet_plain_listener(QTEST_FAULT *fault, + qtest_fault_on_packet_plain_cb pplaincb, + void *pplaincbarg) { fault->pplaincb = pplaincb; fault->pplaincbarg = pplaincbarg; @@ -316,7 +316,7 @@ int ossl_quic_fault_set_packet_plain_listener(OSSL_QUIC_FAULT *fault, } /* To be called from a packet_plain_listener callback */ -int ossl_quic_fault_resize_plain_packet(OSSL_QUIC_FAULT *fault, size_t newlen) +int qtest_fault_resize_plain_packet(QTEST_FAULT *fault, size_t newlen) { unsigned char *buf; size_t oldlen = fault->pplainio.buf_len; @@ -351,8 +351,8 @@ int ossl_quic_fault_resize_plain_packet(OSSL_QUIC_FAULT *fault, size_t newlen) * Prepend frame data into a packet. To be called from a packet_plain_listener * callback */ -int ossl_quic_fault_prepend_frame(OSSL_QUIC_FAULT *fault, unsigned char *frame, - size_t frame_len) +int qtest_fault_prepend_frame(QTEST_FAULT *fault, unsigned char *frame, + size_t frame_len) { unsigned char *buf; size_t old_len; @@ -369,8 +369,8 @@ int ossl_quic_fault_prepend_frame(OSSL_QUIC_FAULT *fault, unsigned char *frame, old_len = fault->pplainio.buf_len; /* Extend the size of the packet by the size of the new frame */ - if (!TEST_true(ossl_quic_fault_resize_plain_packet(fault, - old_len + frame_len))) + if (!TEST_true(qtest_fault_resize_plain_packet(fault, + old_len + frame_len))) return 0; memmove(buf + frame_len, buf, old_len); @@ -383,7 +383,7 @@ static int handshake_mutate(const unsigned char *msgin, size_t msginlen, unsigned char **msgout, size_t *msgoutlen, void *arg) { - OSSL_QUIC_FAULT *fault = arg; + QTEST_FAULT *fault = arg; unsigned char *buf; unsigned long payloadlen; unsigned int msgtype; @@ -408,7 +408,7 @@ static int handshake_mutate(const unsigned char *msgin, size_t msginlen, switch (msgtype) { case SSL3_MT_ENCRYPTED_EXTENSIONS: { - OSSL_QF_ENCRYPTED_EXTENSIONS ee; + QTEST_ENCRYPTED_EXTENSIONS ee; if (fault->encextcb == NULL) break; @@ -441,15 +441,15 @@ static int handshake_mutate(const unsigned char *msgin, size_t msginlen, static void handshake_finish(void *arg) { - OSSL_QUIC_FAULT *fault = arg; + QTEST_FAULT *fault = arg; OPENSSL_free(fault->handbuf); fault->handbuf = NULL; } -int ossl_quic_fault_set_handshake_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_handshake_cb handshakecb, - void *handshakecbarg) +int qtest_fault_set_handshake_listener(QTEST_FAULT *fault, + qtest_fault_on_handshake_cb handshakecb, + void *handshakecbarg) { fault->handshakecb = handshakecb; fault->handshakecbarg = handshakecbarg; @@ -460,9 +460,9 @@ int ossl_quic_fault_set_handshake_listener(OSSL_QUIC_FAULT *fault, fault); } -int ossl_quic_fault_set_hand_enc_ext_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_enc_ext_cb encextcb, - void *encextcbarg) +int qtest_fault_set_hand_enc_ext_listener(QTEST_FAULT *fault, + qtest_fault_on_enc_ext_cb encextcb, + void *encextcbarg) { fault->encextcb = encextcb; fault->encextcbarg = encextcbarg; @@ -474,7 +474,7 @@ int ossl_quic_fault_set_hand_enc_ext_listener(OSSL_QUIC_FAULT *fault, } /* To be called from a handshake_listener callback */ -int ossl_quic_fault_resize_handshake(OSSL_QUIC_FAULT *fault, size_t newlen) +int qtest_fault_resize_handshake(QTEST_FAULT *fault, size_t newlen) { unsigned char *buf; size_t oldlen = fault->handbuflen; @@ -503,10 +503,10 @@ int ossl_quic_fault_resize_handshake(OSSL_QUIC_FAULT *fault, size_t newlen) } /* To be called from message specific listener callbacks */ -int ossl_quic_fault_resize_message(OSSL_QUIC_FAULT *fault, size_t newlen) +int qtest_fault_resize_message(QTEST_FAULT *fault, size_t newlen) { /* First resize the underlying message */ - if (!ossl_quic_fault_resize_handshake(fault, newlen + SSL3_HM_HEADER_LENGTH)) + if (!qtest_fault_resize_handshake(fault, newlen + SSL3_HM_HEADER_LENGTH)) return 0; /* Fixup the handshake message header */ @@ -517,9 +517,9 @@ int ossl_quic_fault_resize_message(OSSL_QUIC_FAULT *fault, size_t newlen) return 1; } -int ossl_quic_fault_delete_extension(OSSL_QUIC_FAULT *fault, - unsigned int exttype, unsigned char *ext, - size_t *extlen) +int qtest_fault_delete_extension(QTEST_FAULT *fault, + unsigned int exttype, unsigned char *ext, + size_t *extlen) { PACKET pkt, sub, subext; unsigned int type; @@ -574,7 +574,7 @@ int ossl_quic_fault_delete_extension(OSSL_QUIC_FAULT *fault, if ((size_t)(end - start) + SSL3_HM_HEADER_LENGTH > msglen) return 0; /* Should not happen */ msglen -= (end - start) + SSL3_HM_HEADER_LENGTH; - if (!ossl_quic_fault_resize_message(fault, msglen)) + if (!qtest_fault_resize_message(fault, msglen)) return 0; return 1; @@ -590,7 +590,7 @@ static int pcipher_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, size_t num_msg, uint64_t flags, size_t *num_processed) { - OSSL_QUIC_FAULT *fault; + QTEST_FAULT *fault; BIO *next = BIO_next(b); ossl_ssize_t ret = 0; size_t i = 0, tmpnump; @@ -666,12 +666,8 @@ static int pcipher_sendmmsg(BIO *b, BIO_MSG *msg, size_t stride, } *num_processed = i; - ret = 1; out: - if (i > 0) - ret = 1; - else - ret = 0; + ret = i > 0; OPENSSL_free(fault->msg.data); fault->msg.data = NULL; return ret; @@ -710,9 +706,9 @@ static BIO_METHOD *get_bio_method(void) return pcipherbiometh; } -int ossl_quic_fault_set_packet_cipher_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_packet_cipher_cb pciphercb, - void *pciphercbarg) +int qtest_fault_set_packet_cipher_listener(QTEST_FAULT *fault, + qtest_fault_on_packet_cipher_cb pciphercb, + void *pciphercbarg) { fault->pciphercb = pciphercb; fault->pciphercbarg = pciphercbarg; @@ -720,9 +716,9 @@ int ossl_quic_fault_set_packet_cipher_listener(OSSL_QUIC_FAULT *fault, return 1; } -int ossl_quic_fault_set_datagram_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_datagram_cb datagramcb, - void *datagramcbarg) +int qtest_fault_set_datagram_listener(QTEST_FAULT *fault, + qtest_fault_on_datagram_cb datagramcb, + void *datagramcbarg) { fault->datagramcb = datagramcb; fault->datagramcbarg = datagramcbarg; @@ -731,7 +727,7 @@ int ossl_quic_fault_set_datagram_listener(OSSL_QUIC_FAULT *fault, } /* To be called from a datagram_listener callback */ -int ossl_quic_fault_resize_datagram(OSSL_QUIC_FAULT *fault, size_t newlen) +int qtest_fault_resize_datagram(QTEST_FAULT *fault, size_t newlen) { if (newlen > fault->msgalloc) return 0; diff --git a/test/helpers/quictestlib.h b/test/helpers/quictestlib.h index 165b3af79d..165551aa6a 100644 --- a/test/helpers/quictestlib.h +++ b/test/helpers/quictestlib.h @@ -11,18 +11,18 @@ #include <internal/quic_tserver.h> /* Type to represent the Fault Injector */ -typedef struct ossl_quic_fault OSSL_QUIC_FAULT; +typedef struct qtest_fault QTEST_FAULT; /* * Structure representing a parsed EncryptedExtension message. Listeners can * make changes to the contents of structure objects as required and the fault * injector will reconstruct the message to be sent on */ -typedef struct ossl_qf_encrypted_extensions { +typedef struct qtest_fault_encrypted_extensions { /* EncryptedExtension messages just have an extensions block */ unsigned char *extensions; size_t extensionslen; -} OSSL_QF_ENCRYPTED_EXTENSIONS; +} QTEST_ENCRYPTED_EXTENSIONS; /* * Given an SSL_CTX for the client and filenames for the server certificate and @@ -31,12 +31,12 @@ typedef struct ossl_qf_encrypted_extensions { */ int qtest_create_quic_objects(SSL_CTX *clientctx, char *certfile, char *keyfile, QUIC_TSERVER **qtserv, SSL **cssl, - OSSL_QUIC_FAULT **fault); + QTEST_FAULT **fault); /* * Free up a Fault Injector instance */ -void ossl_quic_fault_free(OSSL_QUIC_FAULT *fault); +void qtest_fault_free(QTEST_FAULT *fault); /* * Run the TLS handshake to create a QUIC connection between the client and @@ -58,15 +58,15 @@ int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv); /* * Enable tests to listen for pre-encryption QUIC packets being sent */ -typedef int (*ossl_quic_fault_on_packet_plain_cb)(OSSL_QUIC_FAULT *fault, - QUIC_PKT_HDR *hdr, - unsigned char *buf, - size_t len, - void *cbarg); +typedef int (*qtest_fault_on_packet_plain_cb)(QTEST_FAULT *fault, + QUIC_PKT_HDR *hdr, + unsigned char *buf, + size_t len, + void *cbarg); -int ossl_quic_fault_set_packet_plain_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_packet_plain_cb pplaincb, - void *pplaincbarg); +int qtest_fault_set_packet_plain_listener(QTEST_FAULT *fault, + qtest_fault_on_packet_plain_cb pplaincb, + void *pplaincbarg); /* @@ -77,28 +77,28 @@ int ossl_quic_fault_set_packet_plain_listener(OSSL_QUIC_FAULT *fault, * This will fail if a large resize is attempted that exceeds the over * allocation. */ -int ossl_quic_fault_resize_plain_packet(OSSL_QUIC_FAULT *fault, size_t newlen); +int qtest_fault_resize_plain_packet(QTEST_FAULT *fault, size_t newlen); /* * Prepend frame data into a packet. To be called from a packet_plain_listener * callback */ -int ossl_quic_fault_prepend_frame(OSSL_QUIC_FAULT *fault, unsigned char *frame, - size_t frame_len); +int qtest_fault_prepend_frame(QTEST_FAULT *fault, unsigned char *frame, + size_t frame_len); /* * The general handshake message listener is sent the entire handshake message * data block, including the handshake header itself */ -typedef int (*ossl_quic_fault_on_handshake_cb)(OSSL_QUIC_FAULT *fault, - unsigned char *msg, - size_t msglen, - void *handshakecbarg); - -int ossl_quic_fault_set_handshake_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_handshake_cb handshakecb, +typedef int (*qtest_fault_on_handshake_cb)(QTEST_FAULT *fault, + unsigned char *msg, + size_t msglen, void *handshakecbarg); +int qtest_fault_set_handshake_listener(QTEST_FAULT *fault, + qtest_fault_on_handshake_cb handshakecb, + void *handshakecbarg); + /* * Helper function to be called from a handshake_listener callback if it wants * to resize the handshake message (either to add new data to it, or to truncate @@ -108,7 +108,7 @@ int ossl_quic_fault_set_handshake_listener(OSSL_QUIC_FAULT *fault, * This will fail if a large resize is attempted that exceeds the over * allocation. */ -int ossl_quic_fault_resize_handshake(OSSL_QUIC_FAULT *fault, size_t newlen); +int qtest_fault_resize_handshake(QTEST_FAULT *fault, size_t newlen); /* * TODO(QUIC): Add listeners for specifc types of frame here. E.g. we might @@ -121,14 +121,14 @@ int ossl_quic_fault_resize_handshake(OSSL_QUIC_FAULT *fault, size_t newlen); * listener these messages are pre-parsed and supplied with message specific * data and exclude the handshake header */ -typedef int (*ossl_quic_fault_on_enc_ext_cb)(OSSL_QUIC_FAULT *fault, - OSSL_QF_ENCRYPTED_EXTENSIONS *ee, - size_t eelen, - void *encextcbarg); +typedef int (*qtest_fault_on_enc_ext_cb)(QTEST_FAULT *fault, + QTEST_ENCRYPTED_EXTENSIONS *ee, + size_t eelen, + void *encextcbarg); -int ossl_quic_fault_set_hand_enc_ext_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_enc_ext_cb encextcb, - void *encextcbarg); +int qtest_fault_set_hand_enc_ext_listener(QTEST_FAULT *fault, + qtest_fault_on_enc_ext_cb encextcb, + void *encextcbarg); /* TODO(QUIC): Add listeners for other types of handshake message here */ @@ -141,7 +141,7 @@ int ossl_quic_fault_set_hand_enc_ext_listener(OSSL_QUIC_FAULT *fault, * address of the buffer. This will fail if a large resize is attempted that * exceeds the over allocation. */ -int ossl_quic_fault_resize_message(OSSL_QUIC_FAULT *fault, size_t newlen); +int qtest_fault_resize_message(QTEST_FAULT *fault, size_t newlen); /* * Helper function to delete an extension from an extension block. |exttype| is @@ -149,9 +149,9 @@ int ossl_quic_fault_resize_message(OSSL_QUIC_FAULT *fault, size_t newlen); * On entry |*extlen| contains the length of the extension block. It is updated * with the new length on exit. */ -int ossl_quic_fault_delete_extension(OSSL_QUIC_FAULT *fault, - unsigned int exttype, unsigned char *ext, - size_t *extlen); +int qtest_fault_delete_extension(QTEST_FAULT *fault, + unsigned int exttype, unsigned char *ext, + size_t *extlen); /* * TODO(QUIC): Add additional helper functions for querying extensions here (e.g. @@ -162,30 +162,30 @@ int ossl_quic_fault_delete_extension(OSSL_QUIC_FAULT *fault, /* * Enable tests to listen for post-encryption QUIC packets being sent */ -typedef int (*ossl_quic_fault_on_packet_cipher_cb)(OSSL_QUIC_FAULT *fault, - /* The parsed packet header */ - QUIC_PKT_HDR *hdr, - /* The packet payload data */ - unsigned char *buf, - /* Length of the payload */ - size_t len, - void *cbarg); +typedef int (*qtest_fault_on_packet_cipher_cb)(QTEST_FAULT *fault, + /* The parsed packet header */ + QUIC_PKT_HDR *hdr, + /* The packet payload data */ + unsigned char *buf, + /* Length of the payload */ + size_t len, + void *cbarg); -int ossl_quic_fault_set_packet_cipher_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_packet_cipher_cb pciphercb, - void *picphercbarg); +int qtest_fault_set_packet_cipher_listener(QTEST_FAULT *fault, + qtest_fault_on_packet_cipher_cb pciphercb, + void *picphercbarg); /* * Enable tests to listen for datagrams being sent */ -typedef int (*ossl_quic_fault_on_datagram_cb)(OSSL_QUIC_FAULT *fault, - BIO_MSG *m, - size_t stride, - void *cbarg); +typedef int (*qtest_fault_on_datagram_cb)(QTEST_FAULT *fault, + BIO_MSG *m, + size_t stride, + void *cbarg); -int ossl_quic_fault_set_datagram_listener(OSSL_QUIC_FAULT *fault, - ossl_quic_fault_on_datagram_cb datagramcb, - void *datagramcbarg); +int qtest_fault_set_datagram_listener(QTEST_FAULT *fault, + qtest_fault_on_datagram_cb datagramcb, + void *datagramcbarg); /* * To be called from a datagram_listener callback. The datagram buffer is over @@ -193,4 +193,4 @@ int ossl_quic_fault_set_datagram_listener(OSSL_QUIC_FAULT *fault, * address of the buffer. This will fail if a large resize is attempted that * exceeds the over allocation. */ -int ossl_quic_fault_resize_datagram(OSSL_QUIC_FAULT *fault, size_t newlen); +int qtest_fault_resize_datagram(QTEST_FAULT *fault, size_t newlen); |