diff options
author | Matt Caswell <matt@openssl.org> | 2023-07-12 14:54:46 +0100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2023-07-17 09:39:46 +1000 |
commit | 149c4f98168ba19432986e82d30d15bd41bae475 (patch) | |
tree | 1e1322511b2a5575d20986f667f1ac0f119b3c21 /test/helpers | |
parent | 33ef5fc2c2bf0b0587bfcba28f61329abd83be70 (diff) |
Add a test for a retry during the handshake
Test various scenarios for a write retry occuring during a handshake.
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21434)
Diffstat (limited to 'test/helpers')
-rw-r--r-- | test/helpers/ssltestlib.c | 14 | ||||
-rw-r--r-- | test/helpers/ssltestlib.h | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/test/helpers/ssltestlib.c b/test/helpers/ssltestlib.c index 0c31058b65..0c3a076ea9 100644 --- a/test/helpers/ssltestlib.c +++ b/test/helpers/ssltestlib.c @@ -36,6 +36,7 @@ static int tls_dump_puts(BIO *bp, const char *str); static BIO_METHOD *method_tls_dump = NULL; static BIO_METHOD *meth_mem = NULL; static BIO_METHOD *meth_always_retry = NULL; +static int retry_err = -1; /* Note: Not thread safe! */ const BIO_METHOD *bio_f_tls_dump_filter(void) @@ -754,16 +755,21 @@ static int always_retry_free(BIO *bio) return 1; } +void set_always_retry_err_val(int err) +{ + retry_err = err; +} + static int always_retry_read(BIO *bio, char *out, int outl) { BIO_set_retry_read(bio); - return -1; + return retry_err; } static int always_retry_write(BIO *bio, const char *in, int inl) { BIO_set_retry_write(bio); - return -1; + return retry_err; } static long always_retry_ctrl(BIO *bio, int cmd, long num, void *ptr) @@ -789,13 +795,13 @@ static long always_retry_ctrl(BIO *bio, int cmd, long num, void *ptr) static int always_retry_gets(BIO *bio, char *buf, int size) { BIO_set_retry_read(bio); - return -1; + return retry_err; } static int always_retry_puts(BIO *bio, const char *str) { BIO_set_retry_write(bio); - return -1; + return retry_err; } int create_ssl_ctx_pair(OSSL_LIB_CTX *libctx, const SSL_METHOD *sm, diff --git a/test/helpers/ssltestlib.h b/test/helpers/ssltestlib.h index 38cf161c86..defcb35115 100644 --- a/test/helpers/ssltestlib.h +++ b/test/helpers/ssltestlib.h @@ -36,6 +36,7 @@ void bio_s_mempacket_test_free(void); const BIO_METHOD *bio_s_always_retry(void); void bio_s_always_retry_free(void); +void set_always_retry_err_val(int err); /* Packet types - value 0 is reserved */ #define INJECT_PACKET 1 |