-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce8f060
commit 5adaf40
Showing
2 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#include "s2n_test.h" | ||
#include "testlib/s2n_testlib.h" | ||
|
||
|
||
int main(int argc, char **argv) | ||
{ | ||
BEGIN_TEST(); | ||
|
||
DEFER_CLEANUP(struct s2n_cert_chain_and_key *chain_and_key = NULL, s2n_cert_chain_and_key_ptr_free); | ||
EXPECT_SUCCESS(s2n_test_cert_chain_and_key_new(&chain_and_key, | ||
S2N_DEFAULT_TEST_CERT_CHAIN, S2N_DEFAULT_TEST_PRIVATE_KEY)); | ||
|
||
DEFER_CLEANUP(struct s2n_config *server_config = s2n_config_new(), | ||
s2n_config_ptr_free); | ||
EXPECT_NOT_NULL(server_config); | ||
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(server_config, "default_tls13")); | ||
EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(server_config, | ||
chain_and_key)); | ||
EXPECT_OK(s2n_resumption_test_ticket_key_setup(server_config)); | ||
|
||
DEFER_CLEANUP(struct s2n_config *client_config = s2n_config_new(), | ||
s2n_config_ptr_free); | ||
EXPECT_NOT_NULL(client_config); | ||
EXPECT_SUCCESS(s2n_config_set_session_tickets_onoff(client_config, 1)); | ||
EXPECT_SUCCESS(s2n_config_set_cipher_preferences(client_config, "default_tls13")); | ||
EXPECT_SUCCESS(s2n_config_set_verification_ca_location(client_config, S2N_DEFAULT_TEST_CERT_CHAIN, NULL)); | ||
|
||
{ | ||
DEFER_CLEANUP(struct s2n_connection *client = s2n_connection_new(S2N_CLIENT), | ||
s2n_connection_ptr_free); | ||
EXPECT_NOT_NULL(client); | ||
DEFER_CLEANUP(struct s2n_connection *server = s2n_connection_new(S2N_SERVER), | ||
s2n_connection_ptr_free); | ||
EXPECT_NOT_NULL(server); | ||
|
||
EXPECT_SUCCESS(s2n_set_server_name(client, "localhost")); | ||
|
||
EXPECT_SUCCESS(s2n_connection_set_config(client, client_config)); | ||
EXPECT_SUCCESS(s2n_connection_set_config(server, server_config)); | ||
|
||
DEFER_CLEANUP(struct s2n_test_io_stuffer_pair test_io = { 0 }, | ||
s2n_io_stuffer_pair_free); | ||
EXPECT_OK(s2n_io_stuffer_pair_init(&test_io)); | ||
EXPECT_OK(s2n_connections_set_io_stuffer_pair(client, server, &test_io)); | ||
|
||
EXPECT_SUCCESS(s2n_negotiate_test_server_and_client(server, client)); | ||
EXPECT_EQUAL(client->actual_protocol_version, S2N_TLS13); | ||
EXPECT_EQUAL(server->actual_protocol_version, S2N_TLS13); | ||
|
||
uint16_t tickets_sent = 0; | ||
EXPECT_SUCCESS(s2n_connection_get_tickets_sent(server, &tickets_sent)); | ||
EXPECT_EQUAL(tickets_sent, 1); | ||
|
||
s2n_blocked_status blocked = S2N_NOT_BLOCKED; | ||
uint8_t out = 0; | ||
EXPECT_FAILURE_WITH_ERRNO(s2n_recv(client, &out, 1, &blocked), S2N_ERR_IO_BLOCKED); | ||
uint8_t session_data[S2N_TLS12_SESSION_SIZE] = { 0 }; | ||
EXPECT_SUCCESS(s2n_connection_get_session(client, session_data, sizeof(session_data))); | ||
|
||
EXPECT_SUCCESS(s2n_connection_wipe(client)); | ||
EXPECT_SUCCESS(s2n_connection_wipe(server)); | ||
|
||
EXPECT_SUCCESS(s2n_connection_set_config(client, client_config)); | ||
EXPECT_SUCCESS(s2n_connection_set_config(server, server_config)); | ||
|
||
EXPECT_SUCCESS(s2n_connection_set_session(client, session_data, sizeof(session_data))); | ||
|
||
EXPECT_OK(s2n_connections_set_io_stuffer_pair(client, server, &test_io)); | ||
|
||
EXPECT_SUCCESS(s2n_negotiate_test_server_and_client(server, client)); | ||
EXPECT_EQUAL(client->actual_protocol_version, S2N_TLS13); | ||
EXPECT_EQUAL(server->actual_protocol_version, S2N_TLS13); | ||
|
||
EXPECT_FALSE(IS_FULL_HANDSHAKE(client)); | ||
EXPECT_FALSE(IS_FULL_HANDSHAKE(server)); | ||
} | ||
|
||
END_TEST(); | ||
} |