@@ -51,7 +51,7 @@ static int s2n_random_value_is_hello_retry(struct s2n_connection *conn)
5151{
5252 POSIX_ENSURE_REF (conn );
5353
54- POSIX_ENSURE (memcmp (hello_retry_req_random , conn -> handshake_params .server_random , S2N_TLS_RANDOM_DATA_LEN ) == 0 ,
54+ POSIX_ENSURE (s2n_constant_time_equals (hello_retry_req_random , conn -> handshake_params .server_random , S2N_TLS_RANDOM_DATA_LEN ),
5555 S2N_ERR_INVALID_HELLO_RETRY );
5656
5757 return S2N_SUCCESS ;
@@ -157,7 +157,7 @@ static int s2n_server_hello_parse(struct s2n_connection *conn)
157157 S2N_ERROR_IF (compression_method != S2N_TLS_COMPRESSION_METHOD_NULL , S2N_ERR_BAD_MESSAGE );
158158
159159 bool session_ids_match = session_id_len != 0 && session_id_len == conn -> session_id_len
160- && memcmp (session_id , conn -> session_id , session_id_len ) == 0 ;
160+ && s2n_constant_time_equals (session_id , conn -> session_id , session_id_len );
161161 if (!session_ids_match ) {
162162 conn -> ems_negotiated = false;
163163 }
@@ -234,7 +234,7 @@ static int s2n_server_hello_parse(struct s2n_connection *conn)
234234 if (session_ids_match ) {
235235 /* check if the resumed session state is valid */
236236 POSIX_ENSURE (conn -> resume_protocol_version == conn -> actual_protocol_version , S2N_ERR_BAD_MESSAGE );
237- POSIX_ENSURE (memcmp (conn -> secure -> cipher_suite -> iana_value , cipher_suite_wire , S2N_TLS_CIPHER_SUITE_LEN ) == 0 ,
237+ POSIX_ENSURE (s2n_constant_time_equals (conn -> secure -> cipher_suite -> iana_value , cipher_suite_wire , S2N_TLS_CIPHER_SUITE_LEN ),
238238 S2N_ERR_BAD_MESSAGE );
239239
240240 /* Session is resumed */
0 commit comments