| 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 "tls/s2n_tls.h" |
| 20 |
|
| 21 |
int main(int argc, char **argv) |
| 22 |
{ |
| 23 |
BEGIN_TEST(); |
| 24 |
|
| 25 |
|
| 26 |
{ |
| 27 |
DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER), s2n_connection_ptr_free); |
| 28 |
EXPECT_NOT_NULL(server_conn); |
| 29 |
server_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 30 |
server_conn->actual_protocol_version = S2N_TLS12; |
| 31 |
|
| 32 |
DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT), s2n_connection_ptr_free); |
| 33 |
EXPECT_NOT_NULL(client_conn); |
| 34 |
client_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 35 |
client_conn->actual_protocol_version = S2N_TLS12; |
| 36 |
|
| 37 |
|
| 38 |
POSIX_GUARD(s2n_prf_server_finished(client_conn)); |
| 39 |
|
| 40 |
EXPECT_EQUAL(server_conn->server, server_conn->initial); |
| 41 |
|
| 42 |
EXPECT_SUCCESS(s2n_server_finished_send(server_conn)); |
| 43 |
EXPECT_SUCCESS(s2n_stuffer_copy(&server_conn->handshake.io, &client_conn->handshake.io, |
| 44 |
s2n_stuffer_data_available(&server_conn->handshake.io))); |
| 45 |
EXPECT_SUCCESS(s2n_server_finished_recv(client_conn)); |
| 46 |
|
| 47 |
EXPECT_EQUAL(server_conn->server, server_conn->secure); |
| 48 |
}; |
| 49 |
|
| 50 |
|
| 51 |
{ |
| 52 |
DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER), s2n_connection_ptr_free); |
| 53 |
EXPECT_NOT_NULL(server_conn); |
| 54 |
server_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 55 |
server_conn->actual_protocol_version = S2N_TLS12; |
| 56 |
|
| 57 |
DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT), s2n_connection_ptr_free); |
| 58 |
EXPECT_NOT_NULL(client_conn); |
| 59 |
client_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 60 |
client_conn->actual_protocol_version = S2N_TLS12; |
| 61 |
|
| 62 |
|
| 63 |
POSIX_GUARD(s2n_prf_server_finished(client_conn)); |
| 64 |
client_conn->handshake.server_finished[0]++; |
| 65 |
|
| 66 |
EXPECT_SUCCESS(s2n_server_finished_send(server_conn)); |
| 67 |
EXPECT_SUCCESS(s2n_stuffer_copy(&server_conn->handshake.io, &client_conn->handshake.io, |
| 68 |
s2n_stuffer_data_available(&server_conn->handshake.io))); |
| 69 |
EXPECT_FAILURE_WITH_ERRNO(s2n_client_finished_recv(client_conn), S2N_ERR_BAD_MESSAGE); |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
{ |
| 74 |
DEFER_CLEANUP(struct s2n_connection *server_conn = s2n_connection_new(S2N_SERVER), s2n_connection_ptr_free); |
| 75 |
EXPECT_NOT_NULL(server_conn); |
| 76 |
server_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 77 |
server_conn->actual_protocol_version = S2N_TLS12; |
| 78 |
|
| 79 |
DEFER_CLEANUP(struct s2n_connection *client_conn = s2n_connection_new(S2N_CLIENT), s2n_connection_ptr_free); |
| 80 |
EXPECT_NOT_NULL(client_conn); |
| 81 |
client_conn->secure->cipher_suite = &s2n_ecdhe_rsa_with_aes_256_gcm_sha384; |
| 82 |
client_conn->actual_protocol_version = S2N_TLS12; |
| 83 |
|
| 84 |
|
| 85 |
POSIX_GUARD(s2n_prf_server_finished(client_conn)); |
| 86 |
client_conn->handshake.finished_len = 1; |
| 87 |
|
| 88 |
EXPECT_SUCCESS(s2n_server_finished_send(server_conn)); |
| 89 |
EXPECT_SUCCESS(s2n_stuffer_copy(&server_conn->handshake.io, &client_conn->handshake.io, |
| 90 |
s2n_stuffer_data_available(&server_conn->handshake.io))); |
| 91 |
EXPECT_FAILURE_WITH_ERRNO(s2n_client_finished_recv(client_conn), S2N_ERR_SAFETY); |
| 92 |
}; |
| 93 |
|
| 94 |
END_TEST(); |
| 95 |
} |