| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "api/s2n.h" |
| 17 |
#include "s2n_test.h" |
| 18 |
#include "testlib/s2n_testlib.h" |
| 19 |
#include "utils/s2n_result.h" |
| 20 |
|
| 21 |
bool s2n_custom_send_fn_called = false; |
| 22 |
static int s2n_expect_concurrent_error_send_fn(void *io_context, const uint8_t *buf, uint32_t len) |
| 23 |
{ |
| 24 |
struct s2n_connection *conn = (struct s2n_connection *) io_context; |
| 25 |
s2n_custom_send_fn_called = true; |
| 26 |
|
| 27 |
s2n_blocked_status blocked = S2N_NOT_BLOCKED; |
| 28 |
ssize_t result = s2n_negotiate(conn, &blocked); |
| 29 |
EXPECT_FAILURE_WITH_ERRNO(result, S2N_ERR_REENTRANCY); |
| 30 |
return result; |
| 31 |
} |
| 32 |
|
| 33 |
int main(int argc, char **argv) |
| 34 |
{ |
| 35 |
BEGIN_TEST(); |
| 36 |
|
| 37 |
|
| 38 |
{ |
| 39 |
|
| 40 |
struct s2n_connection *conn = NULL; |
| 41 |
EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_CLIENT)); |
| 42 |
EXPECT_OK(s2n_connection_set_tls12_security_policy(conn)); |
| 43 |
EXPECT_OK(s2n_connection_set_secrets(conn)); |
| 44 |
|
| 45 |
|
| 46 |
EXPECT_SUCCESS(s2n_connection_set_send_cb(conn, s2n_expect_concurrent_error_send_fn)); |
| 47 |
EXPECT_SUCCESS(s2n_connection_set_send_ctx(conn, (void *) conn)); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
s2n_custom_send_fn_called = false; |
| 53 |
s2n_blocked_status blocked = S2N_NOT_BLOCKED; |
| 54 |
EXPECT_FAILURE_WITH_ERRNO(s2n_negotiate(conn, &blocked), S2N_ERR_IO); |
| 55 |
EXPECT_TRUE(s2n_custom_send_fn_called); |
| 56 |
|
| 57 |
|
| 58 |
EXPECT_SUCCESS(s2n_connection_free(conn)); |
| 59 |
}; |
| 60 |
|
| 61 |
END_TEST(); |
| 62 |
} |