Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
934410d
tests/unit-mcdc: add SHA intel-dispatch white-box supplements
danielinux Jul 9, 2026
b50f575
tests: cover the AES-EAX streaming Update authIn arg-check
danielinux Jul 9, 2026
931d72a
sha: reorder update arg guards to make the empty-update decision cove…
danielinux Jul 9, 2026
8b673a1
tests/unit-mcdc: aarch64 hw-crypto white-box supplements (qemu lane)
danielinux Jul 9, 2026
0cdcf80
tests/rsa: MC/DC decision + white-box coverage for wolfcrypt/src/rsa.c
danielinux Jul 9, 2026
1155172
tests: add sp_int.c (sp-math module) MC/DC DecisionCoverage + white-box
danielinux Jul 10, 2026
8344f45
tests/ecc: MC/DC decision coverage + white-box for wolfcrypt/src/ecc.c
danielinux Jul 10, 2026
05b68d8
tests: MC/DC decision coverage for chacha.c and poly1305.c
danielinux Jul 10, 2026
c049508
tests: MC/DC decision coverage for hmac.c and cmac.c
danielinux Jul 10, 2026
d7b8c0c
tests: MC/DC decision coverage for curve25519.c and ed25519.c
danielinux Jul 10, 2026
1ebb133
tests: MC/DC decision coverage for dh.c and dsa.c
danielinux Jul 10, 2026
9104025
tests: MC/DC decision coverage for random.c (Hash_DRBG + seed layer)
danielinux Jul 10, 2026
6836c95
tests: fix warning-clean builds
danielinux Jul 10, 2026
f8fe647
tests: fix CI regressions
danielinux Jul 10, 2026
8c2b645
tests/ecc: fix link failures in shared/non-public-mp builds
danielinux Jul 10, 2026
b8e4ba5
tests: fix more CI config-specific build failures
danielinux Jul 10, 2026
06ee755
tests/wolfmath: guard SpInt decision-coverage on full sp_int availabi…
danielinux Jul 10, 2026
ccaed58
tests: avoid WOLFSSL_CHECK_MEM_ZERO false-positives in rsa/dh tests
danielinux Jul 10, 2026
2286b0e
tests/dh: skip GenerateParams test under bare WOLFSSL_SP_MATH
danielinux Jul 10, 2026
368423a
tests/dh: run DhImportKeyPair test under WOLFSSL_CHECK_MEM_ZERO again
danielinux Jul 10, 2026
a6a1215
tests/rsa: run bad-size wc_MakeRsaKey checks under WOLFSSL_CHECK_MEM_…
danielinux Jul 10, 2026
0d62149
tests: align dsa/curve25519 MC/DC assertions with PR-10875 source fixes
danielinux Jul 10, 2026
5943b8e
tests: guard frozen-module MC/DC tests against FIPS/selftest builds
danielinux Jul 10, 2026
fbea2a4
tests/ecc: guard EccDecisionCoverage3 against FIPS/selftest builds
danielinux Jul 10, 2026
c3c2a87
tests: guard DsaSign_ex / DhGenerateParams tests for the frozen selft…
danielinux Jul 10, 2026
7b9ba1e
tests/cmac: guard tooSmallMacSz declaration for the frozen selftest API
danielinux Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/api/test_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -8076,6 +8076,14 @@ int test_wc_AesEaxArgMcdc(void)
/* cond: in == NULL */
ExpectIntEQ(wc_AesEaxEncryptUpdate(&eax, out, NULL, sizeof(in), NULL, 0),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* cond: authInSz > 0 && authIn == NULL -> BAD_FUNC_ARG (both the
* authInSz>0 and authIn==NULL conditions true). */
ExpectIntEQ(wc_AesEaxEncryptUpdate(&eax, out, in, sizeof(in), NULL,
sizeof(in)), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* cond: authInSz > 0 && authIn != NULL -> valid (authIn==NULL false while
* authInSz>0 true), completing that pair. */
ExpectIntEQ(wc_AesEaxEncryptUpdate(&eax, out, in, sizeof(in), in,
sizeof(in)), 0);
ExpectIntEQ(wc_AesEaxFree(&eax), 0);

/* ---- wc_AesEaxDecryptUpdate(): eax/out/in OR-chain ---- */
Expand All @@ -8093,6 +8101,12 @@ int test_wc_AesEaxArgMcdc(void)
/* cond: in == NULL */
ExpectIntEQ(wc_AesEaxDecryptUpdate(&eax, out, NULL, sizeof(in), NULL, 0),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* cond: authInSz > 0 && authIn == NULL -> BAD_FUNC_ARG. */
ExpectIntEQ(wc_AesEaxDecryptUpdate(&eax, out, in, sizeof(in), NULL,
sizeof(in)), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* cond: authInSz > 0 && authIn != NULL -> valid, completing the pair. */
ExpectIntEQ(wc_AesEaxDecryptUpdate(&eax, out, in, sizeof(in), in,
sizeof(in)), 0);
ExpectIntEQ(wc_AesEaxFree(&eax), 0);

/* ---- wc_AesEaxEncryptFinal(): authTag == NULL / authTagSz == 0 ---- */
Expand Down
88 changes: 87 additions & 1 deletion tests/api/test_chacha.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ int test_wc_Chacha_SetKey(void)
/* Test bad args. */
ExpectIntEQ(wc_Chacha_SetIV(NULL, cipher, 0),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* ctx valid, inIv NULL: independence pair for the SetIV OR's 2nd arg. */
ExpectIntEQ(wc_Chacha_SetIV(&ctx, NULL, 0),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));

/* ctx valid, key NULL: independence pair for the SetKey OR's 2nd arg. */
ExpectIntEQ(wc_Chacha_SetKey(&ctx, NULL, keySz),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
/* half-length key (16 bytes / tau constant) is also valid. */
ExpectIntEQ(wc_Chacha_SetKey(&ctx, key, CHACHA_MAX_KEY_SZ / 2), 0);

/* misaligned key pointer: exercises the (wc_ptr_t)key % 4 realignment
* decision in wc_Chacha_SetKey when XSTREAM_ALIGN is forced on (the
* xstream_align campaign variant). settings.h compiles XSTREAM_ALIGN out
* by default on x86_64/i386/ia64 (NO_XSTREAM_ALIGN), so this call is a
* harmless no-op realignment-free copy on every other build. */
{
byte keybuf[CHACHA_MAX_KEY_SZ + 1];
XMEMCPY(keybuf + 1, key, sizeof(key));
ExpectIntEQ(wc_Chacha_SetKey(&ctx, keybuf + 1, keySz), 0);
}
#endif
return EXPECT_RESULT();
} /* END test_wc_Chacha_SetKey */
Expand Down Expand Up @@ -179,9 +199,25 @@ int test_wc_Chacha_Process(void)
}
#endif

/* Test bad args. */
/* Test bad args: independence pairs for each operand of the 3-way OR. */
ExpectIntEQ(wc_Chacha_Process(NULL, cipher, (byte*)input, (word32)inlen),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_Chacha_Process(&enc, cipher, NULL, (word32)inlen),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_Chacha_Process(&enc, NULL, (byte*)input, (word32)inlen),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));

/* msglen==0 with a pending leftover keystream block: independence pair
* for the (msglen > 0 && ctx->left > 0) decision's first operand, held
* with ctx->left > 0 (the other operand) true. Deliberately NOT under
* the USE_INTEL_CHACHA_SPEEDUP-exclude guard above: portable C and the
* intel-speedup dispatch each carry their own copy of this decision at
* a different line, and this call is variant-agnostic so it closes
* whichever one a given build compiled. */
ExpectIntEQ(wc_Chacha_SetKey(&enc, key, keySz), 0);
ExpectIntEQ(wc_Chacha_SetIV(&enc, cipher, 0), 0);
ExpectIntEQ(wc_Chacha_Process(&enc, cipher, (byte*)input, 1), 0);
ExpectIntEQ(wc_Chacha_Process(&enc, cipher, (byte*)input, 0), 0);
#endif
return EXPECT_RESULT();
} /* END test_wc_Chacha_Process */
Expand Down Expand Up @@ -617,3 +653,53 @@ int test_wc_Chacha_UnalignedBuffers(void)
#endif
return EXPECT_RESULT();
} /* END test_wc_Chacha_UnalignedBuffers */

/*
* Testing wc_XChacha_SetKey(). Exercises the XChaCha20 24-byte-nonce setup
* (wc_HChacha_block, the two internal wc_Chacha_SetIV calls) and its
* nonceSz argument check.
*/
int test_wc_Chacha_XChachaSetKey(void)
{
EXPECT_DECLS;
#if defined(HAVE_CHACHA) && defined(HAVE_XCHACHA)
ChaCha enc, dec;
static const byte key[CHACHA_MAX_KEY_SZ] = {
0x00,0x01,0x02,0x03, 0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b, 0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17,
0x18,0x19,0x1a,0x1b, 0x1c,0x1d,0x1e,0x1f
};
static const byte nonce[XCHACHA_NONCE_BYTES] = {
0x00,0x01,0x02,0x03, 0x04,0x05,0x06,0x07,
0x08,0x09,0x0a,0x0b, 0x0c,0x0d,0x0e,0x0f,
0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17
};
static const byte plain[32] = { 0 };
byte cipher[sizeof(plain)];
byte roundtrip[sizeof(plain)];

XMEMSET(&enc, 0, sizeof(enc));
XMEMSET(&dec, 0, sizeof(dec));

/* Valid 24-byte nonce round trip. */
ExpectIntEQ(wc_XChacha_SetKey(&enc, key, sizeof(key), nonce,
sizeof(nonce), 0), 0);
ExpectIntEQ(wc_XChacha_SetKey(&dec, key, sizeof(key), nonce,
sizeof(nonce), 0), 0);
ExpectIntEQ(wc_Chacha_Process(&enc, cipher, plain, sizeof(plain)), 0);
ExpectIntEQ(wc_Chacha_Process(&dec, roundtrip, cipher, sizeof(plain)), 0);
ExpectBufEQ(roundtrip, plain, sizeof(plain));

/* Bad nonceSz: independence pair for the nonceSz != XCHACHA_NONCE_BYTES
* decision (single-condition, but still needs both outcomes for branch
* coverage). */
ExpectIntEQ(wc_XChacha_SetKey(&enc, key, sizeof(key), nonce,
sizeof(nonce) - 1, 0), WC_NO_ERR_TRACE(BAD_FUNC_ARG));

/* Bad keySz propagates the wc_Chacha_SetKey() failure through. */
ExpectIntEQ(wc_XChacha_SetKey(&enc, key, 18, nonce, sizeof(nonce), 0),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
#endif
return EXPECT_RESULT();
} /* END test_wc_Chacha_XChachaSetKey */
4 changes: 3 additions & 1 deletion tests/api/test_chacha.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ 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), \
Expand All @@ -39,6 +40,7 @@ int test_wc_Chacha_UnalignedBuffers(void);
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_UnalignedBuffers), \
TEST_DECL_GROUP("chacha", test_wc_Chacha_XChachaSetKey)

#endif /* WOLFCRYPT_TEST_CHACHA_H */
Loading
Loading