Skip to content

Commit 9781c1f

Browse files
Merge pull request #7999 from douzzer/20240920-fixes
20240920-fixes
2 parents baab334 + 55cd8a8 commit 9781c1f

4 files changed

Lines changed: 44 additions & 38 deletions

File tree

configure.ac

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,7 +4083,7 @@ AC_ARG_ENABLE([compkey],
40834083
)
40844084

40854085
if (test "$ENABLED_WPAS" = "yes" || test "$ENABLED_OPENSSLALL" = "yes") &&
4086-
(test "$HAVE_FIPS_VERSION" != "5" || test "$FIPS_VERSION" = "v5-dev")
4086+
(test "$HAVE_FIPS_VERSION" != "5")
40874087
then
40884088
ENABLED_COMPKEY=yes
40894089
fi
@@ -5434,7 +5434,7 @@ AS_CASE([$FIPS_VERSION],
54345434
[ENABLED_KEYGEN="yes"; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_KEY_GEN"])
54355435
54365436
AS_IF([test "$ENABLED_COMPKEY" = "yes" &&
5437-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_compkey" != "yes")],
5437+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_compkey" = "yes")],
54385438
[AC_MSG_WARN([Forcing off compkey for FIPS ${FIPS_VERSION}.])
54395439
ENABLED_COMPKEY="no"])
54405440
@@ -5452,13 +5452,13 @@ AS_CASE([$FIPS_VERSION],
54525452
54535453
# Shake128 is a SHA-3 algorithm outside the v5 FIPS algorithm list
54545454
AS_IF([test "$ENABLED_SHAKE128" != "no" &&
5455-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake128" != "yes")],
5455+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_shake128" = "yes")],
54565456
[AC_MSG_WARN([Forcing off shake128 for FIPS ${FIPS_VERSION}.])
54575457
ENABLED_SHAKE128=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE128"])
54585458
54595459
# Shake256 is a SHA-3 algorithm outside the v5 FIPS algorithm list
54605460
AS_IF([test "$ENABLED_SHAKE256" != "no" &&
5461-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_shake256" != "yes")],
5461+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_shake256" = "yes")],
54625462
[AC_MSG_WARN([Forcing off shake256 for FIPS ${FIPS_VERSION}.])
54635463
ENABLED_SHAKE256=no; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_SHAKE256"])
54645464
@@ -5470,7 +5470,7 @@ AS_CASE([$FIPS_VERSION],
54705470
[ENABLED_AESCCM="yes"; AM_CFLAGS="$AM_CFLAGS -DHAVE_AESCCM"])
54715471
54725472
AS_IF([test "$ENABLED_AESXTS" = "yes" &&
5473-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesxts" != "yes")],
5473+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_aesxts" = "yes")],
54745474
[AC_MSG_WARN([Forcing off aesxts for FIPS ${FIPS_VERSION}.])
54755475
ENABLED_AESXTS="no"])
54765476
@@ -5510,7 +5510,7 @@ AS_CASE([$FIPS_VERSION],
55105510
55115511
# AES-GCM streaming isn't part of the v5 FIPS suite.
55125512
AS_IF([test "$ENABLED_AESGCM_STREAM" = "yes" &&
5513-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_aesgcm_stream" != "yes")],
5513+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_aesgcm_stream" = "yes")],
55145514
[AC_MSG_WARN([Forcing off aesgcm-stream for FIPS ${FIPS_VERSION}.])
55155515
ENABLED_AESGCM_STREAM="no"])
55165516
@@ -5525,12 +5525,12 @@ AS_CASE([$FIPS_VERSION],
55255525
[ENABLED_AESOFB="yes"; AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_AES_OFB"])])
55265526
55275527
AS_IF([test "$ENABLED_SRTP" != "no" &&
5528-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_srtp" != "yes")],
5528+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_srtp" = "yes")],
55295529
[AC_MSG_WARN([Forcing off srtp for FIPS ${FIPS_VERSION}.])
55305530
ENABLED_SRTP="no"])
55315531
55325532
AS_IF([test "$ENABLED_SRTP_KDF" != "no" &&
5533-
(test "$FIPS_VERSION" != "v5-dev" || test "$enable_srtp_kdf" != "yes")],
5533+
! (test "$FIPS_VERSION" = "v5-dev" && test "$enable_srtp_kdf" = "yes")],
55345534
[AC_MSG_WARN([Forcing off srtp-kdf for FIPS ${FIPS_VERSION}.])
55355535
ENABLED_SRTP_KDF="no"])
55365536

src/tls13.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int Tls13HKDFExpandLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
221221
#endif
222222
(void)ssl;
223223
PRIVATE_KEY_UNLOCK();
224-
#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
224+
#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
225225
ret = wc_Tls13_HKDF_Expand_Label_ex(okm, okmLen, prk, prkLen,
226226
protocol, protocolLen,
227227
label, labelLen,
@@ -261,7 +261,7 @@ static int Tls13HKDFExpandKeyLabel(WOLFSSL* ssl, byte* okm, word32 okmLen,
261261
return ret;
262262
#endif
263263

264-
#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
264+
#if !defined(HAVE_FIPS) || (defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
265265
ret = wc_Tls13_HKDF_Expand_Label_ex(okm, okmLen, prk, prkLen,
266266
protocol, protocolLen,
267267
label, labelLen,
@@ -1137,7 +1137,7 @@ static int Tls13_HKDF_Extract(WOLFSSL *ssl, byte* prk, const byte* salt,
11371137
#endif
11381138
{
11391139
#if !defined(HAVE_FIPS) || \
1140-
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
1140+
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
11411141
ret = wc_Tls13_HKDF_Extract_ex(prk, salt, (word32)saltLen, ikm, (word32)ikmLen, digest,
11421142
ssl->heap, ssl->devId);
11431143
#else
@@ -4840,7 +4840,7 @@ static int EchCheckAcceptance(WOLFSSL* ssl, const byte* input,
48404840
if (ret == 0) {
48414841
PRIVATE_KEY_UNLOCK();
48424842
#if !defined(HAVE_FIPS) || \
4843-
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
4843+
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
48444844
ret = wc_HKDF_Extract_ex(digestType, zeros, (word32)digestSize,
48454845
ssl->arrays->clientRandomInner, RAN_LEN, expandLabelPrk,
48464846
ssl->heap, ssl->devId);
@@ -4978,7 +4978,7 @@ static int EchWriteAcceptance(WOLFSSL* ssl, byte* output,
49784978
if (ret == 0) {
49794979
PRIVATE_KEY_UNLOCK();
49804980
#if !defined(HAVE_FIPS) || \
4981-
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(5,3))
4981+
(defined(FIPS_VERSION_GE) && FIPS_VERSION_GE(6,0))
49824982
ret = wc_HKDF_Extract_ex(digestType, zeros, (word32)digestSize,
49834983
ssl->arrays->clientRandom, RAN_LEN, expandLabelPrk,
49844984
ssl->heap, ssl->devId);

wolfcrypt/src/error.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ const char* wc_GetErrorString(int error)
364364
return "ECC is point on curve failed";
365365

366366
case ECC_INF_E:
367-
return " ECC point at infinity error";
367+
return "ECC point at infinity error";
368368

369369
case ECC_OUT_OF_RANGE_E:
370-
return " ECC Qx or Qy out of range error";
370+
return "ECC Qx or Qy out of range error";
371371

372372
case ECC_PRIV_KEY_E:
373-
return " ECC private key is not valid error";
373+
return "ECC private key is not valid error";
374374

375375
case SRP_CALL_ORDER_E:
376376
return "SRP function called in the wrong order error";

wolfcrypt/test/test.c

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,16 @@ static void render_error_message(const char* msg, wc_test_ret_t es)
810810
#ifdef NO_ERROR_STRINGS
811811
err_sys_printf("%s error L=%d code=%d\n", msg,
812812
WC_TEST_RET_DEC_LN(es), -WC_TEST_RET_DEC_I(es));
813+
#elif defined(WOLFCRYPT_ONLY) || !defined(WOLFSSL_TYPES_DEFINED)
814+
err_sys_printf("%s error L=%d code=%d (%s)\n", msg,
815+
WC_TEST_RET_DEC_LN(es), -WC_TEST_RET_DEC_I(es),
816+
wc_GetErrorString(-WC_TEST_RET_DEC_I(es))
817+
);
813818
#else
814819
err_sys_printf("%s error L=%d code=%d (%s)\n", msg,
815820
WC_TEST_RET_DEC_LN(es), -WC_TEST_RET_DEC_I(es),
816-
wc_GetErrorString(-WC_TEST_RET_DEC_I(es)));
821+
wolfSSL_ERR_reason_error_string(-WC_TEST_RET_DEC_I(es))
822+
);
817823
#endif
818824
break;
819825
case WC_TEST_RET_TAG_ERRNO:
@@ -29327,7 +29333,7 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng)
2932729333
0xA8
2932829334
};
2932929335
#endif
29330-
#ifdef WOLFSSL_SHA384
29336+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2933129337
WOLFSSL_SMALL_STACK_STATIC const byte expSig384[] = {
2933229338
0x30, 0x44, /* CONSTRUCTED SEQUENCE: (0x20 | 0x10) = 68 bytes */
2933329339
0x02, 0x20, /* ASN_INTEGER = 0x02 (32 bytes) - SIG R */
@@ -29342,7 +29348,7 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng)
2934229348
0x26, 0x1f, 0x13, 0xab, 0xde, 0x94, 0x09, 0x54
2934329349
};
2934429350
#endif
29345-
#ifdef WOLFSSL_SHA512
29351+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2934629352
WOLFSSL_SMALL_STACK_STATIC const byte expSig512[] = {
2934729353
0x30, 0x45, /* CONSTRUCTED SEQUENCE: (0x20 | 0x10) = 68 bytes */
2934829354
0x02, 0x21, /* ASN_INTEGER = 0x02 (32 bytes) - SIG R */
@@ -29385,15 +29391,15 @@ static wc_test_ret_t ecc_test_deterministic_k(WC_RNG* rng)
2938529391
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
2938629392
#endif /* !NO_SHA256 */
2938729393

29388-
#ifdef WOLFSSL_SHA384
29394+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2938929395
/* Test for SHA2-384 */
2939029396
ret = ecdsa_test_deterministic_k_sig(key, WC_HASH_TYPE_SHA384, msg, rng,
2939129397
expSig384, sizeof(expSig384));
2939229398
if (ret != 0)
2939329399
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
2939429400
#endif /* WOLFSSL_SHA384 */
2939529401

29396-
#ifdef WOLFSSL_SHA512
29402+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2939729403
/* Test for SHA2-512 */
2939829404
ret = ecdsa_test_deterministic_k_sig(key, WC_HASH_TYPE_SHA512, msg, rng,
2939929405
expSig512, sizeof(expSig512));
@@ -29491,15 +29497,15 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng)
2949129497
"F3AA443FB107745BF4BD77CB3891674632068A10CA67E3D45DB2266FA7D1FEEB"
2949229498
"EFDC63ECCD1AC42EC0CB8668A4FA0AB0";
2949329499
#endif
29494-
#ifdef WOLFSSL_SHA384
29500+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2949529501
WOLFSSL_SMALL_STACK_STATIC const char* expRstr384 =
2949629502
"94EDBB92A5ECB8AAD4736E56C691916B3F88140666CE9FA73D64C4EA95AD133C"
2949729503
"81A648152E44ACF96E36DD1E80FABE46";
2949829504
WOLFSSL_SMALL_STACK_STATIC const char* expSstr384 =
2949929505
"99EF4AEB15F178CEA1FE40DB2603138F130E740A19624526203B6351D0A3A94F"
2950029506
"A329C145786E679E7B82C71A38628AC8";
2950129507
#endif
29502-
#ifdef WOLFSSL_SHA512
29508+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2950329509
WOLFSSL_SMALL_STACK_STATIC const char* expRstr512 =
2950429510
"ED0959D5880AB2D869AE7F6C2915C6D60F96507F9CB3E047C0046861DA4A799C"
2950529511
"FE30F35CC900056D7C99CD7882433709";
@@ -29549,27 +29555,27 @@ static wc_test_ret_t ecc384_test_deterministic_k(WC_RNG* rng)
2954929555
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA256, msg, rng,
2955029556
r, s, expR, expS);
2955129557
if (ret != 0)
29552-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29558+
ERROR_OUT(ret, done);
2955329559
#endif /* NO_SHA256 */
2955429560

29555-
#ifdef WOLFSSL_SHA384
29561+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2955629562
/* Test for SHA2-384 */
2955729563
mp_read_radix(expR, expRstr384, MP_RADIX_HEX);
2955829564
mp_read_radix(expS, expSstr384, MP_RADIX_HEX);
2955929565
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA384, msg, rng,
2956029566
r, s, expR, expS);
2956129567
if (ret != 0)
29562-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29568+
ERROR_OUT(ret, done);
2956329569
#endif /* WOLFSSL_SHA384 */
2956429570

29565-
#ifdef WOLFSSL_SHA512
29571+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2956629572
/* Test for SHA2-512 */
2956729573
mp_read_radix(expR, expRstr512, MP_RADIX_HEX);
2956829574
mp_read_radix(expS, expSstr512, MP_RADIX_HEX);
2956929575
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA512, msg, rng,
2957029576
r, s, expR, expS);
2957129577
if (ret != 0)
29572-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29578+
ERROR_OUT(ret, done);
2957329579
#endif /* WOLFSSL_SHA512 */
2957429580

2957529581
done:
@@ -29630,7 +29636,7 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng)
2963029636
"E4F7A72930B1BC06DBE22CE3F58264AFD23704CBB63B29B931F7DE6C9D949A7E"
2963129637
"CFC";
2963229638
#endif
29633-
#ifdef WOLFSSL_SHA384
29639+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2963429640
WOLFSSL_SMALL_STACK_STATIC const char* expRstr384 =
2963529641
"1EA842A0E17D2DE4F92C15315C63DDF72685C18195C2BB95E572B9C5136CA4B4"
2963629642
"B576AD712A52BE9730627D16054BA40CC0B8D3FF035B12AE75168397F5D50C67"
@@ -29640,7 +29646,7 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng)
2964029646
"FDE143FA85DC394A7DEE766523393784484BDF3E00114A1C857CDE1AA203DB65"
2964129647
"D61";
2964229648
#endif
29643-
#ifdef WOLFSSL_SHA512
29649+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2964429650
WOLFSSL_SMALL_STACK_STATIC const char* expRstr512 =
2964529651
"0C328FAFCBD79DD77850370C46325D987CB525569FB63C5D3BC53950E6D4C5F1"
2964629652
"74E25A1EE9017B5D450606ADD152B534931D7D4E8455CC91F9B15BF05EC36E37"
@@ -29693,27 +29699,27 @@ static wc_test_ret_t ecc521_test_deterministic_k(WC_RNG* rng)
2969329699
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA256, msg, rng,
2969429700
r, s, expR, expS);
2969529701
if (ret != 0)
29696-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29702+
ERROR_OUT(ret, done);
2969729703
#endif /* NO_SHA256 */
2969829704

29699-
#ifdef WOLFSSL_SHA384
29705+
#if defined(WOLFSSL_SHA384) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2970029706
/* Test for SHA2-384 */
2970129707
mp_read_radix(expR, expRstr384, MP_RADIX_HEX);
2970229708
mp_read_radix(expS, expSstr384, MP_RADIX_HEX);
2970329709
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA384, msg, rng,
2970429710
r, s, expR, expS);
2970529711
if (ret != 0)
29706-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29712+
ERROR_OUT(ret, done);
2970729713
#endif /* WOLFSSL_SHA384 */
2970829714

29709-
#ifdef WOLFSSL_SHA512
29715+
#if defined(WOLFSSL_SHA512) && (!defined(HAVE_FIPS) || FIPS_VERSION_GE(6,0))
2971029716
/* Test for SHA2-512 */
2971129717
mp_read_radix(expR, expRstr512, MP_RADIX_HEX);
2971229718
mp_read_radix(expS, expSstr512, MP_RADIX_HEX);
2971329719
ret = ecdsa_test_deterministic_k_rs(key, WC_HASH_TYPE_SHA512, msg, rng,
2971429720
r, s, expR, expS);
2971529721
if (ret != 0)
29716-
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), done);
29722+
ERROR_OUT(ret, done);
2971729723
#endif /* WOLFSSL_SHA512 */
2971829724

2971929725
done:
@@ -48821,7 +48827,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cmac_test(void)
4882148827

4882248828
XMEMSET(tag, 0, sizeof(tag));
4882348829
tagSz = sizeof(tag);
48824-
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(5, 3)
48830+
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(6, 0)
4882548831
ret = wc_AesCmacGenerate_ex(cmac, tag, &tagSz, tc->m, tc->mSz,
4882648832
tc->k, tc->kSz, NULL, devId);
4882748833
#else
@@ -48832,7 +48838,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cmac_test(void)
4883248838
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
4883348839
if (XMEMCMP(tag, tc->t, AES_BLOCK_SIZE) != 0)
4883448840
ERROR_OUT(WC_TEST_RET_ENC_NC, out);
48835-
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(5, 3)
48841+
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(6, 0)
4883648842
ret = wc_AesCmacVerify_ex(cmac, tc->t, tc->tSz, tc->m, tc->mSz,
4883748843
tc->k, tc->kSz, HEAP_HINT, devId);
4883848844
#else
@@ -48842,7 +48848,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t cmac_test(void)
4884248848
if (ret != 0)
4884348849
ERROR_OUT(WC_TEST_RET_ENC_EC(ret), out);
4884448850

48845-
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(5, 3)
48851+
#if !defined(HAVE_FIPS) || FIPS_VERSION_GE(6, 0)
4884648852
/* Test that keyless generate with init is the same */
4884748853
XMEMSET(tag, 0, sizeof(tag));
4884848854
tagSz = sizeof(tag);

0 commit comments

Comments
 (0)