Skip to content

Commit e19a1a4

Browse files
Merge pull request #10912 from danielinux/mcdc-test-coverage
MC/DC coverage for wolfCrypt modules - Part 3
2 parents 5012d1d + 3a47bfb commit e19a1a4

47 files changed

Lines changed: 13161 additions & 19 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4399,6 +4399,7 @@ if(WOLFSSL_EXAMPLES)
43994399
tests/api/test_hash.c
44004400
tests/api/test_hmac.c
44014401
tests/api/test_cmac.c
4402+
tests/api/test_kdf.c
44024403
tests/api/test_she.c
44034404
tests/api/test_des3.c
44044405
tests/api/test_chacha.c
@@ -4411,7 +4412,10 @@ if(WOLFSSL_EXAMPLES)
44114412
tests/api/test_ascon.c
44124413
tests/api/test_sm4.c
44134414
tests/api/test_wc_encrypt.c
4415+
tests/api/test_coding.c
4416+
tests/api/test_error.c
44144417
tests/api/test_random.c
4418+
tests/api/test_wolfentropy.c
44154419
tests/api/test_wolfmath.c
44164420
tests/api/test_rsa.c
44174421
tests/api/test_dsa.c

tests/api.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
#include <tests/api/test_hash.h>
212212
#include <tests/api/test_hmac.h>
213213
#include <tests/api/test_cmac.h>
214+
#include <tests/api/test_kdf.h>
214215
#include <tests/api/test_she.h>
215216
#include <tests/api/test_des3.h>
216217
#include <tests/api/test_chacha.h>
@@ -223,7 +224,10 @@
223224
#include <tests/api/test_ascon.h>
224225
#include <tests/api/test_sm4.h>
225226
#include <tests/api/test_wc_encrypt.h>
227+
#include <tests/api/test_coding.h>
228+
#include <tests/api/test_error.h>
226229
#include <tests/api/test_random.h>
230+
#include <tests/api/test_wolfentropy.h>
227231
#include <tests/api/test_wolfmath.h>
228232
#include <tests/api/test_rsa.h>
229233
#include <tests/api/test_dsa.h>
@@ -7525,10 +7529,25 @@ static int test_wolfSSL_read_write_ex(void)
75257529
ExpectIntEQ(XSTRCMP((char*)buf, test_str), 0);
75267530

75277531

7528-
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SHUTDOWN_NOT_DONE);
7529-
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SHUTDOWN_NOT_DONE);
7530-
ExpectIntEQ(wolfSSL_shutdown(ssl_c), WOLFSSL_SUCCESS);
7531-
ExpectIntEQ(wolfSSL_shutdown(ssl_s), WOLFSSL_SUCCESS);
7532+
/* Drive the bidirectional close-notify exchange to completion instead of
7533+
* asserting a fixed NOT_DONE/SUCCESS sequence: the number of shutdown
7534+
* round-trips is protocol-version/config dependent, so a hard-coded
7535+
* sequence is fragile (fails e.g. under the cmake old-TLS build). */
7536+
{
7537+
int shutC = WOLFSSL_SHUTDOWN_NOT_DONE;
7538+
int shutS = WOLFSSL_SHUTDOWN_NOT_DONE;
7539+
int shutIt;
7540+
for (shutIt = 0; shutIt < 10 &&
7541+
(shutC != WOLFSSL_SUCCESS || shutS != WOLFSSL_SUCCESS);
7542+
shutIt++) {
7543+
if (shutC != WOLFSSL_SUCCESS)
7544+
shutC = wolfSSL_shutdown(ssl_c);
7545+
if (shutS != WOLFSSL_SUCCESS)
7546+
shutS = wolfSSL_shutdown(ssl_s);
7547+
}
7548+
ExpectIntEQ(shutC, WOLFSSL_SUCCESS);
7549+
ExpectIntEQ(shutS, WOLFSSL_SUCCESS);
7550+
}
75327551

75337552
wolfSSL_free(ssl_c);
75347553
wolfSSL_free(ssl_s);
@@ -37011,6 +37030,8 @@ TEST_CASE testCases[] = {
3701137030
TEST_HMAC_DECLS,
3701237031
/* CMAC */
3701337032
TEST_CMAC_DECLS,
37033+
/* KDF */
37034+
TEST_KDF_DECLS,
3701437035
/* SHE */
3701537036
TEST_SHE_DECLS,
3701637037
#ifdef WOLFSSL_SHE_EXTENDED
@@ -37052,9 +37073,14 @@ TEST_CASE testCases[] = {
3705237073
TEST_SM4_DECLS,
3705337074
/* wc_encrypt API */
3705437075
TEST_WC_ENCRYPT_DECLS,
37076+
/* wolfCrypt coding (Base64/Base16) */
37077+
TEST_CODING_DECLS,
37078+
/* wolfCrypt error strings */
37079+
TEST_ERROR_DECLS,
3705537080

3705637081
/* RNG tests */
3705737082
TEST_RANDOM_DECLS,
37083+
TEST_WOLFENTROPY_DECLS,
3705837084

3705937085
/* Public key */
3706037086
/* wolfmath MP API tests */

tests/api/include.am

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ tests_unit_test_SOURCES += tests/api/test_hash.c
1818
# MAC
1919
tests_unit_test_SOURCES += tests/api/test_hmac.c
2020
tests_unit_test_SOURCES += tests/api/test_cmac.c
21+
tests_unit_test_SOURCES += tests/api/test_kdf.c
2122
# SHE
2223
tests_unit_test_SOURCES += tests/api/test_she.c
2324
# Cipher
@@ -32,8 +33,11 @@ tests_unit_test_SOURCES += tests/api/test_aes.c
3233
tests_unit_test_SOURCES += tests/api/test_ascon.c
3334
tests_unit_test_SOURCES += tests/api/test_sm4.c
3435
tests_unit_test_SOURCES += tests/api/test_wc_encrypt.c
36+
tests_unit_test_SOURCES += tests/api/test_coding.c
37+
tests_unit_test_SOURCES += tests/api/test_error.c
3538
# Random
3639
tests_unit_test_SOURCES += tests/api/test_random.c
40+
tests_unit_test_SOURCES += tests/api/test_wolfentropy.c
3741
# MP
3842
tests_unit_test_SOURCES += tests/api/test_wolfmath.c
3943
# Public Key Algorithm
@@ -139,6 +143,7 @@ EXTRA_DIST += tests/api/test_digest.h
139143
EXTRA_DIST += tests/api/test_hash.h
140144
EXTRA_DIST += tests/api/test_hmac.h
141145
EXTRA_DIST += tests/api/test_cmac.h
146+
EXTRA_DIST += tests/api/test_kdf.h
142147
EXTRA_DIST += tests/api/test_she.h
143148
EXTRA_DIST += tests/api/test_des3.h
144149
EXTRA_DIST += tests/api/test_chacha.h
@@ -152,7 +157,10 @@ EXTRA_DIST += tests/api/test_ascon.h
152157
EXTRA_DIST += tests/api/test_sm4.h
153158
EXTRA_DIST += tests/api/test_ascon_kats.h
154159
EXTRA_DIST += tests/api/test_wc_encrypt.h
160+
EXTRA_DIST += tests/api/test_coding.h
161+
EXTRA_DIST += tests/api/test_error.h
155162
EXTRA_DIST += tests/api/test_random.h
163+
EXTRA_DIST += tests/api/test_wolfentropy.h
156164
EXTRA_DIST += tests/api/test_wolfmath.h
157165
EXTRA_DIST += tests/api/test_rsa.h
158166
EXTRA_DIST += tests/api/test_dsa.h

0 commit comments

Comments
 (0)