Skip to content

Commit 5e8297e

Browse files
committed
Fixed more configuration mismatches in tests
1 parent c291477 commit 5e8297e

9 files changed

Lines changed: 225 additions & 19 deletions

File tree

tests/api.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,7 +4139,7 @@ static int test_wolfSSL_session_cache_api_direct(void)
41394139
ExpectIntEQ(wolfSSL_SetServerID(ssl, NULL, sizeof(shortId), 0),
41404140
BAD_FUNC_ARG);
41414141
ExpectIntEQ(wolfSSL_SetServerID(ssl, shortId, 0, 0), BAD_FUNC_ARG);
4142-
#ifndef NO_CLIENT_CACHE
4142+
#if !defined(NO_CLIENT_CACHE) && !defined(NO_WOLFSSL_CLIENT)
41434143
ExpectIntEQ(wolfSSL_SetServerID(ssl, shortId, (int)sizeof(shortId), 1),
41444144
WOLFSSL_SUCCESS);
41454145
ExpectIntEQ(wolfSSL_SetServerID(ssl, longId, (int)sizeof(longId), 1),
@@ -4277,7 +4277,7 @@ static int test_wolfSSL_crl_ocsp_object_api(void)
42774277
#endif
42784278
#endif
42794279

4280-
#ifdef HAVE_CERTIFICATE_STATUS_REQUEST
4280+
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST) && !defined(NO_WOLFSSL_CLIENT)
42814281
ExpectIntEQ(wolfSSL_UseOCSPStapling(NULL, WOLFSSL_CSR_OCSP, 0),
42824282
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
42834283
#ifndef NO_WOLFSSL_SERVER
@@ -4288,15 +4288,13 @@ static int test_wolfSSL_crl_ocsp_object_api(void)
42884288
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
42894289
}
42904290
#endif
4291-
#ifndef NO_WOLFSSL_CLIENT
42924291
ExpectIntEQ(wolfSSL_UseOCSPStapling(clientSsl, WOLFSSL_CSR_OCSP, 0),
42934292
WOLFSSL_SUCCESS);
42944293
ExpectIntEQ(wolfSSL_CTX_UseOCSPStapling(clientCtx, WOLFSSL_CSR_OCSP, 0),
42954294
WOLFSSL_SUCCESS);
42964295
#endif
4297-
#endif
42984296

4299-
#ifdef HAVE_CERTIFICATE_STATUS_REQUEST_V2
4297+
#if defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2) && !defined(NO_WOLFSSL_CLIENT)
43004298
ExpectIntEQ(wolfSSL_UseOCSPStaplingV2(NULL, WOLFSSL_CSR2_OCSP, 0),
43014299
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
43024300
#ifndef NO_WOLFSSL_SERVER
@@ -4307,12 +4305,10 @@ static int test_wolfSSL_crl_ocsp_object_api(void)
43074305
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
43084306
}
43094307
#endif
4310-
#ifndef NO_WOLFSSL_CLIENT
43114308
ExpectIntEQ(wolfSSL_UseOCSPStaplingV2(clientSsl, WOLFSSL_CSR2_OCSP, 0),
43124309
WOLFSSL_SUCCESS);
43134310
ExpectIntEQ(wolfSSL_CTX_UseOCSPStaplingV2(clientCtx, WOLFSSL_CSR2_OCSP, 0),
43144311
WOLFSSL_SUCCESS);
4315-
#endif
43164312
#endif
43174313

43184314
wolfSSL_free(clientSsl);
@@ -27417,7 +27413,7 @@ static int test_CONF_CTX_CMDLINE(void)
2741727413
{
2741827414
EXPECT_DECLS;
2741927415
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && !defined(NO_TLS) && \
27420-
!defined(NO_WOLFSSL_SERVER)
27416+
!defined(NO_WOLFSSL_SERVER) && !defined(NO_WOLFSSL_CLIENT)
2742127417
SSL_CTX* ctx = NULL;
2742227418
SSL_CONF_CTX* cctx = NULL;
2742327419
SSL_CONF_CTX* noCertCtx = NULL;
@@ -29044,7 +29040,7 @@ static int test_wc_CryptoCb_TLS(int tlsVer,
2904429040
}
2904529041
#endif /* WOLF_CRYPTO_CB && HAVE_IO_TESTS_DEPENDENCIES */
2904629042

29047-
#if defined(WOLFSSL_HAVE_PRF) && !defined(NO_HMAC)
29043+
#if defined(WOLFSSL_HAVE_PRF) && !defined(NO_HMAC) && !defined(NO_SHA256)
2904829044
static int test_wc_KdfPrf_guardrails(void)
2904929045
{
2905029046
EXPECT_DECLS;
@@ -29064,6 +29060,8 @@ static int test_wc_KdfPrf_guardrails(void)
2906429060
ExpectIntEQ(wc_PRF(out, sizeof(out), secret, 16, seed, sizeof(seed),
2906529061
sha256_mac, HEAP_HINT, INVALID_DEVID), 0);
2906629062

29063+
/* PRF_TLSv1 requires both MD5 and SHA1. */
29064+
#if !defined(NO_MD5) && !defined(NO_SHA) && !defined(NO_OLD_TLS)
2906729065
ExpectIntEQ(wc_PRF_TLSv1(out, sizeof(out), secret, (word32)sizeof(secret),
2906829066
label, (word32)sizeof(label), seed, 1, HEAP_HINT, INVALID_DEVID),
2906929067
WC_NO_ERR_TRACE(BUFFER_E));
@@ -29072,13 +29070,16 @@ static int test_wc_KdfPrf_guardrails(void)
2907229070
WC_NO_ERR_TRACE(BUFFER_E));
2907329071
ExpectIntEQ(wc_PRF_TLSv1(out, sizeof(out), secret, 16,
2907429072
label, (word32)sizeof(label), seed, 1, HEAP_HINT, INVALID_DEVID), 0);
29073+
#endif
2907529074

2907629075
ExpectIntEQ(wc_PRF_TLS(out, sizeof(out), secret, 16, label,
2907729076
(word32)sizeof(label), seed, MAX_PRF_LABSEED, 1, sha256_mac,
2907829077
HEAP_HINT, INVALID_DEVID), WC_NO_ERR_TRACE(BUFFER_E));
29078+
#ifndef NO_MD5
2907929079
ExpectIntEQ(wc_PRF_TLS(out, sizeof(out), secret, 16, label,
2908029080
(word32)sizeof(label), seed, 1, 1, md5_mac, HEAP_HINT, INVALID_DEVID),
2908129081
0);
29082+
#endif
2908229083
return EXPECT_RESULT();
2908329084
}
2908429085
#endif
@@ -36611,17 +36612,19 @@ TEST_CASE testCases[] = {
3661136612
TEST_DECL(test_ticket_and_psk_mixing),
3661236613
/* Can't memory test as client/server Asserts in thread. */
3661336614
TEST_DECL(test_prioritize_psk),
36614-
#if defined(WOLFSSL_HAVE_PRF) && !defined(NO_HMAC)
36615+
#if defined(WOLFSSL_HAVE_PRF) && !defined(NO_HMAC) && !defined(NO_SHA256)
3661536616
TEST_DECL(test_wc_KdfPrf_guardrails),
3661636617
#endif
3661736618
#if defined(HAVE_HKDF)
3661836619
TEST_DECL(test_wc_KdfHkdf_guardrails),
3661936620
#endif
3662036621

36621-
#ifdef WOLF_CRYPTO_CB
36622+
#if defined(WOLF_CRYPTO_CB) && defined(HAVE_IO_TESTS_DEPENDENCIES)
3662236623
TEST_DECL(test_wc_CryptoCb_hkdf_wrapper),
3662336624
/* Can't memory test as client/server hangs. */
3662436625
TEST_DECL(test_wc_CryptoCb_registry),
36626+
#endif
36627+
#ifdef WOLF_CRYPTO_CB
3662536628
/* Can't memory test as client/server hangs. */
3662636629
TEST_DECL(test_wc_CryptoCb),
3662736630
#endif

tests/api/test_chacha20_poly1305.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,8 @@ int test_wc_Chacha20Poly1305DecisionCoverage(void)
543543
EXPECT_DECLS;
544544
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
545545
ChaChaPoly_Aead aead;
546-
byte ct[64];
547-
byte pt[64];
546+
byte ct[sizeof(tv_plaintext)];
547+
byte pt[sizeof(tv_plaintext)];
548548
byte tag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
549549
byte tag2[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE];
550550
static const byte data15[15] = {

tests/api/test_evp_pkey.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2981,12 +2981,13 @@ int test_wolfSSL_EvpPkeyDeriveCoverage2(void)
29812981
#ifndef NO_RSA
29822982
rsaKey = EVP_PKEY_new();
29832983
if (rsaKey != NULL) {
2984+
EVP_PKEY *saved_peer;
29842985
WOLFSSL_RSA *rsa = wolfSSL_RSA_generate_key(1024, WC_RSA_EXPONENT,
29852986
NULL, NULL);
29862987
if (rsa != NULL) {
29872988
(void)wolfSSL_EVP_PKEY_assign_RSA(rsaKey, rsa);
29882989
}
2989-
EVP_PKEY *saved_peer = ctx->peerKey;
2990+
saved_peer = ctx->peerKey;
29902991
ctx->peerKey = rsaKey;
29912992
keylen = sizeof(outbuf);
29922993
ExpectIntNE(wolfSSL_EVP_PKEY_derive(ctx, outbuf, &keylen),
@@ -3782,8 +3783,9 @@ int test_wolfSSL_EvpPkeyVerifyBatch4(void)
37823783

37833784
/* P3: ctx->pkey == NULL */
37843785
if (ctx != NULL) {
3786+
EVP_PKEY *saved;
37853787
(void)wolfSSL_EVP_PKEY_verify_init(ctx);
3786-
EVP_PKEY *saved = ctx->pkey;
3788+
saved = ctx->pkey;
37873789
ctx->pkey = NULL;
37883790
ExpectIntNE(wolfSSL_EVP_PKEY_verify(ctx, bad_sig, sizeof(bad_sig),
37893791
tbs, sizeof(tbs)),

tests/api/test_md5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int test_wc_Md5UpdateResidualCoverage(void)
189189
{
190190
EXPECT_DECLS;
191191
#ifndef NO_MD5
192-
Md5 md5;
192+
wc_Md5 md5;
193193
byte digest[WC_MD5_DIGEST_SIZE];
194194
byte buf[WC_MD5_BLOCK_SIZE * 2 + 1]; /* 129 bytes */
195195

tests/api/test_ocsp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ static int test_ssl_api_ocsp_crl_guardrails(void)
116116
defined(HAVE_CERTIFICATE_STATUS_REQUEST_V2)
117117
unsigned char* ocspResp = NULL;
118118
byte* ownedResp = NULL;
119+
(void)ocspResp;
120+
(void)ownedResp;
119121
#endif
120122

121123
/* Null-object guardrails for OCSP wrappers. */
@@ -156,10 +158,12 @@ static int test_ssl_api_ocsp_crl_guardrails(void)
156158
#if !defined(NO_TLS) && !defined(NO_WOLFSSL_CLIENT)
157159
ExpectNotNull(clientCtx = wolfSSL_CTX_new(wolfSSLv23_client_method()));
158160
ExpectNotNull(clientSsl = wolfSSL_new(clientCtx));
161+
#ifndef NO_WOLFSSL_SERVER
159162
serverCtx = wolfSSL_CTX_new(wolfSSLv23_server_method());
160163
if (serverCtx != NULL) {
161164
serverSsl = wolfSSL_new(serverCtx);
162165
}
166+
#endif
163167

164168
/* Wrong-side coverage: OCSP stapling use APIs are client-only. */
165169
#ifdef HAVE_CERTIFICATE_STATUS_REQUEST

tests/api/test_signature.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,13 @@ int test_wc_SignatureRsaDecisionCoverage(void)
658658
int test_wc_SignatureGetSizeAllTypes(void)
659659
{
660660
EXPECT_DECLS;
661-
#if !defined(NO_SIG_WRAPPER)
661+
/* Mirror the implicit NO_SIG_WRAPPER auto-disable in wolfcrypt/src/signature.c:
662+
* the wrapper is only compiled when an ECC sign/verify path or RSA is
663+
* available. */
664+
#if !defined(NO_SIG_WRAPPER) && \
665+
((defined(HAVE_ECC) && \
666+
(defined(HAVE_ECC_SIGN) || defined(HAVE_ECC_VERIFY))) || \
667+
!defined(NO_RSA))
662668
#if defined(HAVE_ECC) && !defined(NO_ECC256)
663669
{
664670
ecc_key ecc;

0 commit comments

Comments
 (0)