1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00
Files
wolfssl/tests/api/test_ssl_hs.h
Daniele Lacamera 467406a464 tests: corrupt the handshake in flight over memio
The error paths in internal.c are most of what is left uncovered there, and a
conforming pair of endpoints never enters them. Reaching them needs a peer
that sends something wrong -- not a transport.

test_memio already runs both endpoints through a byte buffer with credentials
from certs/, and both sides are ours, so the buffer between them can be edited
between rounds. test_tls_wire_mangle flips a bit at a chosen offset of a
chosen round, which selects which handshake message gets hit and where: record
type, record length, handshake type, handshake length, or inside the body.
test_tls_wire_sequence uses the harness's own drop, duplicate, reorder and
length-rewrite helpers, which reach the ordering and retransmit logic a byte
flip cannot -- a flipped byte still arrives once, in sequence, at the right
length.

Both assert only that a corrupted handshake fails rather than crashes; the
coverage is in the paths it takes on the way out. Both run in the ssl_hs
group, which five of the six protocol modules already measure.

internal.c 650/1722 -> 690/1722. The DTLS arms of both tests currently
contribute nothing -- see the commit that follows.
2026-09-14 17:44:45 +02:00

86 lines
4.2 KiB
C

/* test_ssl_hs.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_SSL_HS_H
#define TESTS_API_SSL_HS_H
int test_tls_wire_mangle(void);
int test_tls_wire_sequence(void);
#include <tests/api/api_decl.h>
int test_wolfSSL_state_string_long(void);
int test_wolfSSL_state_string_long_states(void);
int test_wolfSSL_set_connect_accept_state(void);
int test_wolfSSL_SSL_do_handshake(void);
int test_wolfSSL_SSL_in_init_hs(void);
int test_wolfSSL_is_init_finished(void);
int test_wolfSSL_SetHsDoneCb(void);
int test_wolfSSL_pk_callback_ctx(void);
int test_wolfSSL_set_accept_state_reinit(void);
int test_wolfSSL_set_accept_state_static_ecc(void);
int test_wolfSSL_negotiate_bad_args(void);
int test_wolfSSL_SSL_do_handshake_quic(void);
int test_wolfSSL_set_connect_state_dh(void);
int test_wolfSSL_dh_ctx_params_reuse(void);
int test_wolfSSL_dh_ctx_params_oom(void);
int test_wolfSSL_connect_bad_args(void);
int test_wolfSSL_accept_bad_args(void);
int test_wolfSSL_connect_step_failures(void);
int test_wolfSSL_accept_step_failures(void);
int test_wolfSSL_hs_send_buffered_fail(void);
int test_wolfSSL_hs_send_buffered_advance(void);
int test_wolfSSL_hs_retry_alert_fail(void);
int test_wolfSSL_connect_ex_no_side(void);
int test_wolfSSL_hs_done_cb_error(void);
int test_wolfSSL_hs_info_cb(void);
#define TEST_SSL_HS_DECLS \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_state_string_long), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_state_string_long_states), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_set_connect_accept_state), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_SSL_do_handshake), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_SSL_in_init_hs), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_is_init_finished), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_SetHsDoneCb), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_pk_callback_ctx), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_set_accept_state_reinit), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_set_accept_state_static_ecc), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_negotiate_bad_args), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_SSL_do_handshake_quic), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_set_connect_state_dh), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_dh_ctx_params_reuse), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_dh_ctx_params_oom), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_connect_bad_args), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_accept_bad_args), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_connect_step_failures), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_accept_step_failures), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_hs_send_buffered_fail), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_hs_send_buffered_advance), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_hs_retry_alert_fail), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_connect_ex_no_side), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_hs_done_cb_error), \
TEST_DECL_GROUP("ssl_hs", test_wolfSSL_hs_info_cb), \
TEST_DECL_GROUP("ssl_hs", test_tls_wire_mangle), \
TEST_DECL_GROUP("ssl_hs", test_tls_wire_sequence)
#endif /* TESTS_API_SSL_HS_H */