Skip to content

Commit 03cee6f

Browse files
committed
tests/api/test_ed25519.c and tests/api/test_ed448.c: add missing FIPS v7+ gating in test_wc_ed25519_export() and test_wc_ed448_export().
wolfcrypt/test/test.c: in aes_cbc_test(), use unconditional static on msg4 and verify4 to work around gcc optimizer bug (probably same bug as noted in ac11279).
1 parent 490c106 commit 03cee6f

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

tests/api/test_ed25519.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,17 @@ int test_wc_ed25519_export(void)
347347
XMEMSET(&rng, 0, sizeof(WC_RNG));
348348

349349
ExpectIntEQ(wc_ed25519_init(&key), 0);
350+
351+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0)
350352
/* Reject export when private key not set. */
351353
PRIVATE_KEY_UNLOCK();
352354
ExpectIntEQ(wc_ed25519_export_private_only(&key, priv, &privSz),
353355
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
354356
ExpectIntEQ(wc_ed25519_export_private(&key, priv, &privSz),
355357
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
356358
PRIVATE_KEY_LOCK();
359+
#endif /* !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0) */
360+
357361
ExpectIntEQ(wc_InitRng(&rng), 0);
358362
#ifdef HAVE_ED25519_MAKE_KEY
359363
ExpectIntEQ(wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key), 0);
@@ -392,12 +396,16 @@ int test_wc_ed25519_export(void)
392396
wc_ed25519_free(&key);
393397
ExpectIntEQ(wc_ed25519_init(&key), 0);
394398
ExpectIntEQ(wc_ed25519_import_public(pub, pubSz, &key), 0);
399+
400+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0)
395401
PRIVATE_KEY_UNLOCK();
396402
ExpectIntEQ(wc_ed25519_export_private_only(&key, priv, &privSz),
397403
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
398404
ExpectIntEQ(wc_ed25519_export_private(&key, priv, &privSz),
399405
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
400406
PRIVATE_KEY_LOCK();
407+
#endif /* !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0) */
408+
401409
#endif
402410

403411
DoExpectIntEQ(wc_FreeRng(&rng), 0);

tests/api/test_ed448.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,17 @@ int test_wc_ed448_export(void)
324324
XMEMSET(&rng, 0, sizeof(WC_RNG));
325325

326326
ExpectIntEQ(wc_ed448_init(&key), 0);
327+
328+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0)
327329
/* Reject export when private key not set. */
328330
PRIVATE_KEY_UNLOCK();
329331
ExpectIntEQ(wc_ed448_export_private_only(&key, priv, &privSz),
330332
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
331333
ExpectIntEQ(wc_ed448_export_private(&key, priv, &privSz),
332334
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
333335
PRIVATE_KEY_LOCK();
336+
#endif /* !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0) */
337+
334338
ExpectIntEQ(wc_InitRng(&rng), 0);
335339
ExpectIntEQ(wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key), 0);
336340

@@ -364,12 +368,16 @@ int test_wc_ed448_export(void)
364368
wc_ed448_free(&key);
365369
ExpectIntEQ(wc_ed448_init(&key), 0);
366370
ExpectIntEQ(wc_ed448_import_public(pub, pubSz, &key), 0);
371+
372+
#if !defined(HAVE_FIPS) || FIPS_VERSION3_GE(7,0,0)
367373
PRIVATE_KEY_UNLOCK();
368374
ExpectIntEQ(wc_ed448_export_private_only(&key, priv, &privSz),
369375
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
370376
ExpectIntEQ(wc_ed448_export_private(&key, priv, &privSz),
371377
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
372378
PRIVATE_KEY_LOCK();
379+
#endif /* !HAVE_FIPS || FIPS_VERSION3_GE(7,0,0) */
380+
373381
#endif
374382

375383
DoExpectIntEQ(wc_FreeRng(&rng), 0);

wolfcrypt/test/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16840,7 +16840,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_cbc_test(void)
1684016840
* the wrong ciphertext block into aes->reg between calls (e.g. the
1684116841
* first block instead of the last) will fail the second KAT. */
1684216842
{
16843-
WOLFSSL_SMALL_STACK_STATIC const byte msg4[] = {
16843+
static const byte msg4[] = {
1684416844
0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,
1684516845
0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a,
1684616846
0xae,0x2d,0x8a,0x57,0x1e,0x03,0xac,0x9c,
@@ -16850,7 +16850,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t aes_cbc_test(void)
1685016850
0xf6,0x9f,0x24,0x45,0xdf,0x4f,0x9b,0x17,
1685116851
0xad,0x2b,0x41,0x7b,0xe6,0x6c,0x37,0x10
1685216852
};
16853-
WOLFSSL_SMALL_STACK_STATIC const byte verify4[] = {
16853+
static const byte verify4[] = {
1685416854
0x76,0x49,0xab,0xac,0x81,0x19,0xb2,0x46,
1685516855
0xce,0xe9,0x8e,0x9b,0x12,0xe9,0x19,0x7d,
1685616856
0x50,0x86,0xcb,0x9b,0x50,0x72,0x19,0xee,

0 commit comments

Comments
 (0)