Skip to content

Commit db858fd

Browse files
committed
Merge tag 'v5.2.1-stable' into merge-fips-builds
Check-in FIPS 140-3 PILOT
2 parents b132946 + 3a5e171 commit db858fd

6 files changed

Lines changed: 26 additions & 5 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4570,6 +4570,19 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
45704570
return 0;
45714571
}
45724572

4573+
int wc_AesCtrSetKey(Aes* aes, const byte* key, word32 len,
4574+
const byte* iv, int dir)
4575+
{
4576+
if (aes == NULL) {
4577+
return BAD_FUNC_ARG;
4578+
}
4579+
if (len > sizeof(aes->key)) {
4580+
return BAD_FUNC_ARG;
4581+
}
4582+
4583+
return wc_AesSetKeyLocal(aes, key, len, iv, dir, 0);
4584+
}
4585+
45734586
#endif /* NEED_AES_CTR_SOFT */
45744587

45754588
#endif /* WOLFSSL_AES_COUNTER */

wolfcrypt/src/dh.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ static int GeneratePublicDh(DhKey* key, byte* priv, word32 privSz,
13521352
*pubSz = (word32)mp_unsigned_bin_size(y);
13531353

13541354
mp_clear(y);
1355-
mp_clear(x);
1355+
mp_forcezero(x);
13561356
#if defined(WOLFSSL_SMALL_STACK) && !defined(WOLFSSL_NO_MALLOC)
13571357
XFREE(y, key->heap, DYNAMIC_TYPE_DH);
13581358
XFREE(x, key->heap, DYNAMIC_TYPE_DH);

wolfcrypt/src/hmac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,7 @@ int wolfSSL_GetHmacMaxSize(void)
12331233
ret = wc_HmacUpdate(myHmac, inKey, inKeySz);
12341234
if (ret == 0)
12351235
ret = wc_HmacFinal(myHmac, out);
1236+
ForceZero(myHmac, sizeof(Hmac));
12361237
wc_HmacFree(myHmac);
12371238
}
12381239
#ifdef WOLFSSL_SMALL_STACK
@@ -1324,6 +1325,7 @@ int wolfSSL_GetHmacMaxSize(void)
13241325
n++;
13251326
}
13261327

1328+
ForceZero(myHmac, sizeof(Hmac));
13271329
wc_HmacFree(myHmac);
13281330
#ifdef WOLFSSL_SMALL_STACK
13291331
XFREE(myHmac, NULL, DYNAMIC_TYPE_HMAC);

wolfcrypt/src/kdf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ int wc_SSH_KDF(byte hashId, byte keyId, byte* key, word32 keySz,
863863
}
864864
}
865865

866+
ForceZero(&hash, sizeof(hash));
866867
_HashFree(enmhashId, &hash);
867868

868869
return ret;

wolfssl/wolfcrypt/aes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ WOLFSSL_API int wc_AesEcbDecrypt(Aes* aes, byte* out,
415415
#ifdef WOLFSSL_AES_COUNTER
416416
WOLFSSL_API int wc_AesCtrEncrypt(Aes* aes, byte* out,
417417
const byte* in, word32 sz);
418+
WOLFSSL_API int wc_AesCtrSetKey(Aes* aes, const byte* key, word32 len,
419+
const byte* iv, int dir);
420+
418421
#endif
419422
/* AES-DIRECT */
420423
#if defined(WOLFSSL_AES_DIRECT)

wolfssl/wolfcrypt/fips_test.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ enum FipsCastStateId {
7777
};
7878

7979
enum FipsModeId {
80-
FIPS_MODE_INIT,
81-
FIPS_MODE_NORMAL,
82-
FIPS_MODE_DEGRADED,
83-
FIPS_MODE_FAILED
80+
FIPS_MODE_INIT = 0,
81+
FIPS_MODE_NORMAL = 1,
82+
FIPS_MODE_DEGRADED = 2,
83+
FIPS_MODE_FAILED = 3
8484
};
8585

8686

@@ -92,6 +92,7 @@ WOLFSSL_API int wolfCrypt_SetCb_fips(wolfCrypt_fips_cb cbf);
9292

9393
/* Public get status functions */
9494
WOLFSSL_API int wolfCrypt_GetStatus_fips(void);
95+
WOLFSSL_API int wolfCrypt_GetMode_fips(void);
9596
WOLFSSL_API const char* wolfCrypt_GetCoreHash_fips(void);
9697

9798
#ifdef HAVE_FORCE_FIPS_FAILURE
@@ -105,6 +106,7 @@ WOLFSSL_LOCAL int DoKnownAnswerTests(char* base16_hash, int base16_hashSz); /* F
105106

106107
WOLFSSL_API int wc_RunCast_fips(int type);
107108
WOLFSSL_API int wc_GetCastStatus_fips(int type);
109+
WOLFSSL_API int wc_RunAllCast_fips(void);
108110

109111
#ifdef __cplusplus
110112
} /* extern "C" */

0 commit comments

Comments
 (0)