Skip to content

Commit 7a29b1e

Browse files
committed
add comments explaining dependence on idempotency for race-free dynamics re checkedAESNI, haveAESNI, intel_flags, and sha_method. see #7863.
1 parent 1fa2d2d commit 7a29b1e

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,10 @@ block cipher mechanism that uses n-bit binary string parameter key with 128-bits
613613
#define AESNI_ALIGN 16
614614
#endif
615615

616+
/* note that all write access to these static variables must be idempotent,
617+
* as arranged by Check_CPU_support_AES(), else they will be susceptible to
618+
* data races.
619+
*/
616620
static int checkedAESNI = 0;
617621
static int haveAESNI = 0;
618622
static word32 intel_flags = 0;

wolfcrypt/src/sha256.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ static int InitSha256(wc_Sha256* sha256)
408408
SHA256_SSE2, SHA256_C };
409409

410410
#ifndef WC_C_DYNAMIC_FALLBACK
411+
/* note that all write access to this static variable must be idempotent,
412+
* as arranged by Sha256_SetTransform(), else it will be susceptible to
413+
* data races.
414+
*/
411415
static enum sha_methods sha_method = SHA256_UNSET;
412416
#endif
413417

wolfcrypt/src/sha512.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ static int InitSha512_256(wc_Sha512* sha512)
489489
SHA512_AVX1_RORX, SHA512_AVX2_RORX, SHA512_C };
490490

491491
#ifndef WC_C_DYNAMIC_FALLBACK
492+
/* note that all write access to this static variable must be idempotent,
493+
* as arranged by Sha512_SetTransform(), else it will be susceptible to
494+
* data races.
495+
*/
492496
static enum sha_methods sha_method = SHA512_UNSET;
493497
#endif
494498

0 commit comments

Comments
 (0)