| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include <errno.h> |
| 17 |
#include <fcntl.h> |
| 18 |
#include <stdint.h> |
| 19 |
#include <stdlib.h> |
| 20 |
#include <unistd.h> |
| 21 |
|
| 22 |
#include "api/s2n.h" |
| 23 |
#include "crypto/s2n_fips.h" |
| 24 |
#include "crypto/s2n_rsa_pss.h" |
| 25 |
#include "s2n_test.h" |
| 26 |
#include "testlib/s2n_testlib.h" |
| 27 |
#include "tls/s2n_cipher_preferences.h" |
| 28 |
#include "tls/s2n_cipher_suites.h" |
| 29 |
#include "tls/s2n_connection.h" |
| 30 |
#include "tls/s2n_handshake.h" |
| 31 |
#include "tls/s2n_handshake_io.c" |
| 32 |
#include "tls/s2n_tls13.h" |
| 33 |
#include "utils/s2n_safety.h" |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
uint8_t record[] = { |
| 39 |
|
| 40 |
0x16, |
| 41 |
|
| 42 |
0x03, 0x03, |
| 43 |
|
| 44 |
0x00, 0x05, |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
0x00, |
| 50 |
|
| 51 |
0x00, 0x00, 0x01, |
| 52 |
|
| 53 |
0x00 |
| 54 |
}; |
| 55 |
static int amt_written = 0; |
| 56 |
|
| 57 |
int s2n_app_data_in_handshake_record_recv_fn(void *io_context, uint8_t *buf, uint32_t len) |
| 58 |
{ |
| 59 |
int amt_left = sizeof(record) - amt_written; |
| 60 |
int to_write = S2N_MIN(len, amt_left); |
| 61 |
POSIX_CHECKED_MEMCPY(buf, record + amt_written, to_write); |
| 62 |
amt_written += to_write; |
| 63 |
return to_write; |
| 64 |
} |
| 65 |
|
| 66 |
int main(int argc, char **argv) |
| 67 |
{ |
| 68 |
BEGIN_TEST(); |
| 69 |
EXPECT_SUCCESS(s2n_disable_tls13_in_test()); |
| 70 |
|
| 71 |
struct s2n_connection *conn = NULL; |
| 72 |
EXPECT_NOT_NULL(conn = s2n_connection_new(S2N_SERVER)); |
| 73 |
|
| 74 |
|
| 75 |
conn->handshake.handshake_type = NEGOTIATED | FULL_HANDSHAKE | TLS12_PERFECT_FORWARD_SECRECY; |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
conn->handshake.message_number = 10; |
| 80 |
conn->actual_protocol_version = S2N_TLS12; |
| 81 |
|
| 82 |
s2n_connection_set_recv_cb(conn, s2n_app_data_in_handshake_record_recv_fn); |
| 83 |
|
| 84 |
EXPECT_FAILURE_WITH_ERRNO(s2n_handshake_read_io(conn), S2N_ERR_BAD_MESSAGE); |
| 85 |
|
| 86 |
s2n_connection_free(conn); |
| 87 |
END_TEST(); |
| 88 |
} |