mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-08-24 15:33:28 +02:00
Review follow-up on the two preceding commits. Only skip the padding when the record content is actually consumed. The post-handshake auth advance ran on any pending return that left processReply at doProcessInit, which assumes the certificate_request was the last message in its record. Two states break that: a fragmented certificate_request makes DoTls13HandShakeMsg() rewind inOutIdx so the fragment can be reprocessed, and RFC 8446 section 5.1 lets a peer coalesce several handshake messages into one record, leaving the index inside the record. Adding padSz in either case points the index at record content. Both states are already mishandled without this series, since post-handshake auth forces processReply to doProcessInit regardless, so this is a narrower guard rather than a regression, and there is no memory safety consequence either way: the largest possible index is the end of the record. The new test mirrors the end of record check that follows the message handlers. Also restore buildArgsSet across the record size probe. The probe borrows buildMsgState and buildArgsSet from the suspended build; the previous commit put back only the first. FreeBuildMsgArgs() clears buildArgsSet unconditionally on the way out, and the resumed call skips the block that would set it again, so the flag stays clear for the rest of the record. That is currently harmless, because the only thing it guards is freeing a dynamically allocated IV and no cipher in the tree needs one, but it leaves the fix one field short of its own premise. Add test_record_size_preserves_build_msg_state, which parks a connection at BUILD_MSG_ENCRYPT with the arguments flag set, runs the probe, and requires both fields to survive. It fails without the restore and passes with it. Guard the post-handshake auth block on WOLFSSL_POST_HANDSHAKE_AUTH as well. The only code that leaves processReply at doProcessInit from inside DoTls13HandShakeMsg() is the post-handshake auth branch, which is itself behind that macro, so the check cannot fire without it. Say that the oversized record is rejected rather than that it overflows the buffer. BuildMessage() catches it and returns BUFFER_E; the old wording read like memory corruption. Verified with --enable-all --enable-asynccrypt-sw and with plain --enable-all, both warning free under the os-check CFLAGS. The two reproducers from the preceding commits still complete.
112 lines
6.1 KiB
C
112 lines
6.1 KiB
C
/* test_tls.h
|
|
*
|
|
* Copyright (C) 2006-2026 wolfSSL Inc.
|
|
*
|
|
* This file is part of wolfSSL.
|
|
*
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
|
*/
|
|
|
|
#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_tls_record_overflow_alert(void);
|
|
int test_tls12_curve_intersection(void);
|
|
int test_tls12_dhe_rsa_pss_sigalg(void);
|
|
int test_tls12_ske_sig_param_binding(void);
|
|
int test_tls12_bad_cv_sig_content(void);
|
|
int test_tls13_curve_intersection(void);
|
|
int test_tls_certreq_order(void);
|
|
int test_tls12_certreq_odd_sigalgs(void);
|
|
int test_tls12_bad_cv_sig_alg(void);
|
|
int test_tls12_no_null_compression(void);
|
|
int test_tls12_ec_point_formats_no_uncompressed(void);
|
|
int test_tls12_ec_point_formats_no_uncompressed_non_ecc(void);
|
|
int test_tls_fallback_scsv(void);
|
|
int test_dtls_fallback_scsv(void);
|
|
int test_dtls_fallback_scsv_no_downgrade(void);
|
|
int test_tls_fallback_scsv_no_downgrade(void);
|
|
int test_tls_fallback_scsv_no_downgrade_runtime_max(void);
|
|
int test_tls12_etm_failed_resumption(void);
|
|
int test_tls12_resume_ticket_wrong_suite(void);
|
|
int test_tls12_resume_ticket_decline_fallback(void);
|
|
int test_tls_set_session_min_downgrade(void);
|
|
int test_tls12_session_id_resumption_sni_mismatch(void);
|
|
int test_tls13_session_resumption_sni_mismatch(void);
|
|
int test_tls13_resumption_with_alpn(void);
|
|
int test_tls12_session_id_resumption_alpn_mismatch(void);
|
|
int test_tls13_session_resumption_alpn_mismatch(void);
|
|
int test_tls_set_curves_list_ecc_fallback(void);
|
|
int test_tls12_corrupted_finished(void);
|
|
int test_tls12_peerauth_failsafe(void);
|
|
int test_tls12_ecdhe_ecdsa_rsa_client_cert(void);
|
|
int test_tls12_ecdhe_rsa_ecdsa_client_cert(void);
|
|
int test_wolfSSL_alert_type_string(void);
|
|
int test_wolfSSL_alert_desc_string(void);
|
|
int test_record_size_matches_build_message(void);
|
|
int test_record_size_preserves_build_msg_state(void);
|
|
int test_record_size_cache_invalidated_on_renegotiation(void);
|
|
int test_wolfSSL_get_shared_ciphers(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_tls_record_overflow_alert), \
|
|
TEST_DECL_GROUP("tls", test_tls12_curve_intersection), \
|
|
TEST_DECL_GROUP("tls", test_tls12_dhe_rsa_pss_sigalg), \
|
|
TEST_DECL_GROUP("tls", test_tls12_ske_sig_param_binding), \
|
|
TEST_DECL_GROUP("tls", test_tls12_bad_cv_sig_content), \
|
|
TEST_DECL_GROUP("tls", test_tls13_curve_intersection), \
|
|
TEST_DECL_GROUP("tls", test_tls_certreq_order), \
|
|
TEST_DECL_GROUP("tls", test_tls12_certreq_odd_sigalgs), \
|
|
TEST_DECL_GROUP("tls", test_tls12_bad_cv_sig_alg), \
|
|
TEST_DECL_GROUP("tls", test_tls12_no_null_compression), \
|
|
TEST_DECL_GROUP("tls", test_tls12_ec_point_formats_no_uncompressed), \
|
|
TEST_DECL_GROUP("tls", \
|
|
test_tls12_ec_point_formats_no_uncompressed_non_ecc), \
|
|
TEST_DECL_GROUP("tls", test_tls_fallback_scsv), \
|
|
TEST_DECL_GROUP("tls", test_dtls_fallback_scsv), \
|
|
TEST_DECL_GROUP("tls", test_dtls_fallback_scsv_no_downgrade), \
|
|
TEST_DECL_GROUP("tls", test_tls_fallback_scsv_no_downgrade), \
|
|
TEST_DECL_GROUP("tls", test_tls_fallback_scsv_no_downgrade_runtime_max),\
|
|
TEST_DECL_GROUP("tls", test_tls12_etm_failed_resumption), \
|
|
TEST_DECL_GROUP("tls", test_tls12_resume_ticket_wrong_suite), \
|
|
TEST_DECL_GROUP("tls", test_tls12_resume_ticket_decline_fallback), \
|
|
TEST_DECL_GROUP("tls", test_tls_set_session_min_downgrade), \
|
|
TEST_DECL_GROUP("tls", test_tls12_session_id_resumption_sni_mismatch), \
|
|
TEST_DECL_GROUP("tls", test_tls13_session_resumption_sni_mismatch), \
|
|
TEST_DECL_GROUP("tls", test_tls13_resumption_with_alpn), \
|
|
TEST_DECL_GROUP("tls", test_tls12_session_id_resumption_alpn_mismatch),\
|
|
TEST_DECL_GROUP("tls", test_tls13_session_resumption_alpn_mismatch), \
|
|
TEST_DECL_GROUP("tls", test_tls_set_curves_list_ecc_fallback), \
|
|
TEST_DECL_GROUP("tls", test_tls12_corrupted_finished), \
|
|
TEST_DECL_GROUP("tls", test_tls12_peerauth_failsafe), \
|
|
TEST_DECL_GROUP("tls", test_tls12_ecdhe_ecdsa_rsa_client_cert), \
|
|
TEST_DECL_GROUP("tls", test_tls12_ecdhe_rsa_ecdsa_client_cert), \
|
|
TEST_DECL_GROUP("tls", test_wolfSSL_alert_type_string), \
|
|
TEST_DECL_GROUP("tls", test_wolfSSL_alert_desc_string), \
|
|
TEST_DECL_GROUP("tls", test_record_size_matches_build_message), \
|
|
TEST_DECL_GROUP("tls", \
|
|
test_record_size_preserves_build_msg_state), \
|
|
TEST_DECL_GROUP("tls", \
|
|
test_record_size_cache_invalidated_on_renegotiation), \
|
|
TEST_DECL_GROUP("tls", test_wolfSSL_get_shared_ciphers)
|
|
|
|
#endif /* TESTS_API_TEST_TLS_H */
|