/*
- * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2022-2024 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
size_t extensionslen;
} QTEST_ENCRYPTED_EXTENSIONS;
+/* Flags for use with qtest_create_quic_objects() */
+
+/* Indicates whether we are using blocking mode or not */
+#define QTEST_FLAG_BLOCK (1 << 0)
+/* Use fake time rather than real time */
+#define QTEST_FLAG_FAKE_TIME (1 << 1)
+/* Introduce noise in the BIO */
+#define QTEST_FLAG_NOISE (1 << 2)
+/* Split datagrams such that each datagram contains one packet */
+#define QTEST_FLAG_PACKET_SPLIT (1 << 3)
+/* Turn on client side tracing */
+#define QTEST_FLAG_CLIENT_TRACE (1 << 4)
/*
* Given an SSL_CTX for the client and filenames for the server certificate and
* keyfile, create a server and client instances as well as a fault injector
- * instance. |block| indicates whether we are using blocking mode or not.
+ * instance. |flags| is the logical or of flags defined above, or 0 if none.
*/
int qtest_create_quic_objects(OSSL_LIB_CTX *libctx, SSL_CTX *clientctx,
- char *certfile, char *keyfile, int block,
- QUIC_TSERVER **qtserv, SSL **cssl,
- QTEST_FAULT **fault);
+ SSL_CTX *serverctx, char *certfile, char *keyfile,
+ int flags, QUIC_TSERVER **qtserv, SSL **cssl,
+ QTEST_FAULT **fault, BIO **tracebio);
+
+/* Where QTEST_FLAG_FAKE_TIME is used, add millis to the current time */
+void qtest_add_time(uint64_t millis);
+
+/* Starts time measurement */
+void qtest_start_stopwatch(void);
+/* Returns the duration from the start in millis */
+uint64_t qtest_get_stopwatch_time(void);
+
+QTEST_FAULT *qtest_create_injector(QUIC_TSERVER *ts);
+
+BIO_METHOD *qtest_get_bio_method(void);
/*
* Free up a Fault Injector instance
*/
int qtest_create_quic_connection(QUIC_TSERVER *qtserv, SSL *clientssl);
+/*
+ * Check if both client and server have no data to read and are waiting on a
+ * timeout. If so, wait until the timeout has expired.
+ */
+int qtest_wait_for_timeout(SSL *s, QUIC_TSERVER *qtserv);
+
+/*
+ * Same as qtest_create_quic_connection but will stop (successfully) if the
+ * clientssl indicates SSL_ERROR_WANT_XXX as specified by |wanterr|
+ */
+int qtest_create_quic_connection_ex(QUIC_TSERVER *qtserv, SSL *clientssl,
+ int wanterr);
+
/*
* Shutdown the client SSL object gracefully
*/
*/
int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv);
+/*
+ * Confirm the server has received a frame encoding error. Equivalent to calling
+ * qtest_check_server_transport_err with a code of QUIC_ERR_FRAME_ENCODING_ERROR
+ */
+int qtest_check_server_frame_encoding_err(QUIC_TSERVER *qtserv);
+
/*
* Enable tests to listen for pre-encryption QUIC packets being sent
*/
* Prepend frame data into a packet. To be called from a packet_plain_listener
* callback
*/
-int qtest_fault_prepend_frame(QTEST_FAULT *fault, unsigned char *frame,
+int qtest_fault_prepend_frame(QTEST_FAULT *fault, const unsigned char *frame,
size_t frame_len);
/*
int qtest_fault_resize_handshake(QTEST_FAULT *fault, size_t newlen);
/*
- * TODO(QUIC): Add listeners for specific types of frame here. E.g. we might
+ * Add listeners for specific types of frame here. E.g. we might
* expect to see an "ACK" frame listener which will be passed pre-parsed ack
* data that can be modified as required.
*/
qtest_fault_on_enc_ext_cb encextcb,
void *encextcbarg);
-/* TODO(QUIC): Add listeners for other types of handshake message here */
+/* Add listeners for other types of handshake message here */
/*
* Helper function to delete an extension from an extension block. |exttype| is
* the type of the extension to be deleted. |ext| points to the extension block.
* On entry |*extlen| contains the length of the extension block. It is updated
- * with the new length on exit.
+ * with the new length on exit. If old_ext is non-NULL, the deleted extension
+ * is appended to the given BUF_MEM.
*/
int qtest_fault_delete_extension(QTEST_FAULT *fault,
unsigned int exttype, unsigned char *ext,
- size_t *extlen);
+ size_t *extlen,
+ BUF_MEM *old_ext);
/*
- * TODO(QUIC): Add additional helper functions for querying extensions here (e.g.
+ * Add additional helper functions for querying extensions here (e.g.
* finding or adding them). We could also provide a "listener" API for listening
* for specific extension types
*/
* exceeds the over allocation.
*/
int qtest_fault_resize_datagram(QTEST_FAULT *fault, size_t newlen);
+
+/*
+ * Set bandwidth and noise rate on noisy dgram filter.
+ * Arguments with values of 0 mean no limit/no noise.
+ */
+
+int qtest_fault_set_bw_limit(QTEST_FAULT *fault,
+ size_t ctos_bw, size_t stoc_bw,
+ int noise_rate);
+
+/* Copy a BIO_MSG */
+int bio_msg_copy(BIO_MSG *dst, BIO_MSG *src);
+
+#define BIO_CTRL_NOISE_BACK_OFF 1001
+#define BIO_CTRL_NOISE_RATE 1002
+#define BIO_CTRL_NOISE_RECV_BANDWIDTH 1003
+#define BIO_CTRL_NOISE_SEND_BANDWIDTH 1004
+#define BIO_CTRL_NOISE_SET_NOW_CB 1005
+
+struct bio_noise_now_cb_st {
+ OSSL_TIME (*now_cb)(void *);
+ void *now_cb_arg;
+};
+
+/* BIO filter for simulating a noisy UDP socket */
+const BIO_METHOD *bio_f_noisy_dgram_filter(void);
+
+/* Free the BIO filter method object */
+void bio_f_noisy_dgram_filter_free(void);
+
+/*
+ * BIO filter for splitting QUIC datagrams containing multiple packets into
+ * individual datagrams.
+ */
+const BIO_METHOD *bio_f_pkt_split_dgram_filter(void);
+
+/* Free the BIO filter method object */
+void bio_f_pkt_split_dgram_filter_free(void);