Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/configs/os-check-linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
"user_settings": "IDE/m33mu-falcon-verify/user_settings.h",
"configure": ["--enable-usersettings", "--disable-examples",
"--disable-crypttests", "--disable-shared",
"CPPFLAGS=-DWOLFCRYPT_ONLY -DHAVE_HASHDRBG -DWC_RESEED_INTERVAL=1000000 -DWOLFSSL_NO_GETPID"],
"CPPFLAGS=-DWOLFCRYPT_ONLY -DHAVE_HASHDRBG -DWC_RESEED_INTERVAL=1000000 -DWOLFSSL_NO_GETPID -DWOLFSSL_ACCEPT_WEAK_ENTROPY"],
"check": false},
{"name": "no-server-no-client-auth", "minutes": 1.0,
"configure": ["CPPFLAGS=-DNO_WOLFSSL_SERVER -DWOLFSSL_NO_CLIENT_AUTH"]},
Expand Down Expand Up @@ -598,7 +598,7 @@
"configure": ["--enable-postauth", "--enable-sessioncerts"]},
{"name": "leanpsk",
"comment": "The NO_DEV_RANDOM seed path includes no system headers, so this catches an undeclared getpid() on GCC 13 too. The test-seed #warning fails -Werror and -pedantic, so extra_cflags repeats the global set minus -pedantic (and -Wno-overlength-strings, which only matters with it) and downgrades the #warning.",
"configure": ["--enable-leanpsk"],
"configure": ["--enable-leanpsk", "--enable-weak-entropy"],
"extra_cflags": "-Wdeclaration-after-statement -Wnull-dereference -DTEST_LIBWOLFSSL_SOURCES_INCLUSION_SEQUENCE -Werror=implicit-function-declaration -Wno-error=cpp",
"check": false,
"run": [["./wolfcrypt/test/testwolfcrypt"]]}
Expand Down
34 changes: 17 additions & 17 deletions .github/membrowse-targets.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .github/workflows/arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ jobs:
# ** END ** Install wolfSSL Arduino library
- name: Opt in to test-only Arduino entropy
if: matrix.fqbn != 'arduino:sam:arduino_due_x'
run: |
settings="$ARDUINO_ROOT/wolfssl/src/user_settings.h"
test -f "$settings"
sed -i '1i#define WOLFSSL_ACCEPT_WEAK_ENTROPY /* CI compile test only */' "$settings"
- name: List installed Arduino libraries
run: arduino-cli lib list

Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/entropy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Entropy Regression Tests

# START OF COMMON SECTION
on:
push:
branches: [ 'master', 'main', 'release/**' ]
pull_request:
branches: [ '*' ]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# END OF COMMON SECTION

jobs:
entropy:
if: github.repository_owner == 'wolfssl'
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Entropy regression tests
run: >-
python3 -m unittest
tests.weak_entropy_defaults
tests.arduino_entropy_guard
tests.cypress_trng_failure
tests.copilot_entropy_review
-v
8 changes: 8 additions & 0 deletions .github/workflows/pic32mz-sim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ jobs:
- name: Clone PIC32MZ simulator
run: git clone --depth 1 https://github.com/wolfSSL/simulators simulators

- name: Opt in to test-only PIC32MZ entropy
run: |
cp simulators/PIC32MZSim/firmware/common/user_settings.h \
"$RUNNER_TEMP/pic32mz-user-settings-ci.h"
sed -i '1i#define WOLFSSL_ACCEPT_WEAK_ENTROPY /* simulator only */' \
"$RUNNER_TEMP/pic32mz-user-settings-ci.h"
- uses: docker/setup-buildx-action@v4

- name: Log in to ghcr (cache refresh on cron/manual dispatch)
Expand All @@ -98,5 +105,6 @@ jobs:
run: |
docker run --rm \
-v "${{ github.workspace }}/wolfssl:/opt/wolfssl:ro" \
-v "$RUNNER_TEMP/pic32mz-user-settings-ci.h:/app/firmware/common/user_settings.h:ro" \
${{ matrix.image_tag }} \
/app/scripts/${{ matrix.script }}
7 changes: 7 additions & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
--user-settings-include . \
--user-settings-include IDE/GCC-ARM/Header \
--user-settings-define WOLFSSL_USER_SETTINGS \
--user-settings-define WOLFSSL_ACCEPT_WEAK_ENTROPY \
--user-settings-define NO_STDINT_H \
--user-settings-define WOLFSSL_NO_ASSERT_H \
--srcs wolfcrypt/src/aes.c \
Expand Down Expand Up @@ -187,6 +188,8 @@ jobs:
cdx = json.load(f)
props = {p['name']: p['value']
for p in cdx['metadata']['component']['properties']}
assert props.get('wolfssl:security:weak-entropy') == 'permitted'
assert props.get('wolfssl:security:weak-entropy-note', '').startswith('WARNING:')
assert props.get('wolfssl:sbom:hash-kind') == 'source-merkle-omnibor', \
props
srcs = props['wolfssl:sbom:source-set'].split(',')
Expand Down Expand Up @@ -255,6 +258,7 @@ jobs:
--user-settings-include . \
--user-settings-include IDE/GCC-ARM/Header \
--user-settings-define WOLFSSL_USER_SETTINGS \
--user-settings-define WOLFSSL_ACCEPT_WEAK_ENTROPY \
--user-settings-define NO_STDINT_H \
--user-settings-define WOLFSSL_NO_ASSERT_H \
--srcs wolfcrypt/src/aes.c \
Expand Down Expand Up @@ -283,6 +287,7 @@ jobs:
--user-settings-include . \
--user-settings-include IDE/GCC-ARM/Header \
--user-settings-define WOLFSSL_USER_SETTINGS \
--user-settings-define WOLFSSL_ACCEPT_WEAK_ENTROPY \
--srcs wolfcrypt/src/aes.c wolfcrypt/src/sha.c \
--dep-libz yes \
--dep-version libz=1.3.1 \
Expand Down Expand Up @@ -317,6 +322,7 @@ jobs:
gcc -dM -E \
-I . -I IDE/GCC-ARM/Header \
-DWOLFSSL_USER_SETTINGS \
-DWOLFSSL_ACCEPT_WEAK_ENTROPY \
-DNO_STDINT_H \
-DWOLFSSL_NO_ASSERT_H \
-include wolfssl/wolfcrypt/settings.h \
Expand Down Expand Up @@ -363,6 +369,7 @@ jobs:
cdx = json.load(f)
props = {p['name']: p['value']
for p in cdx['metadata']['component']['properties']}
assert props.get('wolfssl:security:weak-entropy') == 'permitted'
build_prop_names = {
k.split(':', 2)[-1]
for k in props if k.startswith('wolfssl:build:')
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/zephyr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ jobs:
working-directory: zephyr
run: west update -n -o=--depth=1

- name: Opt in to test-only QEMU entropy
run: |
settings=zephyr/modules/crypto/wolfssl/zephyr/user_settings.h
test -f "$settings"
sed -i '1i#define WOLFSSL_ACCEPT_WEAK_ENTROPY /* QEMU test only */' "$settings"
- name: Export zephyr
working-directory: zephyr
run: west zephyr-export
Expand Down
9 changes: 8 additions & 1 deletion IDE/AURIX/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,17 @@ extern unsigned long my_time(unsigned long* timer);
#define HAVE_HASHDRBG

/* Custom Seed Source */
#if !defined(CUSTOM_RAND_GENERATE_SEED) && \
!defined(CUSTOM_RAND_GENERATE_SEED_OS) && \
!defined(CUSTOM_RAND_GENERATE_BLOCK) && \
!defined(CUSTOM_RAND_GENERATE)
#ifndef WOLFSSL_ACCEPT_WEAK_ENTROPY
#error "AURIX example counter seed is predictable: provide a secure custom seed; test only: define WOLFSSL_ACCEPT_WEAK_ENTROPY"
#endif
#define CUSTOM_RAND_TYPE unsigned int
extern unsigned int my_rng_seed_gen(void);
#undef CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_GENERATE my_rng_seed_gen
#endif

/* Standard Lib - C89 */
#define XSTRCASECMP(s1,s2) strcmp((s1),(s2))
Expand Down
23 changes: 2 additions & 21 deletions IDE/C2000/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CFLAGS="-v28 --abi=eabi --float_support=fpu32 --tmu_support=tmu1 -O2 \
# regression surface for this port, plus hash.c, which HashML-DSA
# (wc_MlDsaKey_VerifyCtxHash) calls for the digest size and OID.
SRCS="error wc_port memory logging misc coding hash \
sha sha256 sha512 sha3 wc_mldsa random ecc sp_int sp_c32 \
sha sha256 sha512 sha3 wc_mldsa random rng_noisesrc ecc sp_int sp_c32 \
aes cmac chacha poly1305 cryptocb \
curve25519 ed25519 fe_operations ge_operations \
curve448 ed448 fe_448 ge_448"
Expand All @@ -61,25 +61,6 @@ for s in $SRCS; do
fi
done

# rng_noisesrc.c and random.c again with the entropy gate on: that turns
# WOLFSSL_NOISE_SRC on, compiling the generic SP800-90B noise-source layer in
# rng_noisesrc.c and the C2000 wc_GenerateSeed() branch in random.c, both left
# out of the sweep above. Needs no C2000Ware - only the port .c touches
# driverlib.
for s in rng_noisesrc random; do
printf 'CC %s.c (WOLFSSL_C2000_ENTROPY) ... ' "$s"
if "$CL" $CFLAGS $INCS --define=WOLFSSL_C2000_ENTROPY \
--compile_only --skip_assembler \
--asm_directory="$OUT" --obj_directory="$OUT" \
"$WOLFROOT/wolfcrypt/src/$s.c" > "$OUT/$s-noise.log" 2>&1; then
echo "ok"
else
echo "FAIL"
cat "$OUT/$s-noise.log"
rc=1
fi
done

# The AESA hardware-AES port needs C2000Ware driverlib headers, which CI does
# not download, so it is an opt-in extra leg: set C2000WARE to a C2000Ware
# install to include it.
Expand All @@ -89,7 +70,7 @@ if [ -n "${C2000WARE:-}" ]; then
-I$C2000WARE/device_support/f28p55x/common/include \
-I$C2000WARE/device_support/f28p55x/headers/include"
for p in "ti-c2000-aes:--define=WOLF_CRYPTO_CB --define=WOLFSSL_C2000_AES" \
"ti-c2000-entropy:--define=WOLFSSL_C2000_ENTROPY"; do
"ti-c2000-entropy:"; do
f=${p%%:*}
d=${p#*:}
printf 'CC port/ti/%s.c ... ' "$f"
Expand Down
4 changes: 3 additions & 1 deletion IDE/C2000/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
#define WOLFSSL_IGNORE_FILE_WARN
#define BENCH_EMBEDDED
#define NO_WOLFSSL_MEMORY
#define WOLFSSL_GENSEED_FORTEST /* dev-only seed; no TRNG on this part */
/* Use the DCC oscillator-noise source for wc_GenerateSeed(). Hardware builds
* must also compile rng_noisesrc.c and port/ti/ti-c2000-entropy.c. */
#define WOLFSSL_C2000_ENTROPY

/* Hashes (SHA-1 is on by default - NO_SHA is not set) */
#define WOLFSSL_SHA512
Expand Down
2 changes: 1 addition & 1 deletion IDE/ECLIPSE/RTTHREAD/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define WOLFSSL_BENCHMARK_TEST
#define WOLFSSL_CLIENT_TEST
#define WOLFSSL_SERVER_TEST
#define USE_TEST_GENSEED
/* Supply CUSTOM_RAND_GENERATE_SEED from a hardware entropy source. */
#define NO_DEV_RANDOM
#define HAVE_PKCS7
#define HAVE_AES_KEYWRAP
Expand Down
9 changes: 8 additions & 1 deletion IDE/GCC-ARM/Header/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,16 @@ extern "C" {
/* ------------------------------------------------------------------------- */

/* Seed Source */
#if !defined(CUSTOM_RAND_GENERATE_SEED) && \
!defined(CUSTOM_RAND_GENERATE_SEED_OS) && \
!defined(CUSTOM_RAND_GENERATE_BLOCK) && \
!defined(CUSTOM_RAND_GENERATE)
#ifndef WOLFSSL_ACCEPT_WEAK_ENTROPY
#error "GCC ARM example counter seed is predictable: provide a secure custom seed; test only: define WOLFSSL_ACCEPT_WEAK_ENTROPY"
#endif
/* Size of returned HW RNG value */
#define CUSTOM_RAND_TYPE unsigned int
extern unsigned int my_rng_seed_gen(void);
#undef CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_GENERATE my_rng_seed_gen

/* Choose RNG method */
Expand All @@ -501,6 +507,7 @@ extern unsigned int my_rng_seed_gen(void);
#undef CUSTOM_RAND_GENERATE_BLOCK
#define CUSTOM_RAND_GENERATE_BLOCK my_rng_gen_block
#endif
#endif /* no application seed source */


/* ------------------------------------------------------------------------- */
Expand Down
4 changes: 3 additions & 1 deletion IDE/IAR-EWARM/Projects/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
#define XVALIDATEDATE(d, f,t) (0)
#define WOLFSSL_USER_CURRTIME /* for benchmark */

#define WOLFSSL_GENSEED_FORTEST /* Warning: define your own seed gen */
/* Provide a real seed source through CUSTOM_RAND_GENERATE_SEED before use.
* The test seed requires explicit WOLFSSL_GENSEED_FORTEST and
* WOLFSSL_ACCEPT_WEAK_ENTROPY definitions in the application build. */

/* A few examples of different math options below.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#undef WOLFSSL_EMBOS
#define WOLFSSL_EMBOS
/* Supply a real seed through CUSTOM_RAND_GENERATE_SEED. */

#undef WOLFCRYPT_ONLY
#define WOLFCRYPT_ONLY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#undef WOLFSSL_EMBOS
#define WOLFSSL_EMBOS
/* Supply a real seed through CUSTOM_RAND_GENERATE_SEED. */

#undef WOLFCRYPT_ONLY
#define WOLFCRYPT_ONLY
Expand Down
11 changes: 9 additions & 2 deletions IDE/IAR-MSP430/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,15 @@ extern "C" {

#define CUSTOM_RAND_TYPE unsigned int
extern unsigned int msp430_rnd(void);
#undef CUSTOM_RAND_GENERATE
#define CUSTOM_RAND_GENERATE msp430_rnd
#if !defined(CUSTOM_RAND_GENERATE_SEED) && \
!defined(CUSTOM_RAND_GENERATE_SEED_OS) && \
!defined(CUSTOM_RAND_GENERATE_BLOCK) && \
!defined(CUSTOM_RAND_GENERATE)
#ifndef WOLFSSL_ACCEPT_WEAK_ENTROPY
#error "MSP430 timer XOR is not an entropy source: provide a secure custom seed; test only: define WOLFSSL_ACCEPT_WEAK_ENTROPY"
#endif
#define CUSTOM_RAND_GENERATE msp430_rnd
#endif

extern unsigned int msp430_time(long *x);
#undef XTIME
Expand Down
2 changes: 2 additions & 0 deletions IDE/INTIME-RTOS/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extern "C" {
/* ------------------------------------------------------------------------- */
#undef INTIME_RTOS
#define INTIME_RTOS
/* INtime v6+ uses arc4random() for seeding. Older releases must provide a
* custom seed source; random.c rejects their clock-seeded rand() fallback. */

#undef WOLF_EXAMPLES_STACK
#define WOLF_EXAMPLES_STACK (1<<17)
Expand Down
21 changes: 19 additions & 2 deletions IDE/MDK5-ARM/Conf/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,18 @@
// </h>

// <e>Random Seed, for TEST Only
#define MDK_CONF_RNDSEED 1
#define MDK_CONF_RNDSEED 0
#if MDK_CONF_RNDSEED == 1
#ifndef WOLFSSL_ACCEPT_WEAK_ENTROPY
#error "Test seed only: define WOLFSSL_ACCEPT_WEAK_ENTROPY for development; remove both before deployment"
#endif
#define WOLFSSL_GENSEED_FORTEST
#endif
// </e>

// <h>Hardware Crypt (See document for usage)
// <e>Hardware RNG
#define MDK_CONF_STM32F2_RNG 0
#define MDK_CONF_STM32F2_RNG 1
Comment thread
danielinux marked this conversation as resolved.
Resolved
#if MDK_CONF_STM32F2_RNG == 1
#define WOLFSSL_STM32_CUBEMX
#define STM32_RNG
Expand All @@ -386,6 +389,13 @@

#endif
// </e>
#if MDK_CONF_STM32F2_RNG == 0 && MDK_CONF_RNDSEED == 0 && \
!defined(CUSTOM_RAND_GENERATE_SEED) && \
!defined(CUSTOM_RAND_GENERATE_SEED_OS) && \
!defined(CUSTOM_RAND_GENERATE_BLOCK) && \
!defined(CUSTOM_RAND_GENERATE)
#error "Enable the STM32 hardware RNG or provide a real custom seed; test only: MDK_CONF_RNDSEED=1 and WOLFSSL_ACCEPT_WEAK_ENTROPY"
#endif
// <e>Hardware Crypt
#define MDK_CONF_STM32F2_CRYPTO 0
#if MDK_CONF_STM32F2_CRYPTO == 1
Expand Down Expand Up @@ -422,6 +432,13 @@

#endif
// </e>
#if MDK_CONF_STM32F2_CRYPTO == 0
#define NO_STM32_CRYPTO
#endif
#if MDK_CONF_STM32F2_HASH == 0
#define NO_STM32_HASH
#define NO_STM32_HMAC
#endif
// </h>

// <h>Cert/Key Storage
Expand Down
3 changes: 2 additions & 1 deletion IDE/MPLABX16/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ extern "C" {
#define BENCH_EMBEDDED
#define WC_16BIT_CPU
#define WORD64_AVAILABLE
#define WOLFSSL_GENSEED_FORTEST
/* PIC24 has no configured seed source. Supply
* CUSTOM_RAND_GENERATE_SEED before using the RNG. */
#endif

/* ------------------------------------------------------------------------- */
Expand Down
1 change: 1 addition & 0 deletions IDE/MSVS-2019-AZSPHERE/user_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define CUSTOM_SERVER_CONNECTION

#define WOLFSSL_AZSPHERE
/* Supply a real seed through CUSTOM_RAND_GENERATE_SEED. */
/* Client connects to the server with these details. */
#ifdef CUSTOM_SERVER_CONNECTION
#ifndef SERVER_IP
Expand Down
7 changes: 4 additions & 3 deletions IDE/NETOS/wolfssl_netos_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ unsigned char get_byte_from_pool(void)
int my_rng_generate_seed(unsigned char* output, int sz)
{
int i;
srand(get_byte_from_pool());

/* Use the pool bytes directly: the pool is the entropy source, and a
* libc PRNG stage would add nothing while risking entropy loss through
* non-random low-order bits. */
for (i = 0; i < sz; i++) {
output[i] = (unsigned char) rand();
srand(get_byte_from_pool());
output[i] = get_byte_from_pool();
}

return 0;
Expand Down
Loading
Loading