Skip to content

Commit 04feffe

Browse files
committed
Fixed more test cases configurations
1 parent 9e1720c commit 04feffe

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
@@ -7074,6 +7074,7 @@ int test_wc_AesInitIdLabelCoverage(void)
70747074
/* An id with valid length (1 byte). */
70757075
const unsigned char idBuf[1] = { 0x42 };
70767076

7077+
XMEMSET(&aes, 0, sizeof(aes));
70777078
XMEMSET(longLabel, 'X', AES_MAX_LABEL_LEN + 1);
70787079
longLabel[AES_MAX_LABEL_LEN + 1] = '\0';
70797080

@@ -7083,17 +7084,17 @@ int test_wc_AesInitIdLabelCoverage(void)
70837084
INVALID_DEVID), WC_NO_ERR_TRACE(BAD_FUNC_ARG));
70847085

70857086
/* Pair: aes != NULL, len < 0 (second cond TRUE) */
7087+
XMEMSET(&aes, 0, sizeof(aes));
70867088
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, -1, HEAP_HINT,
70877089
INVALID_DEVID), WC_NO_ERR_TRACE(BUFFER_E));
7088-
/* aes may have been partially initialised — free defensively */
7089-
wc_AesFree(&aes);
70907090

70917091
/* Pair: aes != NULL, len > AES_MAX_ID_LEN (third cond TRUE) */
7092+
XMEMSET(&aes, 0, sizeof(aes));
70927093
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, AES_MAX_ID_LEN + 1,
70937094
HEAP_HINT, INVALID_DEVID), WC_NO_ERR_TRACE(BUFFER_E));
7094-
wc_AesFree(&aes);
70957095

70967096
/* Happy path: all conditions FALSE → success */
7097+
XMEMSET(&aes, 0, sizeof(aes));
70977098
ExpectIntEQ(wc_AesInit_Id(&aes, (unsigned char*)idBuf, (int)sizeof(idBuf),
70987099
HEAP_HINT, INVALID_DEVID), 0);
70997100
if (EXPECT_SUCCESS()) initAes = 1;
@@ -7104,15 +7105,18 @@ int test_wc_AesInitIdLabelCoverage(void)
71047105
ExpectIntEQ(wc_AesInit_Label(NULL, shortLabel, HEAP_HINT, INVALID_DEVID),
71057106
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
71067107
/* Pair: label == NULL */
7108+
XMEMSET(&aes, 0, sizeof(aes));
71077109
ExpectIntEQ(wc_AesInit_Label(&aes, NULL, HEAP_HINT, INVALID_DEVID),
71087110
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
71097111

71107112
/* --- wc_AesInit_Label (L13672: labelLen==0 || labelLen>MAX) --- */
71117113
/* Pair: labelLen > AES_MAX_LABEL_LEN */
7114+
XMEMSET(&aes, 0, sizeof(aes));
71127115
ExpectIntEQ(wc_AesInit_Label(&aes, longLabel, HEAP_HINT, INVALID_DEVID),
71137116
WC_NO_ERR_TRACE(BUFFER_E));
71147117

71157118
/* Happy path: valid label, both conditions FALSE */
7119+
XMEMSET(&aes, 0, sizeof(aes));
71167120
ExpectIntEQ(wc_AesInit_Label(&aes, shortLabel, HEAP_HINT, INVALID_DEVID),
71177121
0);
71187122
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)