You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wolfcrypt/src/random.c, wolfssl/wolfcrypt/random.hwolfcrypt/src/rng_bank.c, linuxkm/lkcapi_sha_glue.c, wolfcrypt/test/test.c, doc/dox_comments/header_files/random.h: rename nonce to addIn in reseed
APIs, for consistent naming of "additional" data as such.
tests/api/test_random.c, tests/unit-mcdc/test_random_fault_whitebox.c, tests/unit-mcdc/test_random_whitebox.c: rename nonce to addIn in reseed APIs.
.github/workflows/codespell.yml: add "addIn" to ignore_words_list.
wolfssl/wolfcrypt/wc_port.h, wolfcrypt/src/wc_port.c: add wolfSSL_Atomic_Func_Ptr_CompareExchange() -- casting wrapper around wolfSSL_Atomic_Ptr_CompareExchange().
RNG: add auxiliary invalidation pathway, both sender-side and receiver-side.
add APIs wc_RNG_entropy_epoch_extra_inv_init() and wc_RNG_extra_entropy_epoch_init(), and associated callback types.
add internal routine current_entropy_epoch() and associated internal state.
refactor all ad hoc invalidation checks of global_entropy_epoch to use current_entropy_epoch().
refactor entropy epochs as 64 bit width, with wc_RNG_entropy_epoch_t (word64).
add struct wc_RNG_entropy_epoch_atomic and associated initializers.
add inline helpers wc_RNG_entropy_epoch_export(), wc_RNG_entropy_epoch_import(), and wc_RNG_entropy_epoch_increment_atomic().
refactor Hash_DRBG_Reseed() and its callers to pass cur_epoch only when defined(WC_RNG_HAVE_ENTROPY_EPOCH).
update tests and documentation for 64 bit epochs.
add test and documentation coverage of auxiliary epoch facility.
This PR extends wolfCrypt’s RNG invalidation mechanism with auxiliary callbacks for publishing and receiving entropy events, while standardizing additional-input naming.
Changes:
Introduces 64-bit entropy epochs and routes invalidation checks through external-event detection.
Adds callback registration APIs and a function-pointer atomic comparison wrapper.
Renames reseed APIs from Nonce to AddIn, updates callers and documentation, and adds auxiliary-epoch tests.
File
Description
wolfssl/wolfcrypt/wc_port.h
Adds the function-pointer atomic comparison wrapper.
wolfssl/wolfcrypt/random.h
Defines epoch types, helpers, callbacks, and renamed APIs.
wolfcrypt/test/test.h
Declares the auxiliary-epoch test.
wolfcrypt/test/test.c
Adds auxiliary-epoch coverage and updates API calls.
wolfcrypt/src/wc_port.c
Checks the wrapper’s pointer-size assumption.
wolfcrypt/src/rng_bank.c
Updates reseed and stir API names.
wolfcrypt/src/random.c
Implements auxiliary invalidation and integrates epoch checks.
Scan targets checked:linuxkm-src, linuxkm-bugs, wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs Not reviewed (no scan target covers them):.github/workflows/codespell.yml, doc/dox_comments/header_files/random.h, wolfcrypt/test/test.h Coverage: 7 of 10 in-scope changed file(s) opened by the reviewer; not opened: tests/api/test_random.c, tests/unit-mcdc/test_random_fault_whitebox.c, tests/unit-mcdc/test_random_whitebox.c
Findings: 1 1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Reported findings require changes before merge.
…bank.c,
linuxkm/lkcapi_sha_glue.c, wolfcrypt/test/test.c,
doc/dox_comments/header_files/random.h: rename "nonce" to "addIn" in reseed
APIs, for consistent naming of "additional" data as such.
…r-side.
* add APIs wc_RNG_entropy_epoch_extra_inv_init() and wc_RNG_extra_entropy_epoch_init(), and associated callback types.
* add internal routine current_entropy_epoch() and associated internal state.
* refactor all ad hoc invalidation checks of global_entropy_epoch to use current_entropy_epoch().
* refactor entropy epochs as 64 bit width, with wc_RNG_entropy_epoch_t (word64).
* add struct wc_RNG_entropy_epoch_atomic and associated initializers.
* add inline helpers wc_RNG_entropy_epoch_export(), wc_RNG_entropy_epoch_import(), and wc_RNG_entropy_epoch_increment_atomic().
* refactor Hash_DRBG_Reseed() and its caller to pass cur_epoch only when defined(WC_RNG_HAVE_ENTROPY_EPOCH).
* update tests and documentation for 64 bit epochs.
* add test and documentation coverage of auxiliary epoch facility.
…ra_entropy_epoch_reset() and wc_RNG_entropy_epoch_extra_inv_reset() (test helpers).
wolfcrypt/test/test.c and wolfcrypt/test/test.h: call rng_epoch_extra_test()
from rng_epoch_test() rather than reporting its results separately; fix data
race in rng_epoch_extra_getCb(); implement ext epoch save/restore in
rng_epoch_extra_test().
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new RNG epoch tests can falsely report success because subtest failures are not propagated, and small-stack allocation failure can discard installed production handlers without restoring them.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A stale epoch import can publish mixed shadow values despite a failed low-word CAS, leaving a new external epoch undetected and suppressing RNG recovery.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Prevent stale imports from publishing mixed external epochs
wolfssl/wolfcrypt/random.h:1164
A stale import can fail its low-word CAS but still change the high word, manufacturing an unobserved external epoch and suppressing recovery. Starting with shadow 0x1, reader A detects 0x100000002 and pauses after invalidating; reader B detects a rollback to 0x3, imports it, and an RNG recovers; if the source then changes to 0x100000003, A's resumed import makes the shadow equal that new event without another invalidation. Use a coherent shadow update, such as a full-width CAS after the bump, that cannot publish mixed values; arbitrary external epochs and snapshot restores make this distinct from local counter wraparound.
Scan targets checked:wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs Unchanged since last review (not re-run):linuxkm-src, linuxkm-bugs Not reviewed (no scan target covers them):.github/workflows/codespell.yml, doc/dox_comments/header_files/random.h Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
Findings: 1 1 finding(s) posted as inline comments (see file-level comments below)
💬 1 finding(s) from an earlier review are still open and were not re-posted:
Auxiliary epoch handler pointers are read twice without atomics, so a concurrent reset can cause a NULL function call — wolfcrypt/src/random.c:440
This review was generated automatically by Fenrir. Reported findings require changes before merge.
* in rng_epoch_test(), capture retval from rng_epoch_extra_test() directly
to ret, and move call to end of rng_epoch_test() so that it isn't
conditional on rng_test_generate_is_local(rng).
* in rng_epoch_extra_test(), direct return on failed initial allocation to avoid
spurious and destructive handler resets at cleanup.
Scan targets checked:wolfcrypt-src, wolfcrypt-bugs, wolfssl-src, wolfssl-bugs Unchanged since last review (not re-run):linuxkm-src, linuxkm-bugs Not reviewed (no scan target covers them):.github/workflows/codespell.yml, doc/dox_comments/header_files/random.h Coverage: 1 of 1 in-scope changed file(s) opened by the reviewer
No new issues found in the changed files.
💬 1 finding(s) from an earlier review are still open and were not re-posted:
Auxiliary epoch handler pointers are read twice without atomics, so a concurrent reset can cause a NULL function call — wolfcrypt/src/random.c:440
This review was generated automatically by Fenrir. Reported findings require changes before merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wolfcrypt/src/random.c,wolfssl/wolfcrypt/random.hwolfcrypt/src/rng_bank.c,linuxkm/lkcapi_sha_glue.c,wolfcrypt/test/test.c,doc/dox_comments/header_files/random.h: renamenoncetoaddInin reseedAPIs, for consistent naming of "additional" data as such.
tests/api/test_random.c,tests/unit-mcdc/test_random_fault_whitebox.c,tests/unit-mcdc/test_random_whitebox.c: renamenoncetoaddInin reseed APIs..github/workflows/codespell.yml: add "addIn" to ignore_words_list.wolfssl/wolfcrypt/wc_port.h,wolfcrypt/src/wc_port.c: addwolfSSL_Atomic_Func_Ptr_CompareExchange()-- casting wrapper aroundwolfSSL_Atomic_Ptr_CompareExchange().RNG: add auxiliary invalidation pathway, both sender-side and receiver-side.
wc_RNG_entropy_epoch_extra_inv_init()andwc_RNG_extra_entropy_epoch_init(), and associated callback types.current_entropy_epoch()and associated internal state.global_entropy_epochto usecurrent_entropy_epoch().wc_RNG_entropy_epoch_t(word64).struct wc_RNG_entropy_epoch_atomicand associated initializers.wc_RNG_entropy_epoch_export(),wc_RNG_entropy_epoch_import(), andwc_RNG_entropy_epoch_increment_atomic().Hash_DRBG_Reseed()and its callers to passcur_epochonly whendefined(WC_RNG_HAVE_ENTROPY_EPOCH).tested with