Skip to content

Commit 3e2d559

Browse files
committed
Fix runtime error tls_mcdc, fixed correct MAP symbols
1 parent 04feffe commit 3e2d559

4 files changed

Lines changed: 74 additions & 35 deletions

File tree

tests/api/test_aes.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6909,8 +6909,13 @@ int test_wc_AesRequirementCoverage(void)
69096909
ExpectIntEQ(wc_AesXtsEncryptConsecutiveSectors(&xts, cipher, xtsMsg,
69106910
XTS_TOTAL, (word64)0x12345678, XTS_SECTOR_SZ), 0);
69116911
ExpectIntNE(XMEMCMP(cipher, xtsMsg, XTS_TOTAL), 0);
6912-
if (initXts) ExpectIntEQ(wc_AesXtsFree(&xts), 0);
6913-
initXts = 0;
6912+
if (initXts) {
6913+
int freeRet = wc_AesXtsFree(&xts);
6914+
if (EXPECT_SUCCESS()) {
6915+
ExpectIntEQ(freeRet, 0);
6916+
}
6917+
initXts = 0;
6918+
}
69146919

69156920
ExpectIntEQ(wc_AesXtsInit(&xts, HEAP_HINT, INVALID_DEVID), 0);
69166921
if (EXPECT_SUCCESS()) initXts = 1;
@@ -6919,7 +6924,13 @@ int test_wc_AesRequirementCoverage(void)
69196924
ExpectIntEQ(wc_AesXtsDecryptConsecutiveSectors(&xts, plain, cipher,
69206925
XTS_TOTAL, (word64)0x12345678, XTS_SECTOR_SZ), 0);
69216926
ExpectIntEQ(XMEMCMP(plain, xtsMsg, XTS_TOTAL), 0);
6922-
if (initXts) ExpectIntEQ(wc_AesXtsFree(&xts), 0);
6927+
if (initXts) {
6928+
int freeRet = wc_AesXtsFree(&xts);
6929+
if (EXPECT_SUCCESS()) {
6930+
ExpectIntEQ(freeRet, 0);
6931+
}
6932+
initXts = 0;
6933+
}
69236934
}
69246935
#endif /* WOLFSSL_AES_XTS */
69256936

tests/api/test_tls13.c

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,17 +3909,6 @@ int test_tls13_mcdc_hrr_coverage(void)
39093909
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
39103910
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
39113911
struct test_memio_ctx test_ctx;
3912-
(void)ctx_c;
3913-
(void)ssl_c;
3914-
(void)ctx_s;
3915-
(void)ssl_s;
3916-
(void)test_ctx;
3917-
3918-
/* Client offers P-384 (or P-521) key_share in CH1 but also advertises
3919-
* P-256 as a supported group; server prefers P-256 -> server sends HRR
3920-
* with key_share extension selecting P-256 -> client retries with P-256.
3921-
* When client_grp == server_grp both sides agree immediately; HRR is
3922-
* still triggered by the stateless cookie mechanism. */
39233912
int server_grp = WOLFSSL_ECC_SECP256R1;
39243913
#if defined(HAVE_ECC384) && (ECC_MIN_KEY_SZ <= 384)
39253914
int client_grp = WOLFSSL_ECC_SECP384R1;
@@ -3940,6 +3929,11 @@ int test_tls13_mcdc_hrr_coverage(void)
39403929
int client_grps[2] = { client_grp, 0 };
39413930
int client_grps_cnt = 1;
39423931
#endif
3932+
(void)ctx_c;
3933+
(void)ssl_c;
3934+
(void)ctx_s;
3935+
(void)ssl_s;
3936+
(void)test_ctx;
39433937

39443938
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
39453939
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
@@ -4334,13 +4328,15 @@ int test_tls13_mcdc_batch2_post_handshake_auth(void)
43344328
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
43354329
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
43364330
struct test_memio_ctx test_ctx;
4331+
char buf[64];
4332+
int err;
4333+
int rounds;
4334+
int ret;
43374335
(void)ctx_c;
43384336
(void)ssl_c;
43394337
(void)ctx_s;
43404338
(void)ssl_s;
43414339
(void)test_ctx;
4342-
char buf[64];
4343-
int err;
43444340

43454341
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
43464342
ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, &ctx_s, &ssl_c, &ssl_s,
@@ -4365,24 +4361,44 @@ int test_tls13_mcdc_batch2_post_handshake_auth(void)
43654361
/* Phase 1: complete the main TLS 1.3 handshake. */
43664362
ExpectIntEQ(test_memio_do_handshake(ssl_c, ssl_s, 10, NULL), 0);
43674363

4368-
/* Drain any NewSessionTicket records at the client. */
4369-
ExpectIntEQ(wolfSSL_read(ssl_c, buf, sizeof(buf)), -1);
4370-
err = wolfSSL_get_error(ssl_c, -1);
4371-
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE);
4364+
/* Drain any NewSessionTicket records at the client. */
4365+
rounds = 0;
4366+
do {
4367+
ret = wolfSSL_read(ssl_c, buf, sizeof(buf));
4368+
if (ret > 0)
4369+
continue;
4370+
err = wolfSSL_get_error(ssl_c, -1);
4371+
rounds++;
4372+
} while (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_NONE &&
4373+
err != WOLFSSL_ERROR_WANT_WRITE && rounds < 32 && !EXPECT_FAIL());
4374+
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE ||
4375+
err == WOLFSSL_ERROR_WANT_WRITE);
43724376

43734377
/* Phase 2: server sends a post-handshake CertificateRequest. */
43744378
ExpectIntEQ(wolfSSL_request_certificate(ssl_s), WOLFSSL_SUCCESS);
43754379

4376-
/* Pump client-side: read CertificateRequest, produce Certificate +
4377-
* CertificateVerify + Finished. */
4378-
ExpectIntEQ(wolfSSL_read(ssl_c, buf, sizeof(buf)), -1);
4379-
err = wolfSSL_get_error(ssl_c, -1);
4380-
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE);
4380+
/* Pump both sides until post-handshake auth traffic quiesces. */
4381+
for (rounds = 0; rounds < 32 && !EXPECT_FAIL(); rounds++) {
4382+
ret = wolfSSL_read(ssl_c, buf, sizeof(buf));
4383+
if (ret <= 0) {
4384+
err = wolfSSL_get_error(ssl_c, -1);
4385+
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ ||
4386+
err == WOLFSSL_ERROR_WANT_WRITE ||
4387+
err == WOLFSSL_ERROR_NONE);
4388+
}
43814389

4382-
/* Pump server-side: receive the client certificate messages. */
4383-
ExpectIntEQ(wolfSSL_read(ssl_s, buf, sizeof(buf)), -1);
4384-
err = wolfSSL_get_error(ssl_s, -1);
4385-
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ || err == WOLFSSL_ERROR_NONE);
4390+
ret = wolfSSL_read(ssl_s, buf, sizeof(buf));
4391+
if (ret <= 0) {
4392+
err = wolfSSL_get_error(ssl_s, -1);
4393+
ExpectTrue(err == WOLFSSL_ERROR_WANT_READ ||
4394+
err == WOLFSSL_ERROR_WANT_WRITE ||
4395+
err == WOLFSSL_ERROR_NONE);
4396+
}
4397+
4398+
if (test_ctx.c_len == 0 && test_ctx.s_len == 0) {
4399+
break;
4400+
}
4401+
}
43864402

43874403
/* App-data round-trip after post-handshake auth verifies keys intact. */
43884404
ExpectIntEQ(wolfSSL_write(ssl_s, "pha-ok", 6), 6);
@@ -4424,15 +4440,15 @@ int test_tls13_mcdc_batch2_early_data(void)
44244440
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
44254441
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
44264442
struct test_memio_ctx test_ctx;
4443+
WOLFSSL_SESSION *sess = NULL;
4444+
char msgBuf[64];
4445+
int written = 0;
4446+
int readSz = 0;
44274447
(void)ctx_c;
44284448
(void)ssl_c;
44294449
(void)ctx_s;
44304450
(void)ssl_s;
44314451
(void)test_ctx;
4432-
WOLFSSL_SESSION *sess = NULL;
4433-
char msgBuf[64];
4434-
int written = 0;
4435-
int readSz = 0;
44364452

44374453
/* ---- pass 1: establish session ticket -------------------------------- */
44384454
XMEMSET(&test_ctx, 0, sizeof(test_ctx));
@@ -4803,10 +4819,9 @@ int test_tls13_mcdc_batch2_alpn(void)
48034819
defined(WOLFSSL_TLS13) && \
48044820
!defined(NO_WOLFSSL_CLIENT) && !defined(NO_WOLFSSL_SERVER) && \
48054821
defined(HAVE_ALPN)
4806-
struct test_memio_ctx test_ctx;
4807-
(void)test_ctx;
48084822
WOLFSSL_CTX *ctx_c = NULL, *ctx_s = NULL;
48094823
WOLFSSL *ssl_c = NULL, *ssl_s = NULL;
4824+
struct test_memio_ctx test_ctx;
48104825
(void)ctx_c;
48114826
(void)ssl_c;
48124827
(void)ctx_s;
@@ -4815,6 +4830,7 @@ int test_tls13_mcdc_batch2_alpn(void)
48154830
unsigned short protoSz = 0;
48164831
char alpn_h2[] = "h2";
48174832
char alpn_http11[] = "http/1.1";
4833+
(void)test_ctx;
48184834

48194835
/* ---- sub-test A: matching ALPN protocol "h2" -------------------------- */
48204836
XMEMSET(&test_ctx, 0, sizeof(test_ctx));

wolfssl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,6 +3169,7 @@ struct TLSX {
31693169

31703170
#ifdef WOLFSSL_API_PREFIX_MAP
31713171
#define TLSX_Find wolfSSL_TLSX_Find
3172+
#define TLSX_SupportExtensions wolfSSL_TLSX_SupportExtensions
31723173
#endif
31733174
WOLFSSL_TEST_VIS TLSX* TLSX_Find(TLSX* list, TLSX_Type type);
31743175
WOLFSSL_LOCAL void TLSX_Remove(TLSX** list, TLSX_Type type, void* heap);

wolfssl/wolfcrypt/asn.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,10 @@ WOLFSSL_API int wc_SetUnknownExtCallbackEx(DecodedCert* cert,
23252325
void *ctx);
23262326
#endif
23272327

2328+
#ifdef WOLFSSL_API_PREFIX_MAP
2329+
#define DecodePolicyOID wolfSSL_DecodePolicyOID
2330+
#define DecodeAuthKeyId wolfSSL_DecodeAuthKeyId
2331+
#endif
23282332
WOLFSSL_TEST_VIS int DecodePolicyOID(char *out, word32 outSz, const byte *in,
23292333
word32 inSz);
23302334
WOLFSSL_LOCAL int EncodePolicyOID(byte *out, word32 *outSz,
@@ -2445,6 +2449,10 @@ WOLFSSL_LOCAL int GetTimeString(byte* date, int format, char* buf, int len,
24452449
#if !defined(NO_ASN_TIME) && !defined(USER_TIME) && \
24462450
!defined(TIME_OVERRIDES) && (defined(OPENSSL_EXTRA) || \
24472451
defined(HAVE_PKCS7) || defined(HAVE_OCSP_RESPONDER))
2452+
#ifdef WOLFSSL_API_PREFIX_MAP
2453+
#define GetAsnTimeString wolfSSL_GetAsnTimeString
2454+
#define GetFormattedTime_ex wolfSSL_GetFormattedTime_ex
2455+
#endif
24482456
WOLFSSL_LOCAL int GetFormattedTime(void* currTime, byte* buf, word32 len);
24492457
WOLFSSL_TEST_VIS int GetAsnTimeString(void* currTime, byte* buf, word32 len);
24502458
WOLFSSL_TEST_VIS int GetFormattedTime_ex(void* currTime, byte* buf, word32 len,
@@ -2558,6 +2566,9 @@ WOLFSSL_LOCAL word32 SetExplicit(byte number, word32 len, byte* output,
25582566
byte isIndef);
25592567
WOLFSSL_LOCAL word32 SetSet(word32 len, byte* output);
25602568
WOLFSSL_API word32 SetAlgoID(int algoOID, byte* output, int type, int curveSz);
2569+
#ifdef WOLFSSL_API_PREFIX_MAP
2570+
#define SetAlgoIDEx wolfSSL_SetAlgoIDEx
2571+
#endif
25612572
WOLFSSL_TEST_VIS word32 SetAlgoIDEx(int algoOID, byte* output, int type,
25622573
int curveSz, byte absentParams);
25632574
#if defined(WC_RSA_PSS) && !defined(NO_RSA)

0 commit comments

Comments
 (0)