Skip to content

Commit ac779dc

Browse files
committed
wolfssl: allow fallback from rdseed
1 parent 065b3e4 commit ac779dc

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

windows_32.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- git apply ../../wolfssl/0008-intel-illegal-instruction.patch
2323
- git apply ../../wolfssl/0009-reverse-only-with-avx12.patch
2424
- git apply ../../wolfssl/0010-rng-move-debug-messages-while-preserving-semantics.patch
25+
- git apply ../../wolfssl/0011-random-allow-rdseed-to-fallback-on-windows.patch
2526
- "cp ../../windows/wolfssl-user_settings-common.h wolfssl/user_settings.h"
2627
- "cat ../../windows/wolfssl-user_settings-32.h >> wolfssl/user_settings.h"
2728
- "cp -f wolfssl/user_settings.h IDE/WIN/user_settings.h"

windows_64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- git apply ../../wolfssl/0008-intel-illegal-instruction.patch
2323
- git apply ../../wolfssl/0009-reverse-only-with-avx12.patch
2424
- git apply ../../wolfssl/0010-rng-move-debug-messages-while-preserving-semantics.patch
25+
- git apply ../../wolfssl/0011-random-allow-rdseed-to-fallback-on-windows.patch
2526
- "cp ../../windows/wolfssl-user_settings-common.h wolfssl/user_settings.h"
2627
- "cat ../../windows/wolfssl-user_settings-64.h >> wolfssl/user_settings.h"
2728
- "cp -f wolfssl/user_settings.h IDE/WIN/user_settings.h"

windows_64_multithread.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- git apply ../../wolfssl/0008-intel-illegal-instruction.patch
2323
- git apply ../../wolfssl/0009-reverse-only-with-avx12.patch
2424
- git apply ../../wolfssl/0010-rng-move-debug-messages-while-preserving-semantics.patch
25+
- git apply ../../wolfssl/0011-random-allow-rdseed-to-fallback-on-windows.patch
2526
- "cp ../../windows/wolfssl-user_settings-common.h wolfssl/user_settings.h"
2627
- "cat ../../windows/wolfssl-user_settings-64.h >> wolfssl/user_settings.h"
2728
- "cat ../../windows/wolfssl-user_settings-multithread.h >> wolfssl/user_settings.h"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
From b84924d610c609673e00f61630e53039ae209a61 Mon Sep 17 00:00:00 2001
2+
From: Raihaan Shouhell <raihaan.shouhell@kape.com>
3+
Date: Tue, 18 Mar 2025 13:09:33 +0800
4+
Subject: [PATCH] random: allow rdseed to fallback on windows
5+
6+
---
7+
wolfcrypt/src/random.c | 26 ++++++++++++++++++++------
8+
1 file changed, 20 insertions(+), 6 deletions(-)
9+
10+
diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c
11+
index 7c32cc024..cdd7eb73a 100644
12+
--- a/wolfcrypt/src/random.c
13+
+++ b/wolfcrypt/src/random.c
14+
@@ -2695,17 +2695,31 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
15+
16+
#ifdef HAVE_INTEL_RDSEED
17+
if (IS_INTEL_RDSEED(intel_flags)) {
18+
- if (!wc_GenerateSeed_IntelRD(NULL, output, sz)) {
19+
- /* success, we're done */
20+
- return 0;
21+
- }
22+
+ #if defined(DEBUG_WOLFSSL)
23+
+ WOLFSSL_MSG_EX("Using RDSEED");
24+
+ #endif
25+
+ if (!wc_GenerateSeed_IntelRD(NULL, output, sz)) {
26+
+ if (wc_RNG_TestSeed(output, sz) == 0) {
27+
+ /* success, we're done */
28+
+ return 0;
29+
+ }
30+
+ #if defined(DEBUG_WOLFSSL)
31+
+ else {
32+
+ WOLFSSL_MSG_EX("Using RDSEED returned bad data");
33+
+ }
34+
+ #endif
35+
+ }
36+
#ifdef FORCE_FAILURE_RDSEED
37+
- /* don't fall back to CryptoAPI */
38+
- return READ_RAN_E;
39+
+ /* don't fall back to CryptoAPI */
40+
+ return READ_RAN_E;
41+
#endif
42+
}
43+
#endif /* HAVE_INTEL_RDSEED */
44+
45+
+ #if defined(DEBUG_WOLFSSL)
46+
+ WOLFSSL_MSG_EX("Using WinCryptRandom");
47+
+ #endif
48+
+
49+
if(!CryptAcquireContext(&os->handle, 0, 0, PROV_RSA_FULL,
50+
CRYPT_VERIFYCONTEXT))
51+
return WINCRYPT_E;
52+
--
53+
2.48.1
54+

0 commit comments

Comments
 (0)