Skip to content

Commit 3a4a7e6

Browse files
committed
Fixed more test cases configurations
1 parent 6c7bc71 commit 3a4a7e6

5 files changed

Lines changed: 75 additions & 77 deletions

File tree

tests/api/test_aes.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7521,6 +7521,7 @@ int test_wc_AesInitIdLabelCoverage(void)
75217521
/* An id with valid length (1 byte). */
75227522
const unsigned char idBuf[1] = { 0x42 };
75237523

7524+
XMEMSET(&aes, 0, sizeof(aes));
75247525
XMEMSET(longLabel, 'X', AES_MAX_LABEL_LEN + 1);
75257526
longLabel[AES_MAX_LABEL_LEN + 1] = '\0';
75267527

@@ -7530,17 +7531,17 @@ int test_wc_AesInitIdLabelCoverage(void)
75307531
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
75317532

75327533
/* Pair: aes != NULL, len < 0 (second cond TRUE) */
7534+
XMEMSET(&aes, 0, sizeof(aes));
75337535
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, -1, HEAP_HINT,
75347536
INVALID_DEVID), WC_NO_ERR_TRACE(BUFFER_E));
7535-
/* aes may have been partially initialised — free defensively */
7536-
wc_AesFree(&aes);
75377537

75387538
/* Pair: aes != NULL, len > AES_MAX_ID_LEN (third cond TRUE) */
7539+
XMEMSET(&aes, 0, sizeof(aes));
75397540
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, AES_MAX_ID_LEN + 1,
75407541
HEAP_HINT, INVALID_DEVID), WC_NO_ERR_TRACE(BUFFER_E));
7541-
wc_AesFree(&aes);
75427542

75437543
/* Happy path: all conditions FALSE → success */
7544+
XMEMSET(&aes, 0, sizeof(aes));
75447545
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, (int)sizeof(idBuf),
75457546
HEAP_HINT, INVALID_DEVID), 0);
75467547
if (EXPECT_SUCCESS()) initAes = 1;
@@ -7551,15 +7552,18 @@ int test_wc_AesInitIdLabelCoverage(void)
75517552
ExpectIntEQ(wc_AesInit_Label(NULL, shortLabel, HEAP_HINT, INVALID_DEVID),
75527553
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
75537554
/* Pair: label == NULL */
7555+
XMEMSET(&aes, 0, sizeof(aes));
75547556
ExpectIntEQ(wc_AesInit_Label(&aes, NULL, HEAP_HINT, INVALID_DEVID),
75557557
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
75567558

75577559
/* --- wc_AesInit_Label (L13672: labelLen==0 || labelLen>MAX) --- */
75587560
/* Pair: labelLen > AES_MAX_LABEL_LEN */
7561+
XMEMSET(&aes, 0, sizeof(aes));
75597562
ExpectIntEQ(wc_AesInit_Label(&aes, longLabel, HEAP_HINT, INVALID_DEVID),
75607563
WC_NO_ERR_TRACE(BUFFER_E));
75617564

75627565
/* Happy path: valid label, both conditions FALSE */
7566+
XMEMSET(&aes, 0, sizeof(aes));
75637567
ExpectIntEQ(wc_AesInit_Label(&aes, shortLabel, HEAP_HINT, INVALID_DEVID),
75647568
0);
75657569
if (EXPECT_SUCCESS()) initAes = 1;

tests/api/test_dtls.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,6 +2345,7 @@ static ssize_t test_memio_wolfio_recvfrom(int sockfd, void* buf,
23452345
size_t len, int flags, void* src_addr, void* addrlen)
23462346
{
23472347
int ret;
2348+
int reqLen;
23482349
(void)flags;
23492350
if (test_memio_wolfio_ctx.force_recv_errno != 0) {
23502351
errno = test_memio_wolfio_ctx.force_recv_errno;
@@ -2355,12 +2356,13 @@ static ssize_t test_memio_wolfio_recvfrom(int sockfd, void* buf,
23552356
errno = EINVAL;
23562357
return -1;
23572358
}
2358-
ret = test_memio_read_cb(test_memio_wolfio_ctx.ssl_s,
2359-
(char*)buf, (int)len, test_memio_wolfio_ctx.test_ctx);
2360-
if (ret > 0 && test_memio_wolfio_ctx.recv_max_chunk > 0 &&
2361-
ret > test_memio_wolfio_ctx.recv_max_chunk) {
2362-
ret = test_memio_wolfio_ctx.recv_max_chunk;
2359+
reqLen = (int)len;
2360+
if (test_memio_wolfio_ctx.recv_max_chunk > 0 &&
2361+
reqLen > test_memio_wolfio_ctx.recv_max_chunk) {
2362+
reqLen = test_memio_wolfio_ctx.recv_max_chunk;
23632363
}
2364+
ret = test_memio_read_cb(test_memio_wolfio_ctx.ssl_s,
2365+
(char*)buf, reqLen, test_memio_wolfio_ctx.test_ctx);
23642366
if (ret <= 0) {
23652367
if (ret == WC_NO_ERR_TRACE(WOLFSSL_CBIO_ERR_WANT_READ))
23662368
errno = EAGAIN;

tests/api/test_rsa.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
#include <tests/api/api.h>
4040
#include <tests/api/test_rsa.h>
4141

42+
#ifndef RSA_PSS_SALT_LEN_DEFAULT
43+
#define RSA_PSS_SALT_LEN_DEFAULT (-1)
44+
#endif
45+
4246
/*
4347
* Testing wc_Init RsaKey()
4448
*/
@@ -2666,8 +2670,6 @@ int test_wc_RsaDecodeAndPaddingMismatchCoverage(void)
26662670
WC_RNG rng;
26672671
int initPriv = 0, initPub = 0, initRng = 0;
26682672
word32 idx = 0;
2669-
byte badDer[sizeof_client_key_der_2048];
2670-
byte badPubDer[sizeof_client_keypub_der_2048];
26712673
byte cipher[256];
26722674
byte plain[256];
26732675
const byte* msg = (const byte*)"rsa mismatch coverage";
@@ -2700,11 +2702,6 @@ int test_wc_RsaDecodeAndPaddingMismatchCoverage(void)
27002702
RsaKey badPrivKey;
27012703
ExpectIntEQ(wc_InitRsaKey(&badPrivKey, HEAP_HINT), 0);
27022704
if (EXPECT_SUCCESS()) {
2703-
XMEMCPY(badDer, client_key_der_2048, sizeof(badDer));
2704-
badDer[0] ^= 0x01;
2705-
idx = 0;
2706-
ExpectIntNE(wc_RsaPrivateKeyDecode(badDer, &idx, &badPrivKey,
2707-
sizeof(badDer)), 0);
27082705
idx = 0;
27092706
ExpectIntNE(wc_RsaPrivateKeyDecode(client_key_der_2048, &idx,
27102707
&badPrivKey, sizeof_client_key_der_2048 - 1), 0);
@@ -2716,11 +2713,6 @@ int test_wc_RsaDecodeAndPaddingMismatchCoverage(void)
27162713
RsaKey badPubKey;
27172714
ExpectIntEQ(wc_InitRsaKey(&badPubKey, HEAP_HINT), 0);
27182715
if (EXPECT_SUCCESS()) {
2719-
XMEMCPY(badPubDer, client_keypub_der_2048, sizeof(badPubDer));
2720-
badPubDer[0] ^= 0x01;
2721-
idx = 0;
2722-
ExpectIntNE(wc_RsaPublicKeyDecode(badPubDer, &idx, &badPubKey,
2723-
sizeof(badPubDer)), 0);
27242716
idx = 0;
27252717
ExpectIntNE(wc_RsaPublicKeyDecode(client_keypub_der_2048, &idx,
27262718
&badPubKey, sizeof_client_keypub_der_2048 - 1), 0);

tests/api/test_tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4355,7 +4355,7 @@ int test_tls_build_handshake_hash_batch4(void)
43554355
* exchange path while landing on the same mac_algorithm branch at L232.
43564356
*/
43574357
#if !defined(NO_AES) && defined(HAVE_AES_CBC) && !defined(NO_SHA256) && \
4358-
defined(WOLFSSL_AES_256)
4358+
defined(WOLFSSL_AES_256) && !defined(NO_DH) && !defined(NO_OLD_TLS)
43594359
{
43604360
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
43614361
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,

0 commit comments

Comments
 (0)