mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
instantiated value (the genealogical birth stratum); implied by HAVE_FIPS. wolfssl/wolfcrypt/random.h: define WC_RNG_RBGC_STRATUM_IMMUTABLE whenever HAVE_FIPS; declare wc_InitRngNonce_UserSeed(). wolfcrypt/src/random.c: in WC_RNG_RBGC_STRATUM_IMMUTABLE builds, inhibit all post-init stratum relabeling, and refuse credited user-class reseeds (wc_RNG_DRBG_Reseed(), wc_RNG_DRBG_Reseed_Nonce()) of instances below WC_RNG_RBGC_USER_SEED_STRATUM with WRONG_TYPE_OBJECT_E, ahead of lock acquisition and length handling, lest an instance carrying the vetted ESV provenance marker have its reseed counter cleared by unvetted material -- the conformant aperture for user material is the uncredited wc_RNG_DRBG_Stir(). add wc_InitRngNonce_UserSeed(), instantiating born-user-seeded instances at WC_RNG_RBGC_USER_SEED_STRATUM, reseedable by the user in all builds; a null seed returns BAD_FUNC_ARG, and in Hash_DRBG builds an undersized seed (seedSz below WC_DRBG_SEED_SZ, zero included) returns BAD_LENGTH_E, so that an argument mistake cannot mint a primary-class instance the caller believes is user-seeded. src/ssl.c, src/ssl_crypto.c: enable the modern RNG arms of wolfSSL_FIPS_drbg_reseed(), wolfSSL_RAND_seed(), wolfSSL_RAND_poll(), and wolfSSL_RAND_load_file() whenever WC_RNG_RBGC_STRATUM_IMMUTABLE, alongside the incumbent ((!HAVE_FIPS || FIPS_VERSION3_GE(7,0,0)) && !HAVE_SELFTEST) gate; rework the wolfSSL_RAND_poll() modern arm to wc_RNG_DRBG_Reseed_Now(&globalRNG, NULL, 0), with the wolfCrypt return mapped to WOLFSSL_SUCCESS/WOLFSSL_FAILURE; route wolfSSL_RAND_seed() and wolfSSL_RAND_load_file() user material through the uncredited wc_RNG_DRBG_Stir(), treating NOT_READY_E as success. wolfcrypt/test/test.c: in rng_drbg_rbgc_test(), add born-user-seeded instantiation coverage (sentinel stratum at init, user reseed accepted and stratum retained, generation); in random_test(), add the wc_InitRngNonce_UserSeed() error-contract battery (null/undersized arguments, and NOT_COMPILED_IN without WC_RNG_HAVE_RBGC) and sub-sentinel reseed-refusal probes on a plain instance (WRONG_TYPE_OBJECT_E, including at zero length, with generation unaffected); pivot stratum expectations on the new RBGC_RESEED_STRATUM() frozen/updated selector; in the threaded reseed test, churn with credited wc_RNG_DRBG_Reseed_Now() where user-class reseeds are refused; drive bank user-seeding through WC_RNG_BANK_FLAG_STIR, treating NOT_READY_E as success. tests/api/test_random.c: WC_RNG_RBGC_STRATUM_IMMUTABLE-arm expectations (WRONG_TYPE_OBJECT_E) at the wc_RNG_DRBG_Reseed() probes in test_wc_RNG_DRBG_Reseed() and test_wc_DrbgDecisionCoverage(). doc/dox_comments/header_files/random.h: add the wc_InitRngNonce_UserSeed() entry; update wc_RNG_DRBG_Reseed()/wc_RNG_DRBG_Reseed_Nonce() for the stratum-immutable refusal, the reseed-obligation BAD_LENGTH_E floor, condemned-instance RNG_FAILURE_E, and the nonce null-with-nonzero-length argument check; update wc_RNG_DRBG_GetRBGCStratum(), ReseedRBGC(), the spawn family, and NextSeedGenerate_RBGC() for frozen-stratum semantics; rebalance briefs to declarative one-liners with rationale consolidated into \details.
The wolfSSL manual is available at: http://www.wolfssl.com/documentation/wolfSSL-Manual.pdf The wolfSSL API guide is available at: https://www.wolfssl.com/doxygen/wolfssl_API.html The wolfCrypt API guide is available at: https://www.wolfssl.com/doxygen/wolfcrypt_API.html