Skip to content

Commit 5c29ebe

Browse files
author
Boquan Fang
committed
address PR comments:
* Fix typos for temporary * use s2n_stuffer_data_available * add GUARD to the s2n_negotiate to write Client Hello
1 parent 371ae42 commit 5c29ebe

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crypto/s2n_ecc_evp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ int s2n_ecc_evp_write_params_point(struct s2n_ecc_evp_params *ecc_evp_params, st
434434
POSIX_GUARD(s2n_ecc_evp_calculate_point_length(point, group, &point_len));
435435
S2N_ERROR_IF(point_len != ecc_evp_params->negotiated_curve->share_size, S2N_ERR_ECDHE_SERIALIZING);
436436

437-
/* Use a temprorary stuffer copy to perform s2n_stuffer_raw_write, so the original stuffer won't be tainted */
437+
/* Use a temporary stuffer copy to perform s2n_stuffer_raw_write, so the original stuffer won't be tainted */
438438
POSIX_GUARD(s2n_stuffer_reserve_space(out, point_len));
439439
struct s2n_stuffer copy = *out;
440440

@@ -462,7 +462,7 @@ int s2n_ecc_evp_write_params(struct s2n_ecc_evp_params *ecc_evp_params, struct s
462462

463463
uint8_t key_share_size = ecc_evp_params->negotiated_curve->share_size;
464464

465-
/* Use a temprorary stuffer copy to perform s2n_stuffer_raw_write, so the original stuffer won't be tainted */
465+
/* Use a temporary stuffer copy to perform s2n_stuffer_raw_write, so the original stuffer won't be tainted */
466466
struct s2n_stuffer copy = *out;
467467

468468
/* Remember where the written data starts */

tests/unit/s2n_client_hello_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646

4747
#define CIPHER_SUITES_MAX_LENGTH (UINT16_MAX - 2)
4848
#define NUM_OF_CIPHER_SUITES_TO_DROP 150
49-
#define MAXIMUM_NUM_OF_CIPHER_SUITES (CIPHER_SUITES_MAX_LENGTH / S2N_TLS_CIPHER_SUITE_LEN)
49+
#define MAX_CIPHER_SUITE_COUNT (CIPHER_SUITES_MAX_LENGTH / S2N_TLS_CIPHER_SUITE_LEN)
5050
/* Drop 150 cipher suites from max, so that the total handshake message length won't exceed 64KB */
51-
#define REDUCED_CIPHER_SUITE_COUNT (MAXIMUM_NUM_OF_CIPHER_SUITES - NUM_OF_CIPHER_SUITES_TO_DROP)
51+
#define REDUCED_CIPHER_SUITE_COUNT (MAX_CIPHER_SUITE_COUNT - NUM_OF_CIPHER_SUITES_TO_DROP)
5252
/* Reducing cipher suites by 150 creates approximately 300 bytes margin below maximum handshake length */
5353
#define ESTIMATED_MAX_HANDSHAKE_LENGTH_MARGIN (NUM_OF_CIPHER_SUITES_TO_DROP * S2N_TLS_CIPHER_SUITE_LEN)
5454

@@ -2036,9 +2036,9 @@ int main(int argc, char **argv)
20362036

20372037
EXPECT_SUCCESS(s2n_config_add_cert_chain_and_key_to_store(server_config, chain_and_key));
20382038

2039-
struct s2n_cipher_suite *test_cipher_suites[MAXIMUM_NUM_OF_CIPHER_SUITES] = { 0 };
2039+
struct s2n_cipher_suite *test_cipher_suites[MAX_CIPHER_SUITE_COUNT] = { 0 };
20402040

2041-
for (int i = 0; i < MAXIMUM_NUM_OF_CIPHER_SUITES; i++) {
2041+
for (int i = 0; i < MAX_CIPHER_SUITE_COUNT; i++) {
20422042
test_cipher_suites[i] = &s2n_rsa_with_aes_128_gcm_sha256;
20432043
}
20442044

@@ -2082,10 +2082,10 @@ int main(int argc, char **argv)
20822082
s2n_blocked_status blocked = S2N_NOT_BLOCKED;
20832083

20842084
/* Write Client Hello into io_pair.server_in */
2085-
s2n_negotiate(client, &blocked);
2085+
EXPECT_FAILURE_WITH_ERRNO(s2n_negotiate(client, &blocked), S2N_ERR_IO_BLOCKED);
20862086

20872087
/* The size of Client Hello exceeds S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH */
2088-
EXPECT_TRUE(io_pair.server_in.write_cursor > S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH);
2088+
EXPECT_TRUE(s2n_stuffer_data_available(&io_pair.server_in) > S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH);
20892089
EXPECT_ERROR_WITH_ERRNO(s2n_negotiate_test_server_and_client_until_message(server, client, SERVER_HELLO), S2N_ERR_BAD_MESSAGE);
20902090

20912091
/* handshake.io shouldn't be tainted after sending and receiving large client hello */

0 commit comments

Comments
 (0)