Files
wolfssl/tests/api/test_chacha.h
T
Daniele Lacamera e2568cc39e tests: MC/DC decision coverage for chacha.c and poly1305.c
Per-module ISO 26262 MC/DC campaign (iso26262-mcdc-per-module). Adds
DecisionCoverage-style cases to tests/api/test_chacha.c and
test_poly1305.c, plus intel-dispatch white-box supplements mirroring
the aes/sha3 technique.

chacha.c: BEFORE 6/11 (54.55%) -> AFTER 13/13 (100%). Closed
wc_Chacha_SetIV/SetKey's NULL-argument independence pairs,
wc_Chacha_Process's input/output NULL-argument pairs (both the
portable-C and USE_INTEL_CHACHA_SPEEDUP physical copies), and the
(msglen>0 && ctx->left>0) leftover-block decision's msglen==0 side.
Also adds an unaligned-key SetKey case (XSTREAM_ALIGN), a half-length
key case, and a new test_wc_Chacha_XChachaSetKey covering
wc_XChacha_SetKey. Total rose from 11 to 13 once the intelasm variant
was fixed (see campaign notes): it carries its own physical copy of
the leftover decision that the portable-only union previously missed.

poly1305.c: BEFORE 10/14 (71.43%) -> AFTER 12/14 (85.71%). Closed
wc_Poly1305Update's (m==NULL && bytes>0) inner AND, both operands.
Also adds an addSz==0 case to wc_Poly1305_MAC and a
lenToPad==WC_POLY1305_PAD_SZ case to wc_Poly1305_Pad for API
robustness. The 2 remaining conditions are structural/dead-code
residuals: wc_Poly1305SetKey's compound key==NULL check is shadowed
by an earlier unconditional key==NULL guard a few lines above (dead
code); wc_Poly1305_Pad's paddingLen<WC_POLY1305_PAD_SZ operand is
always true whenever paddingLen>0 (paddingLen is a mod-16 value
bounded to 0..15). See campaign baselines.json for full detail.
2026-07-13 11:19:23 +02:00

47 lines
1.9 KiB
C

/* test_chacha.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 WOLFCRYPT_TEST_CHACHA_H
#define WOLFCRYPT_TEST_CHACHA_H
#include <tests/api/api_decl.h>
int test_wc_Chacha_SetKey(void);
int test_wc_Chacha_Process(void);
int test_wc_Chacha_Process_Chunking(void);
int test_wc_Chacha_MonteCarlo(void);
int test_wc_Chacha_CounterOverflow(void);
int test_wc_Chacha_InPlace(void);
int test_wc_Chacha_UnalignedBuffers(void);
int test_wc_Chacha_XChachaSetKey(void);
#define TEST_CHACHA_DECLS \
TEST_DECL_GROUP("chacha", test_wc_Chacha_SetKey), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_Process), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_Process_Chunking), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_MonteCarlo), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_CounterOverflow), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_InPlace), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_UnalignedBuffers), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_XChachaSetKey)
#endif /* WOLFCRYPT_TEST_CHACHA_H */