mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-26 10:52:20 +01:00
Add message order sanity checks
Reorganize test_dtls tests to use TEST_DECL_GROUP Reorganize test_tls tests to use TEST_DECL_GROUP
This commit is contained in:
@@ -17525,6 +17525,15 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
if (!ssl->msgsReceived.got_server_hello ||
|
||||
ssl->msgsReceived.got_change_cipher ||
|
||||
ssl->msgsReceived.got_finished ||
|
||||
(!ssl->options.resuming &&
|
||||
!ssl->msgsReceived.got_server_hello_done)) {
|
||||
WOLFSSL_MSG("session_ticket received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
ssl->msgsReceived.got_session_ticket = 1;
|
||||
|
||||
break;
|
||||
@@ -17540,20 +17549,36 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
|
||||
#ifndef NO_WOLFSSL_CLIENT
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END) {
|
||||
if ( ssl->msgsReceived.got_server_hello == 0) {
|
||||
if (!ssl->msgsReceived.got_server_hello) {
|
||||
WOLFSSL_MSG("No ServerHello before Cert");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_certificate_status ||
|
||||
ssl->msgsReceived.got_server_key_exchange ||
|
||||
ssl->msgsReceived.got_certificate_request ||
|
||||
ssl->msgsReceived.got_server_hello_done) {
|
||||
WOLFSSL_MSG("Cert received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef NO_WOLFSSL_SERVER
|
||||
if (ssl->options.side == WOLFSSL_SERVER_END) {
|
||||
if ( ssl->msgsReceived.got_client_hello == 0) {
|
||||
if (!ssl->msgsReceived.got_client_hello) {
|
||||
WOLFSSL_MSG("No ClientHello before Cert");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_client_key_exchange ||
|
||||
ssl->msgsReceived.got_certificate_verify ||
|
||||
ssl->msgsReceived.got_change_cipher ||
|
||||
ssl->msgsReceived.got_finished) {
|
||||
WOLFSSL_MSG("Cert received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
@@ -17572,7 +17597,6 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
ssl->msgsReceived.got_certificate_status = 1;
|
||||
|
||||
if (ssl->msgsReceived.got_certificate == 0) {
|
||||
WOLFSSL_MSG("No Certificate before CertificateStatus");
|
||||
@@ -17584,7 +17608,15 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_server_key_exchange ||
|
||||
ssl->msgsReceived.got_certificate_request ||
|
||||
ssl->msgsReceived.got_server_hello_done) {
|
||||
WOLFSSL_MSG("CertificateStatus received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
|
||||
ssl->msgsReceived.got_certificate_status = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -17602,14 +17634,19 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
ssl->msgsReceived.got_server_key_exchange = 1;
|
||||
|
||||
if (ssl->msgsReceived.got_server_hello == 0) {
|
||||
WOLFSSL_MSG("No ServerHello before ServerKeyExchange");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_certificate_request ||
|
||||
ssl->msgsReceived.got_server_hello_done) {
|
||||
WOLFSSL_MSG("ServerKeyExchange received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
|
||||
ssl->msgsReceived.got_server_key_exchange = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -17627,6 +17664,16 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_server_hello == 0) {
|
||||
WOLFSSL_MSG("No ServerHello before CertificateRequest");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_server_hello_done) {
|
||||
WOLFSSL_MSG("CertificateRequest received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
ssl->msgsReceived.got_certificate_request = 1;
|
||||
|
||||
break;
|
||||
@@ -17746,13 +17793,18 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
ssl->msgsReceived.got_certificate_verify = 1;
|
||||
|
||||
if ( ssl->msgsReceived.got_certificate == 0) {
|
||||
WOLFSSL_MSG("No Cert before CertVerify");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_change_cipher ||
|
||||
ssl->msgsReceived.got_finished) {
|
||||
WOLFSSL_MSG("CertVerify received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
ssl->msgsReceived.got_certificate_verify = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -17770,13 +17822,19 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
WOLFSSL_ERROR_VERBOSE(DUPLICATE_MSG_E);
|
||||
return DUPLICATE_MSG_E;
|
||||
}
|
||||
ssl->msgsReceived.got_client_key_exchange = 1;
|
||||
|
||||
if (ssl->msgsReceived.got_client_hello == 0) {
|
||||
WOLFSSL_MSG("No ClientHello before ClientKeyExchange");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
if (ssl->msgsReceived.got_certificate_verify||
|
||||
ssl->msgsReceived.got_change_cipher ||
|
||||
ssl->msgsReceived.got_finished) {
|
||||
WOLFSSL_MSG("ClientKeyExchange received in wrong order");
|
||||
WOLFSSL_ERROR_VERBOSE(OUT_OF_ORDER_E);
|
||||
return OUT_OF_ORDER_E;
|
||||
}
|
||||
ssl->msgsReceived.got_client_key_exchange = 1;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -17795,13 +17853,12 @@ static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
ssl->msgsReceived.got_finished = 1;
|
||||
|
||||
if (ssl->msgsReceived.got_change_cipher == 0) {
|
||||
WOLFSSL_MSG("Finished received before ChangeCipher");
|
||||
WOLFSSL_ERROR_VERBOSE(NO_CHANGE_CIPHER_E);
|
||||
return NO_CHANGE_CIPHER_E;
|
||||
}
|
||||
ssl->msgsReceived.got_finished = 1;
|
||||
break;
|
||||
|
||||
case change_cipher_hs:
|
||||
|
||||
@@ -1850,7 +1850,7 @@ int wolfSSL_mutual_auth(WOLFSSL* ssl, int req)
|
||||
{
|
||||
if (ssl == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
if (ssl->options.side == WOLFSSL_SERVER_END)
|
||||
if (ssl->options.side == WOLFSSL_CLIENT_END)
|
||||
return SIDE_ERROR;
|
||||
|
||||
ssl->options.mutualAuth = (word16)req;
|
||||
|
||||
26
tests/api.c
26
tests/api.c
@@ -51380,13 +51380,6 @@ TEST_CASE testCases[] = {
|
||||
/* Can't memory test as client/server hangs. */
|
||||
TEST_DECL(test_dtls_msg_from_other_peer),
|
||||
TEST_DECL(test_dtls_ipv6_check),
|
||||
TEST_DECL(test_dtls_short_ciphertext),
|
||||
TEST_DECL(test_dtls12_record_length_mismatch),
|
||||
TEST_DECL(test_dtls12_short_read),
|
||||
TEST_DECL(test_dtls13_longer_length),
|
||||
TEST_DECL(test_dtls13_short_read),
|
||||
TEST_DECL(test_records_span_network_boundaries),
|
||||
TEST_DECL(test_dtls_record_cross_boundaries),
|
||||
TEST_DECL(test_wolfSSL_SCR_after_resumption),
|
||||
TEST_DECL(test_dtls_no_extensions),
|
||||
TEST_DECL(test_tls_alert_no_server_hello),
|
||||
@@ -51406,12 +51399,10 @@ TEST_CASE testCases[] = {
|
||||
TEST_DECL(test_dtls13_frag_ch_pq),
|
||||
TEST_DECL(test_dtls_empty_keyshare_with_cookie),
|
||||
TEST_DECL(test_dtls_old_seq_number),
|
||||
TEST_DECL(test_dtls12_basic_connection_id),
|
||||
TEST_DECL(test_dtls13_basic_connection_id),
|
||||
TEST_DECL(test_dtls12_missing_finished),
|
||||
TEST_DECL(test_dtls13_missing_finished_client),
|
||||
TEST_DECL(test_dtls13_missing_finished_server),
|
||||
TEST_DECL(test_wolfSSL_dtls_set_pending_peer),
|
||||
TEST_DTLS_DECLS,
|
||||
TEST_DECL(test_tls_multi_handshakes_one_record),
|
||||
TEST_DECL(test_write_dup),
|
||||
TEST_DECL(test_read_write_hs),
|
||||
@@ -51422,25 +51413,12 @@ TEST_CASE testCases[] = {
|
||||
TEST_DECL(test_wolfSSL_SendUserCanceled),
|
||||
TEST_DECL(test_wolfSSL_SSLDisableRead),
|
||||
TEST_DECL(test_wolfSSL_inject),
|
||||
TEST_DECL(test_wolfSSL_dtls_cid_parse),
|
||||
TEST_DECL(test_dtls13_epochs),
|
||||
TEST_DECL(test_dtls_rtx_across_epoch_change),
|
||||
TEST_DECL(test_dtls_drop_client_ack),
|
||||
TEST_DECL(test_dtls_bogus_finished_epoch_zero),
|
||||
TEST_DECL(test_dtls_replay),
|
||||
TEST_DECL(test_dtls_srtp),
|
||||
TEST_DECL(test_dtls_timeout),
|
||||
TEST_DECL(test_dtls13_ack_order),
|
||||
TEST_DECL(test_dtls_version_checking),
|
||||
TEST_DECL(test_ocsp_status_callback),
|
||||
TEST_DECL(test_ocsp_basic_verify),
|
||||
TEST_DECL(test_ocsp_response_parsing),
|
||||
TEST_DECL(test_ocsp_certid_enc_dec),
|
||||
TEST_DECL(test_ocsp_tls_cert_cb),
|
||||
TEST_DECL(test_tls12_unexpected_ccs),
|
||||
TEST_DECL(test_tls13_unexpected_ccs),
|
||||
TEST_DECL(test_tls12_curve_intersection),
|
||||
TEST_DECL(test_tls13_curve_intersection),
|
||||
TEST_TLS_DECLS,
|
||||
TEST_DECL(test_wc_DhSetNamedKey),
|
||||
/* This test needs to stay at the end to clean up any caches allocated. */
|
||||
TEST_DECL(test_wolfSSL_Cleanup)
|
||||
|
||||
@@ -1700,3 +1700,190 @@ int test_dtls_timeout(void)
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_dtls_certreq_order(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && defined(WOLFSSL_DTLS) && \
|
||||
!defined(WOLFSSL_NO_TLS12) && defined(HAVE_AESGCM) && \
|
||||
defined(WOLFSSL_AES_128) && !defined(NO_SHA256) && !defined(NO_RSA) && \
|
||||
!defined(NO_DH)
|
||||
/* This test checks that a certificate request message
|
||||
* received before server certificate message is properly detected.
|
||||
* The binary is taken from https://github.com/wolfSSL/wolfssl/issues/9198
|
||||
*/
|
||||
static const unsigned char certreq_before_cert_bin[] = {
|
||||
0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x39, 0x02, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x2d, 0xfe, 0xfd, 0x48, 0xc0, 0xd5, 0xf2, 0x60, 0xb4, 0x20, 0xbb, 0x38,
|
||||
0x51, 0xd9, 0xd4, 0x7a, 0xcb, 0x93, 0x3d, 0xbe, 0x70, 0x39, 0x9b, 0xf6,
|
||||
0xc9, 0x2d, 0xa3, 0x3a, 0xf0, 0x1d, 0x4f, 0xb7, 0x70, 0xe9, 0x8c, 0x00,
|
||||
0x00, 0x9e, 0x00, 0x00, 0x05, 0x00, 0x0f, 0x00, 0x01, 0x01, 0x16, 0xfe,
|
||||
0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x3a, 0x0d,
|
||||
0x00, 0x00, 0x2e, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2e, 0x01,
|
||||
0x01, 0x00, 0x28, 0x02, 0x02, 0x03, 0x02, 0x04, 0x02, 0x05, 0x02, 0x06,
|
||||
0x02, 0x01, 0x01, 0x02, 0x01, 0x03, 0x01, 0x04, 0x01, 0x05, 0x01, 0x06,
|
||||
0x01, 0x02, 0x03, 0x03, 0x03, 0x04, 0x03, 0x05, 0x03, 0x06, 0x03, 0x08,
|
||||
0x04, 0x08, 0x05, 0x08, 0x06, 0x07, 0x08, 0x00, 0x00, 0x16, 0xfe, 0xfd,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x2b, 0x0b, 0x00,
|
||||
0x03, 0x1f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1f, 0x00, 0x03,
|
||||
0x1c, 0x00, 0x03, 0x19, 0x30, 0x82, 0x03, 0x15, 0x30, 0x82, 0x01, 0xfd,
|
||||
0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x14, 0x40, 0xe7, 0x6e, 0x85, 0x66,
|
||||
0x7c, 0x3f, 0x04, 0x87, 0x4c, 0x3f, 0x94, 0x21, 0x6d, 0x21, 0x65, 0xa5,
|
||||
0x28, 0xa7, 0x38, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
|
||||
0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x1a, 0x31, 0x18, 0x30, 0x16,
|
||||
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x64, 0x74, 0x6c, 0x73, 0x2d,
|
||||
0x66, 0x75, 0x7a, 0x7a, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1e,
|
||||
0x17, 0x0d, 0x32, 0x34, 0x30, 0x36, 0x30, 0x36, 0x31, 0x32, 0x31, 0x33,
|
||||
0x30, 0x33, 0x5a, 0x17, 0x0d, 0x33, 0x38, 0x30, 0x32, 0x31, 0x33, 0x31,
|
||||
0x32, 0x31, 0x33, 0x30, 0x33, 0x5a, 0x30, 0x1a, 0x31, 0x18, 0x30, 0x16,
|
||||
0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x64, 0x74, 0x6c, 0x73, 0x2d,
|
||||
0x66, 0x75, 0x7a, 0x7a, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x82,
|
||||
0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,
|
||||
0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01, 0x0f, 0x00, 0x30, 0x82,
|
||||
0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, 0x00, 0xbb, 0x2a, 0x06, 0xfa, 0xaf,
|
||||
0x9c, 0xb7, 0xeb, 0x33, 0xce, 0xde, 0xf6, 0xb6, 0x0a, 0x93, 0xb3, 0x97,
|
||||
0x7a, 0x36, 0x55, 0x89, 0xc2, 0xf5, 0x45, 0x84, 0x6d, 0x45, 0x25, 0x5c,
|
||||
0x4f, 0xa8, 0x8a, 0x41, 0x29, 0x5b, 0x71, 0x98, 0x6c, 0x63, 0xe7, 0xcf,
|
||||
0x7f, 0xb4, 0x9d, 0x06, 0x76, 0x60, 0x8c, 0x6a, 0x26, 0x47, 0x65, 0x5d,
|
||||
0x74, 0x7a, 0xb5, 0x40, 0x33, 0x61, 0xe0, 0x28, 0xed, 0xa6, 0x66, 0x6a,
|
||||
0x4b, 0x97, 0xaf, 0xae, 0x6c, 0xa1, 0xf2, 0xfc, 0xd0, 0xf1, 0x61, 0x98,
|
||||
0x05, 0x2a, 0x02, 0x42, 0x13, 0x06, 0x7c, 0x4a, 0x7e, 0x53, 0x01, 0x87,
|
||||
0x27, 0x6c, 0x41, 0xe8, 0xed, 0x6e, 0xb2, 0x45, 0x90, 0xe8, 0x93, 0xc0,
|
||||
0x20, 0xff, 0x64, 0xdf, 0x48, 0x57, 0xb9, 0x62, 0x8c, 0x14, 0x88, 0xc9,
|
||||
0x4a, 0x56, 0x3f, 0x5d, 0x9f, 0xeb, 0x1d, 0x79, 0x75, 0xfd, 0x24, 0xad,
|
||||
0xb6, 0x65, 0x1d, 0x53, 0x81, 0x5c, 0x67, 0xbe, 0x3a, 0x9d, 0xcd, 0xe1,
|
||||
0x47, 0xab, 0x8d, 0xd4, 0xa5, 0xbd, 0xa6, 0xd7, 0x60, 0xf9, 0x5c, 0x32,
|
||||
0x51, 0x65, 0x7e, 0x8b, 0xd6, 0xa1, 0x5b, 0xa2, 0xf5, 0x60, 0xaf, 0x29,
|
||||
0xff, 0x9f, 0x3a, 0xa4, 0xd0, 0x5d, 0x6e, 0x96, 0x09, 0xe8, 0xcf, 0xc3,
|
||||
0xe1, 0xe8, 0x5a, 0x82, 0xce, 0x9a, 0x3c, 0xc6, 0xbb, 0xe5, 0x4c, 0xa8,
|
||||
0xa4, 0xb0, 0xfd, 0x86, 0x06, 0x8b, 0x3f, 0x7e, 0x38, 0xe4, 0x06, 0xdf,
|
||||
0xf7, 0x9c, 0xc6, 0x8b, 0x1d, 0xb5, 0xad, 0x7a, 0x91, 0x5f, 0x64, 0xa5,
|
||||
0x69, 0xc8, 0x7b, 0x77, 0x32, 0x71, 0x8f, 0x73, 0x82, 0xd2, 0x21, 0xe8,
|
||||
0xa8, 0x81, 0xfe, 0x76, 0x7f, 0x20, 0xd1, 0xb6, 0x42, 0x9e, 0xaf, 0x60,
|
||||
0x85, 0x47, 0xf5, 0xfe, 0x9f, 0x85, 0xbf, 0xb0, 0x11, 0xb7, 0xf7, 0x83,
|
||||
0x0d, 0x80, 0x63, 0xa0, 0xf7, 0x0c, 0x2c, 0x83, 0x12, 0xa9, 0x0f, 0x02,
|
||||
0x03, 0x01, 0x00, 0x01, 0xa3, 0x53, 0x30, 0x51, 0x30, 0x1d, 0x06, 0x03,
|
||||
0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x2a, 0xb5, 0x00, 0x45, 0x06,
|
||||
0x08, 0xef, 0xe5, 0xfa, 0x78, 0x19, 0x47, 0x5b, 0x04, 0x40, 0x18, 0xf3,
|
||||
0xeb, 0xab, 0x99, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18,
|
||||
0x30, 0x16, 0x80, 0x14, 0x2a, 0xb5, 0x00, 0x45, 0x06, 0x08, 0xef, 0xe5,
|
||||
0xfa, 0x78, 0x19, 0x47, 0x5b, 0x04, 0x40, 0x18, 0xf3, 0xeb, 0xab, 0x99,
|
||||
0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x05,
|
||||
0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48,
|
||||
0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x01, 0x01,
|
||||
0x00, 0xa7, 0x58, 0x65, 0xfc, 0x60, 0x3e, 0xb7, 0x34, 0x82, 0xde, 0x04,
|
||||
0x06, 0x3d, 0x69, 0x62, 0x8a, 0x4c, 0xcc, 0xd6, 0x54, 0x72, 0x81, 0xcb,
|
||||
0x31, 0xdf, 0x63, 0xaf, 0x84, 0x27, 0x62, 0xbf, 0xe8, 0x6b, 0xf9, 0x81,
|
||||
0xd4, 0x5a, 0x98, 0x88, 0xae, 0x05, 0x5b, 0x2c, 0xa3, 0xf8, 0xb0, 0xde,
|
||||
0x9b, 0x44, 0xc7, 0x1d, 0x19, 0x52, 0x02, 0x02, 0xd9, 0x0e, 0x66, 0x7b,
|
||||
0x25, 0xdf, 0x95, 0x03, 0x5e, 0x4b, 0x15, 0xef, 0xda, 0x86, 0x2e, 0x8b,
|
||||
0xc4, 0xe7, 0x2d, 0x3f, 0x5f, 0xea, 0x1f, 0x13, 0x81, 0x2e, 0x6e, 0xf8,
|
||||
0x7f, 0x0b, 0x3b, 0x95, 0x4f, 0xb6, 0xb3, 0x91, 0xcf, 0x89, 0x52, 0xdb,
|
||||
0xb7, 0xb1, 0x5d, 0x79, 0xdf, 0x3a, 0xf3, 0xe2, 0x46, 0xc4, 0x04, 0xf3,
|
||||
0xf4, 0xf1, 0xc3, 0xf3, 0xa4, 0x98, 0x47, 0xae, 0x46, 0x99, 0x43, 0x4b,
|
||||
0x20, 0xba, 0x33, 0xaa, 0x7e, 0x2e, 0x80, 0x88, 0x25, 0x84, 0x73, 0x6d,
|
||||
0x44, 0x5f, 0x48, 0x57, 0x0a, 0xc4, 0x4a, 0x4d, 0xc4, 0xd1, 0x47, 0x5f,
|
||||
0x4f, 0xd5, 0xdb, 0x3e, 0x90, 0xbd, 0xe1, 0x6a, 0xcb, 0xe4, 0xf3, 0xe6,
|
||||
0x64, 0x26, 0xbd, 0xb6, 0x0b, 0x95, 0x6f, 0x4e, 0x1b, 0x09, 0x25, 0x68,
|
||||
0x93, 0xb6, 0xd0, 0xc2, 0xfc, 0xce, 0x8f, 0x64, 0xf5, 0x75, 0x50, 0x58,
|
||||
0xe5, 0x3e, 0x00, 0x01, 0xfd, 0x62, 0x37, 0xe1, 0x37, 0x1e, 0x9f, 0x97,
|
||||
0x88, 0xb1, 0xa9, 0x6f, 0xad, 0x93, 0x41, 0x01, 0xfb, 0x38, 0x24, 0xc8,
|
||||
0x08, 0xa0, 0x68, 0x4b, 0x34, 0x8b, 0x76, 0xea, 0x01, 0x62, 0x9d, 0xfa,
|
||||
0xdc, 0x91, 0x50, 0x47, 0x98, 0xec, 0x0c, 0x44, 0x58, 0xb6, 0x16, 0xa0,
|
||||
0x05, 0xf2, 0x94, 0x34, 0x6d, 0xcb, 0xbc, 0xe4, 0x58, 0xd6, 0x97, 0x9d,
|
||||
0x57, 0xa5, 0x5a, 0x65, 0xfa, 0xab, 0x94, 0x24, 0xbf, 0x06, 0x64, 0xc0,
|
||||
0xe5, 0x89, 0xe4, 0x2e, 0x46, 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x03, 0x17, 0x0c, 0x00, 0x03, 0x0b, 0x00, 0x03,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x0b, 0x01, 0x00, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, 0x9a,
|
||||
0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83,
|
||||
0xce, 0x2d, 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb,
|
||||
0xcc, 0x93, 0x9d, 0xce, 0x24, 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63,
|
||||
0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, 0xae, 0xc4, 0x61, 0x7a,
|
||||
0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, 0x1f,
|
||||
0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3,
|
||||
0xb5, 0x57, 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70,
|
||||
0xe0, 0xe6, 0x8b, 0x77, 0xe2, 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72,
|
||||
0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, 0x30, 0xac, 0xca, 0x4f,
|
||||
0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, 0x61,
|
||||
0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7,
|
||||
0x60, 0xd7, 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4,
|
||||
0xae, 0x56, 0xed, 0xe7, 0x63, 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8,
|
||||
0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, 0xcd, 0xf7, 0xe2, 0xec,
|
||||
0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, 0x9c,
|
||||
0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83,
|
||||
0xc3, 0xfe, 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc,
|
||||
0x2e, 0xc2, 0x20, 0x05, 0xc5, 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2,
|
||||
0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, 0x88, 0x6b, 0x42, 0x38,
|
||||
0x61, 0x28, 0x5c, 0x97, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0x00, 0x01, 0x02, 0x01, 0x00, 0xea, 0x10, 0x0e, 0xb8, 0xc4, 0xc9, 0xc9,
|
||||
0x9a, 0x8c, 0x03, 0x04, 0x56, 0x4f, 0x3d, 0x2d, 0x64, 0x51, 0xc9, 0x1e,
|
||||
0xf7, 0x63, 0x06, 0x81, 0xca, 0x89, 0x5c, 0x81, 0xb9, 0x78, 0xe0, 0xf5,
|
||||
0x43, 0xe4, 0x47, 0x40, 0x8f, 0x0e, 0xab, 0x0e, 0xd0, 0xb4, 0x43, 0x92,
|
||||
0x2a, 0x03, 0x4a, 0x1f, 0x69, 0x7b, 0xc3, 0x0c, 0x13, 0x0d, 0xf3, 0xd8,
|
||||
0xaa, 0xd7, 0x1e, 0x0e, 0xf5, 0x09, 0x7d, 0xda, 0xc9, 0x7c, 0x16, 0xfd,
|
||||
0xe6, 0xbb, 0x2d, 0xc1, 0x12, 0x20, 0xad, 0x8f, 0x1b, 0x64, 0x79, 0xb9,
|
||||
0xbc, 0x26, 0x11, 0xec, 0x3d, 0x20, 0xa6, 0x18, 0x6c, 0xb3, 0x27, 0xbe,
|
||||
0x86, 0xde, 0x0e, 0x49, 0x8f, 0xc2, 0x0e, 0x86, 0x8b, 0x2a, 0xc7, 0x4c,
|
||||
0xb5, 0x09, 0xed, 0x94, 0x6d, 0xb6, 0x50, 0xfb, 0xc1, 0x8e, 0xd7, 0xce,
|
||||
0x58, 0xf8, 0xb0, 0x68, 0xbc, 0xcf, 0x28, 0xc5, 0x1c, 0xf3, 0x99, 0x17,
|
||||
0x22, 0xaa, 0x40, 0x28, 0x90, 0x78, 0x34, 0xe2, 0x0f, 0x28, 0x0d, 0x22,
|
||||
0xe1, 0x55, 0xcd, 0x90, 0x26, 0x84, 0xa0, 0xd8, 0xea, 0xd9, 0xe8, 0x83,
|
||||
0x43, 0x24, 0xef, 0x66, 0xa6, 0x7f, 0x9f, 0x56, 0x10, 0x6f, 0xc9, 0x13,
|
||||
0x2f, 0xb1, 0x00, 0x49, 0xc7, 0x88, 0x8d, 0xec, 0x55, 0xc1, 0xdb, 0x39,
|
||||
0xa2, 0x5e, 0xbd, 0xde, 0xb6, 0x0a, 0x1c, 0x1f, 0xa4, 0x1a, 0x93, 0xc2,
|
||||
0xee, 0x9c, 0x63, 0x3b, 0x09, 0xcf, 0xf6, 0x93, 0x83, 0xfe, 0xd7, 0x4d,
|
||||
0x35, 0xd3, 0x15, 0x74, 0x23, 0x5a, 0x33, 0xdc, 0x64, 0x9d, 0xba, 0x2a,
|
||||
0xb0, 0x63, 0x26, 0x17, 0x44, 0xe2, 0xfa, 0x41, 0xb1, 0xb2, 0xf2, 0x63,
|
||||
0xb2, 0x51, 0x50, 0xfc, 0x31, 0xc2, 0xd6, 0xda, 0x01, 0x18, 0xcf, 0xe8,
|
||||
0x9b, 0xed, 0x4c, 0x69, 0x38, 0xe1, 0xe2, 0x69, 0x53, 0xdc, 0x85, 0x40,
|
||||
0x4e, 0x9a, 0x1d, 0xe8, 0x2a, 0xe1, 0x27, 0xad, 0x8e, 0x03, 0x01, 0x01,
|
||||
0x00, 0xad, 0x55, 0xc0, 0xac, 0xbb, 0x32, 0x93, 0x86, 0xc6, 0xdf, 0x5d,
|
||||
0x58, 0x94, 0xba, 0x35, 0x81, 0x32, 0x54, 0x98, 0xdc, 0x85, 0x6f, 0x1e,
|
||||
0x41, 0xe4, 0x3d, 0x1e, 0x0d, 0x37, 0x85, 0x05, 0xd1, 0xf7, 0xb2, 0x3a,
|
||||
0xd5, 0xb1, 0x8c, 0x93, 0x20, 0x8a, 0x42, 0xf0, 0xc9, 0x86, 0xcc, 0xf4,
|
||||
0xa1, 0x17, 0x8d, 0x65, 0xd0, 0xea, 0x23, 0x9f, 0xf7, 0xcf, 0x3e, 0x7b,
|
||||
0x51, 0x55, 0xfe, 0x3d, 0x6c, 0x9e, 0x3e, 0x51, 0x39, 0xd8, 0xa0, 0xa0,
|
||||
0x8a, 0x6b, 0xd8, 0x4d, 0x41, 0x7f, 0x97, 0x5c, 0x8e, 0x25, 0x7b, 0x24,
|
||||
0x72, 0x1a, 0x46, 0xac, 0x8f, 0x8e, 0xd7, 0xe8, 0xa6, 0x31, 0x1e, 0x7c,
|
||||
0xd0, 0xa9, 0x31, 0x84, 0xa6, 0x60, 0x73, 0xb3, 0xb9, 0x26, 0xa3, 0x4e,
|
||||
0xd5, 0x03, 0x3f, 0xef, 0xaa, 0x5a, 0x41, 0x8d, 0x1f, 0x0b, 0xb6, 0x37,
|
||||
0x63, 0x9b, 0xa1, 0xfe, 0x43, 0x5b, 0x73, 0xa2, 0x5b, 0xce, 0x53, 0x61,
|
||||
0x05, 0x1f, 0x75, 0x35, 0xf1, 0x71, 0x5b, 0xf6, 0x60, 0x1e, 0xcc, 0x62,
|
||||
0xae, 0xca, 0xe3, 0x4f, 0xc0, 0xc0, 0xfd, 0xe1, 0x42, 0xc3, 0xbc, 0x29,
|
||||
0x84, 0x74, 0x30, 0x0a, 0x22, 0x69, 0x10, 0x3d, 0xb6, 0x7c, 0x54, 0xc7,
|
||||
0x54, 0xe2, 0xaf, 0x3a, 0xee, 0xa3, 0x05, 0xd4, 0x89, 0xa2, 0xc3, 0xa1,
|
||||
0x51, 0x45, 0x25, 0x8e, 0xc5, 0x5a, 0xc8, 0x75, 0x50, 0xd9, 0x98, 0x67,
|
||||
0x3c, 0xd2, 0xfa, 0x96, 0x6a, 0xaa, 0x1b, 0x0a, 0x29, 0x15, 0xfe, 0xd0,
|
||||
0xbb, 0x1a, 0xf5, 0xa4, 0xcd, 0xbe, 0xce, 0xa2, 0x3e, 0x0c, 0x03, 0x9c,
|
||||
0xab, 0x3a, 0x34, 0xe2, 0x0e, 0x0e, 0xa0, 0xb3, 0x9a, 0x2a, 0x3f, 0xa2,
|
||||
0x1e, 0xd3, 0x33, 0x38, 0x42, 0x6e, 0x65, 0xf8, 0xda, 0xfa, 0x90, 0x73,
|
||||
0xa5, 0x66, 0x84, 0xe0, 0xfe, 0x99, 0xe9, 0xc1, 0x94, 0x24, 0x04, 0x7f,
|
||||
0x05, 0xda, 0xc7, 0xcd, 0xce, 0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x04,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
WOLFSSL_CTX *ctx_c = NULL;
|
||||
WOLFSSL *ssl_c = NULL;
|
||||
struct test_memio_ctx test_ctx;
|
||||
|
||||
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
|
||||
|
||||
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, NULL, &ssl_c, NULL,
|
||||
wolfDTLSv1_2_client_method, NULL), 0);
|
||||
|
||||
/* start handshake, send first ClientHello */
|
||||
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WOLFSSL_ERROR_WANT_READ);
|
||||
ExpectIntEQ(test_memio_inject_message(&test_ctx, 1,
|
||||
(const char*)certreq_before_cert_bin,
|
||||
sizeof(certreq_before_cert_bin)), 0);
|
||||
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), OUT_OF_ORDER_E);
|
||||
|
||||
wolfSSL_free(ssl_c);
|
||||
wolfSSL_CTX_free(ctx_c);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
@@ -42,4 +42,28 @@ int test_dtls_bogus_finished_epoch_zero(void);
|
||||
int test_dtls_replay(void);
|
||||
int test_dtls_srtp(void);
|
||||
int test_dtls_timeout(void);
|
||||
int test_dtls_certreq_order(void);
|
||||
|
||||
#define TEST_DTLS_DECLS \
|
||||
TEST_DECL_GROUP("dtls", test_dtls12_basic_connection_id), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls13_basic_connection_id), \
|
||||
TEST_DECL_GROUP("dtls", test_wolfSSL_dtls_cid_parse), \
|
||||
TEST_DECL_GROUP("dtls", test_wolfSSL_dtls_set_pending_peer), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls13_epochs), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls13_ack_order), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_version_checking), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_short_ciphertext), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls12_record_length_mismatch), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls12_short_read), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls13_longer_length), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls13_short_read), \
|
||||
TEST_DECL_GROUP("dtls", test_records_span_network_boundaries), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_record_cross_boundaries), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_rtx_across_epoch_change), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_drop_client_ack), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_bogus_finished_epoch_zero), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_replay), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_srtp), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_certreq_order), \
|
||||
TEST_DECL_GROUP("dtls", test_dtls_timeout)
|
||||
#endif /* TESTS_API_DTLS_H */
|
||||
|
||||
@@ -32,6 +32,42 @@
|
||||
#include <tests/api/test_tls.h>
|
||||
|
||||
|
||||
int test_utils_memio_move_message(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES)
|
||||
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
|
||||
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
|
||||
struct test_memio_ctx test_ctx;
|
||||
|
||||
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
|
||||
|
||||
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
|
||||
wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0);
|
||||
wolfSSL_set_verify(ssl_s, WOLFSSL_VERIFY_PEER, NULL);
|
||||
/* start handshake, send first ClientHello */
|
||||
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WOLFSSL_ERROR_WANT_READ);
|
||||
/* send server's flight */
|
||||
ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_s, -1), WOLFSSL_ERROR_WANT_READ);
|
||||
/* Move messages around but they should be the same at the end */
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 1, 2), 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 2, 1), 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 1, 3), 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 3, 1), 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 0, 2), 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, 2, 0), 0);
|
||||
ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);
|
||||
|
||||
wolfSSL_free(ssl_c);
|
||||
wolfSSL_free(ssl_s);
|
||||
wolfSSL_CTX_free(ctx_c);
|
||||
wolfSSL_CTX_free(ctx_s);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
int test_tls12_unexpected_ccs(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
@@ -254,3 +290,56 @@ int test_tls13_curve_intersection(void) {
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
||||
int test_tls_certreq_order(void)
|
||||
{
|
||||
EXPECT_DECLS;
|
||||
#if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && \
|
||||
!defined(WOLFSSL_NO_TLS12) && defined(HAVE_AESGCM) && \
|
||||
defined(WOLFSSL_AES_256) && defined(WOLFSSL_SHA384) && !defined(NO_RSA) && \
|
||||
defined(HAVE_ECC)
|
||||
/* This test checks that a certificate request message
|
||||
* received before server certificate message is properly detected.
|
||||
*/
|
||||
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
|
||||
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
|
||||
struct test_memio_ctx test_ctx;
|
||||
int i = 0;
|
||||
const char* msg = NULL;
|
||||
int msgSz = 0;
|
||||
int certIdx = 0;
|
||||
int certReqIdx = 0;
|
||||
|
||||
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
|
||||
|
||||
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
|
||||
wolfTLSv1_2_client_method, wolfTLSv1_2_server_method), 0);
|
||||
wolfSSL_set_verify(ssl_s, WOLFSSL_VERIFY_PEER, NULL);
|
||||
|
||||
/* start handshake, send first ClientHello */
|
||||
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), WOLFSSL_ERROR_WANT_READ);
|
||||
/* send server's flight */
|
||||
ExpectIntEQ(wolfSSL_accept(ssl_s), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_s, -1), WOLFSSL_ERROR_WANT_READ);
|
||||
for (i = 0; test_memio_get_message(&test_ctx, 1, &msg, &msgSz, i) == 0; i++) {
|
||||
if (msg[5] == 11) /* cert */
|
||||
certIdx = i;
|
||||
if (msg[5] == 13) /* certreq */
|
||||
certReqIdx = i;
|
||||
}
|
||||
ExpectIntNE(certIdx, 0);
|
||||
ExpectIntNE(certReqIdx, 0);
|
||||
ExpectIntEQ(test_memio_move_message(&test_ctx, 1, certReqIdx, certIdx), 0);
|
||||
ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
|
||||
ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), OUT_OF_ORDER_E);
|
||||
|
||||
wolfSSL_free(ssl_c);
|
||||
wolfSSL_free(ssl_s);
|
||||
wolfSSL_CTX_free(ctx_c);
|
||||
wolfSSL_CTX_free(ctx_s);
|
||||
#endif
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,19 @@
|
||||
#ifndef TESTS_API_TEST_TLS_H
|
||||
#define TESTS_API_TEST_TLS_H
|
||||
|
||||
int test_utils_memio_move_message(void);
|
||||
int test_tls12_unexpected_ccs(void);
|
||||
int test_tls13_unexpected_ccs(void);
|
||||
int test_tls12_curve_intersection(void);
|
||||
int test_tls13_curve_intersection(void);
|
||||
int test_tls_certreq_order(void);
|
||||
|
||||
#define TEST_TLS_DECLS \
|
||||
TEST_DECL_GROUP("tls", test_utils_memio_move_message), \
|
||||
TEST_DECL_GROUP("tls", test_tls12_unexpected_ccs), \
|
||||
TEST_DECL_GROUP("tls", test_tls13_unexpected_ccs), \
|
||||
TEST_DECL_GROUP("tls", test_tls12_curve_intersection), \
|
||||
TEST_DECL_GROUP("tls", test_tls13_curve_intersection), \
|
||||
TEST_DECL_GROUP("tls", test_tls_certreq_order)
|
||||
|
||||
#endif /* TESTS_API_TEST_TLS_EMS_H */
|
||||
|
||||
@@ -407,6 +407,21 @@ int test_memio_inject_message(struct test_memio_ctx* ctx, int client,
|
||||
|
||||
int test_memio_copy_message(const struct test_memio_ctx *ctx, int client,
|
||||
char *out, int *out_sz, int msg_pos)
|
||||
{
|
||||
const char* buff = NULL;
|
||||
int buff_sz = 0;
|
||||
|
||||
if (test_memio_get_message(ctx, client, &buff, &buff_sz, msg_pos) != 0)
|
||||
return -1;
|
||||
if (*out_sz < buff_sz)
|
||||
return -1;
|
||||
XMEMCPY(out, buff, (size_t)buff_sz);
|
||||
*out_sz = buff_sz;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_memio_get_message(const struct test_memio_ctx *ctx, int client,
|
||||
const char **out, int *out_sz, int msg_pos)
|
||||
{
|
||||
int msg_count;
|
||||
const int* msg_sizes;
|
||||
@@ -426,17 +441,75 @@ int test_memio_copy_message(const struct test_memio_ctx *ctx, int client,
|
||||
if (msg_pos < 0 || msg_pos >= msg_count) {
|
||||
return -1;
|
||||
}
|
||||
if (*out_sz < msg_sizes[msg_pos]) {
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < msg_pos; i++) {
|
||||
buff += msg_sizes[i];
|
||||
}
|
||||
XMEMCPY(out, buff, (size_t)msg_sizes[msg_pos]);
|
||||
*out = (const char*)buff;
|
||||
*out_sz = msg_sizes[msg_pos];
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_memio_move_message(struct test_memio_ctx *ctx, int client,
|
||||
int msg_pos_in, int msg_pos_out)
|
||||
{
|
||||
int msg_count;
|
||||
int* msg_sizes;
|
||||
int i;
|
||||
byte* buff;
|
||||
byte* buff_in;
|
||||
byte* buff_out;
|
||||
int total_size = 0;
|
||||
int msg_in_size;
|
||||
|
||||
if (client) {
|
||||
buff = buff_in = buff_out = ctx->c_buff;
|
||||
msg_count = ctx->c_msg_count;
|
||||
msg_sizes = ctx->c_msg_sizes;
|
||||
}
|
||||
else {
|
||||
buff = buff_in = buff_out = ctx->s_buff;
|
||||
msg_count = ctx->s_msg_count;
|
||||
msg_sizes = ctx->s_msg_sizes;
|
||||
}
|
||||
if (msg_pos_in < 0 || msg_pos_in >= msg_count)
|
||||
return -1;
|
||||
if (msg_pos_out < 0 || msg_pos_out >= msg_count)
|
||||
msg_pos_out = msg_count-1;
|
||||
if (msg_pos_in == msg_pos_out)
|
||||
return 0;
|
||||
msg_in_size = msg_sizes[msg_pos_in];
|
||||
for (i = 0; i < msg_count; i++)
|
||||
total_size += msg_sizes[i];
|
||||
if (total_size + msg_in_size > TEST_MEMIO_BUF_SZ)
|
||||
return -1;
|
||||
for (i = 0; i < msg_pos_in; i++)
|
||||
buff_in += msg_sizes[i];
|
||||
for (i = 0; i < msg_pos_out + (msg_pos_out > msg_pos_in ? 1 : 0); i++)
|
||||
buff_out += msg_sizes[i];
|
||||
XMEMMOVE(buff_out + msg_in_size, buff_out,
|
||||
total_size - (buff_out - buff));
|
||||
total_size += msg_in_size;
|
||||
if (buff_in > buff_out)
|
||||
buff_in += msg_in_size;
|
||||
XMEMCPY(buff_out, buff_in, msg_in_size);
|
||||
XMEMMOVE(buff_in, buff_in + msg_in_size,
|
||||
total_size - (buff_in - buff) - msg_in_size);
|
||||
if (msg_pos_in < msg_pos_out) {
|
||||
XMEMMOVE(msg_sizes + msg_pos_in, msg_sizes + msg_pos_in + 1,
|
||||
sizeof(*msg_sizes) *
|
||||
((msg_sizes + msg_pos_out) - (msg_sizes + msg_pos_in)));
|
||||
msg_sizes[msg_pos_out] = msg_in_size;
|
||||
}
|
||||
else {
|
||||
XMEMMOVE(msg_sizes + msg_pos_out + 1, msg_sizes + msg_pos_out,
|
||||
sizeof(*msg_sizes) *
|
||||
((msg_sizes + msg_pos_in) - (msg_sizes + msg_pos_out)));
|
||||
msg_sizes[msg_pos_out] = msg_in_size;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_memio_drop_message(struct test_memio_ctx *ctx, int client, int msg_pos)
|
||||
{
|
||||
int *len;
|
||||
|
||||
@@ -68,6 +68,10 @@ void test_memio_clear_buffer(struct test_memio_ctx *ctx, int is_client);
|
||||
int test_memio_inject_message(struct test_memio_ctx *ctx, int client, const char *data, int sz);
|
||||
int test_memio_copy_message(const struct test_memio_ctx *ctx, int client,
|
||||
char *out, int *out_sz, int msg_pos);
|
||||
int test_memio_get_message(const struct test_memio_ctx *ctx, int client,
|
||||
const char **out, int *out_sz, int msg_pos);
|
||||
int test_memio_move_message(struct test_memio_ctx *ctx, int client,
|
||||
int msg_pos_in, int msg_pos_out);
|
||||
int test_memio_drop_message(struct test_memio_ctx *ctx, int client, int msg_pos);
|
||||
int test_memio_modify_message_len(struct test_memio_ctx *ctx, int client, int msg_pos, int new_len);
|
||||
int test_memio_remove_from_buffer(struct test_memio_ctx *ctx, int client, int off, int sz);
|
||||
|
||||
Reference in New Issue
Block a user