Skip to content

Commit c4f4110

Browse files
adjust test case for CI tests after additional sanity check
1 parent 915c59c commit c4f4110

2 files changed

Lines changed: 53 additions & 15 deletions

File tree

tests/api/test_evp_cipher.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ int test_wolfssl_EVP_sm4_ecb(void)
21952195
};
21962196
byte cipherText[sizeof(plainText) + SM4_BLOCK_SIZE];
21972197
byte decryptedText[sizeof(plainText) + SM4_BLOCK_SIZE];
2198-
EVP_CIPHER_CTX* ctx;
2198+
EVP_CIPHER_CTX* ctx = NULL;
21992199
int outSz;
22002200

22012201
XMEMSET(key, 0, sizeof(key));
@@ -2251,7 +2251,7 @@ int test_wolfssl_EVP_sm4_cbc(void)
22512251
};
22522252
byte cipherText[sizeof(plainText) + SM4_BLOCK_SIZE];
22532253
byte decryptedText[sizeof(plainText) + SM4_BLOCK_SIZE];
2254-
EVP_CIPHER_CTX* ctx;
2254+
EVP_CIPHER_CTX* ctx = NULL;
22552255
int outSz;
22562256

22572257
XMEMSET(key, 0, sizeof(key));
@@ -2319,7 +2319,7 @@ int test_wolfssl_EVP_sm4_ctr(void)
23192319
byte plainText[] = {0xDE, 0xAD, 0xBE, 0xEF};
23202320
byte cipherText[sizeof(plainText)];
23212321
byte decryptedText[sizeof(plainText)];
2322-
EVP_CIPHER_CTX* ctx;
2322+
EVP_CIPHER_CTX* ctx = NULL;
23232323
int outSz;
23242324

23252325
XMEMSET(key, 0, sizeof(key));

wolfcrypt/test/test.c

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36427,13 +36427,30 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
3642736427
ret = wc_ecc_sign_hash(digest, ECC_DIGEST_SIZE, sig, &x, rng,
3642836428
userA);
3642936429
} while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
36430-
if (ret == 0) {
36431-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36430+
#ifdef WOLFSSL_SM2
36431+
if (curve_id == ECC_SM2P256V1) {
36432+
/* SM2 does not reject zero-hash signing */
36433+
if (ret != 0)
36434+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
3643236435
}
36433-
else {
36434-
/* reset ret value, was expecting a failure */
36435-
ret = 0;
36436+
else
36437+
#endif
36438+
#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(7,0,0)
36439+
{
36440+
if (ret != 0)
36441+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
3643636442
}
36443+
#else
36444+
{
36445+
if (ret == 0) {
36446+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36447+
}
36448+
else {
36449+
/* reset ret value, was expecting a failure */
36450+
ret = 0;
36451+
}
36452+
}
36453+
#endif
3643736454
TEST_SLEEP();
3643836455

3643936456
#ifdef HAVE_ECC_VERIFY
@@ -36446,15 +36463,36 @@ static wc_test_ret_t ecc_test_curve_size(WC_RNG* rng, int keySize, int testVerif
3644636463
ret = wc_ecc_verify_hash(sig, x, digest, ECC_DIGEST_SIZE,
3644736464
&verify, userA);
3644836465
} while (ret == WC_NO_ERR_TRACE(WC_PENDING_E));
36449-
if (ret == 0) {
36450-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36466+
#ifdef WOLFSSL_SM2
36467+
if (curve_id == ECC_SM2P256V1) {
36468+
/* SM2 zero-hash sign succeeded, so verify should succeed too */
36469+
if (ret != 0)
36470+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36471+
if (verify != 1)
36472+
ERROR_OUT(WC_TEST_RET_ENC_NC, done);
3645136473
}
36452-
else {
36453-
/* reset ret value, was expecting a failure */
36454-
ret = 0;
36474+
else
36475+
#endif
36476+
#if defined(HAVE_FIPS) && FIPS_VERSION3_LT(7,0,0)
36477+
{
36478+
if (ret != 0)
36479+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36480+
if (verify != 1)
36481+
ERROR_OUT(WC_TEST_RET_ENC_NC, done);
3645536482
}
36456-
if (verify == 1)
36457-
ERROR_OUT(WC_TEST_RET_ENC_NC, done);
36483+
#else
36484+
{
36485+
if (ret == 0) {
36486+
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
36487+
}
36488+
else {
36489+
/* reset ret value, was expecting a failure */
36490+
ret = 0;
36491+
}
36492+
if (verify == 1)
36493+
ERROR_OUT(WC_TEST_RET_ENC_NC, done);
36494+
}
36495+
#endif
3645836496
TEST_SLEEP();
3645936497
#endif /* HAVE_ECC_VERIFY */
3646036498

0 commit comments

Comments
 (0)