Skip to content

Conversation

@kaleb-himes
Copy link
Contributor

@kaleb-himes kaleb-himes commented Jan 14, 2026

Description

Replace the DRBG legacy CRNGT test with the more modern RCT/ADP tests.

CRNGT: Simply compares each block of output from the entropy source with each previous block of output to detect a "stuck entropy source" but suffers a probability failure rate of ~29.80 failures for every 4 billion checks. (keeping in mind a single false-positive means the module must be power cycled to recover from this catastrophic scenario per FIPS 140-2 ss 4.9.2) which leads to high volumes of real-world failures in long running applications (weeks or months under moderate load, days or weeks under heavy load).

RCT/ADP - The Repetition Count Test (RCT) acts as a "stuck-at" detector by failing if a single value repeats consecutively more than a calculated threshold, effectively catching total hardware failures. The Adaptive Proportion Test (ADP) functions as a "bias" detector by counting how many times a specific value appears within a sliding window of samples, identifying subtle statistical collapses that the RCT would otherwise miss.

Fixes issue reported in zd# 21032 for future modules (does not fix legacy modules)

Testing

There is a new test (but it's off by default because it is very slow) in wolfcrypt/test/test.c with two flavors for the Re-Init test, a single threaded and a multi-threaded test.

Single threaded takes a long time but will produce the same rate of failures as the multi-threaded test if entropy pool depletion is not a concern. If entropy pool is small the single threaded option is the best way but it takes longer.

The multi threaded test completes faster by using 40 threads and 100Million iterations per thread to hit the 4 billion goal more quickly. Entropy depletion is a concern so only use this on modern large scale desktop and servers, not on embedded linux.

Examples of configuring and running the tests with and without FIPS enabled are in wolfcrypt/test/README.md along with the investigation results into this issue.

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@kaleb-himes kaleb-himes requested a review from SparkiDev January 14, 2026 23:28
@kaleb-himes kaleb-himes force-pushed the PQ-FS-2026-Part1 branch 2 times, most recently from 489c044 to 38cd661 Compare January 16, 2026 21:00
@kaleb-himes kaleb-himes requested a review from dgarske January 16, 2026 23:30
@dgarske dgarske removed their request for review January 19, 2026 19:56
@SparkiDev SparkiDev assigned kaleb-himes and unassigned wolfSSL-Bot Jan 21, 2026
@SparkiDev
Copy link
Contributor

conflicts on bracnh

…RCT/ADP tests

Update ret code to match docs and update docs

Replace magic numbers with appropriate define

Define MAX_ENTROPY_BITS when MEMUSE not enabled

Fix type cast windows detection

Older FIPS modules still need the old check

CodeSpell you're wrong, that is what I want to name my variable

Turn the hostap into a manual dispatch until it gets fixed

Upon closer review we can not skip the test when memuse enabled

Fix whitespace stuff found by multitest

More syntax things

Correct comments based on latest findings
@kaleb-himes
Copy link
Contributor Author

Re-synced with master, conflicts resolved.

@kaleb-himes kaleb-himes removed their assignment Jan 22, 2026
@SparkiDev SparkiDev merged commit baaa368 into wolfSSL:master Jan 23, 2026
500 of 720 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants