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
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
check_filenames: true
check_hidden: true
# Add comma separated list of words that occur multiple times that should be ignored (sorted alphabetically, case sensitive)
ignore_words_list: adin,ameba,aNULL,brunch,carryIn,chainG,ciph,cLen,cliKs,cna,dout,FPR,fpr,haveA,inCreated,inOut,inout,larg,LEAPYEAR,Merget,optionA,parm,parms,repid,rIn,userA,ser,siz,te,Te,HSI,failT,toLen,vor,checkin
ignore_words_list: addIn,adin,ameba,aNULL,brunch,carryIn,chainG,ciph,cLen,cliKs,cna,dout,FPR,fpr,haveA,inCreated,inOut,inout,larg,LEAPYEAR,Merget,optionA,parm,parms,repid,rIn,userA,ser,siz,te,Te,HSI,failT,toLen,vor,checkin
# The exclude_file contains lines of code that should be ignored. This is useful for individual lines which have non-words that can safely be ignored.
exclude_file: '.codespellexcludelines'
# To skip files entirely from being processed, add it to the following list:
Expand Down
241 changes: 178 additions & 63 deletions doc/dox_comments/header_files/random.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions linuxkm/lkcapi_sha_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -3568,7 +3568,7 @@ static int wc_linuxkm_entropy_daemon(void *arg)
if (ret == 0) {
ret = wc_RNG_lock_get_unconditional(global_fallback_rng);
if (ret == 0) {
ret = wc_RNG_DRBG_NextSeedNow_Nonce(
ret = wc_RNG_DRBG_NextSeedNow_AddIn(
global_fallback_rng,
(byte *)&uncredited_nonce,
(word32)sizeof uncredited_nonce);
Expand Down Expand Up @@ -4508,7 +4508,7 @@ static int wc_linuxkm_drbg_generate(struct wc_rng_bank *ctx,
)
{
unsigned long uncredited_nonce = random_get_entropy();
ret = wc_RNG_DRBG_NextSeedNow_Nonce(WC_RNG_BANK_INST_TO_RNG(drbg),
ret = wc_RNG_DRBG_NextSeedNow_AddIn(WC_RNG_BANK_INST_TO_RNG(drbg),
(byte *)&uncredited_nonce,
(word32)sizeof uncredited_nonce);
ForceZero(&uncredited_nonce, (word32)sizeof uncredited_nonce);
Expand Down
28 changes: 14 additions & 14 deletions tests/api/test_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,37 +1807,37 @@ int test_wc_DrbgReworkDecisionCoverage(void)
XMEMSET(&rng, 0, sizeof(rng));
ExpectIntEQ(wc_InitRng_ex(&rng, HEAP_HINT, INVALID_DEVID), 0);

/* wc_RNG_DRBG_Reseed_Nonce: "nonce == NULL && nonceSz > 0" pair. */
ExpectIntEQ(wc_RNG_DRBG_Reseed_Nonce(&rng, seed, sizeof(seed), NULL,
/* wc_RNG_DRBG_Reseed_AddIn: "nonce == NULL && nonceSz > 0" pair. */
ExpectIntEQ(wc_RNG_DRBG_Reseed_AddIn(&rng, seed, sizeof(seed), NULL,
sizeof(nonce)),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
#if defined(WC_RNG_HAVE_RBGC) && defined(WC_RNG_RBGC_STRATUM_IMMUTABLE)
ExpectIntEQ(wc_RNG_DRBG_Reseed_Nonce(&rng, seed, sizeof(seed), nonce,
ExpectIntEQ(wc_RNG_DRBG_Reseed_AddIn(&rng, seed, sizeof(seed), nonce,
sizeof(nonce)),
WC_NO_ERR_TRACE(WRONG_TYPE_OBJECT_E));
ExpectIntEQ(wc_RNG_DRBG_Reseed_Nonce(&rng, seed, sizeof(seed), nonce, 0),
ExpectIntEQ(wc_RNG_DRBG_Reseed_AddIn(&rng, seed, sizeof(seed), nonce, 0),
WC_NO_ERR_TRACE(WRONG_TYPE_OBJECT_E));
#else
ExpectIntEQ(wc_RNG_DRBG_Reseed_Nonce(&rng, seed, sizeof(seed), nonce,
ExpectIntEQ(wc_RNG_DRBG_Reseed_AddIn(&rng, seed, sizeof(seed), nonce,
sizeof(nonce)), 0);
ExpectIntEQ(wc_RNG_DRBG_Reseed_Nonce(&rng, seed, sizeof(seed), nonce, 0),
ExpectIntEQ(wc_RNG_DRBG_Reseed_AddIn(&rng, seed, sizeof(seed), nonce, 0),
0);
#endif

/* wc_RNG_DRBG_Stir_Nonce: rng/seed NULL pair, nonce pair, and the
/* wc_RNG_DRBG_Stir_AddIn: rng/seed NULL pair, nonce pair, and the
* second-chunk decision (nonce non-NULL with zero size). */
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(NULL, seed, sizeof(seed), nonce,
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(NULL, seed, sizeof(seed), nonce,
sizeof(nonce)),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(&rng, NULL, sizeof(seed), nonce,
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(&rng, NULL, sizeof(seed), nonce,
sizeof(nonce)),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(&rng, seed, sizeof(seed), NULL,
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(&rng, seed, sizeof(seed), NULL,
sizeof(nonce)),
WC_NO_ERR_TRACE(BAD_FUNC_ARG));
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(&rng, seed, sizeof(seed), nonce,
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(&rng, seed, sizeof(seed), nonce,
sizeof(nonce)), 0);
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(&rng, seed, sizeof(seed), nonce, 0),
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(&rng, seed, sizeof(seed), nonce, 0),
0);

/* wc_RNG_DRBG_Stir: valid seed only (no nonce chunk). */
Expand Down Expand Up @@ -1953,12 +1953,12 @@ int test_wc_RngInitFlagsDecisionCoverage(void)
ExpectIntEQ(wc_GenerateSeed(&os, NULL, sizeof(out)), BAD_FUNC_ARG);
#endif

/* wc_RNG_DRBG_Stir_Nonce with a valid rng and a NULL seed: the
/* wc_RNG_DRBG_Stir_AddIn with a valid rng and a NULL seed: the
* rng-NULL clause's false side. */
XMEMSET(&rng, 0, sizeof(rng));
ExpectIntEQ(wc_InitRng_ex2(&rng, HEAP_HINT, INVALID_DEVID,
WC_RNG_INIT_FLAG_NONE), 0);
ExpectIntEQ(wc_RNG_DRBG_Stir_Nonce(&rng, NULL, 0, out, sizeof(out)),
ExpectIntEQ(wc_RNG_DRBG_Stir_AddIn(&rng, NULL, 0, out, sizeof(out)),
BAD_FUNC_ARG);
ExpectIntEQ(wc_FreeRng(&rng), 0);
#endif
Expand Down
8 changes: 4 additions & 4 deletions tests/unit-mcdc/test_random_fault_whitebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,11 +1301,11 @@ static void wb_drbg_reseedctr_type_rows(void)
#endif

/* --------------------------------------------------------------------------
* 11. wc_RNG_DRBG_Stir_Nonce() argument guard:
* 11. wc_RNG_DRBG_Stir_AddIn() argument guard:
* :2550 (rng == NULL) || (seed == NULL)
*
* c0 (rng == NULL) is the open operand. c0-T is a structural residual: the
* public wc_RNG_DRBG_Stir_Nonce wrapper guards rng == NULL before calling the
* public wc_RNG_DRBG_Stir_AddIn wrapper guards rng == NULL before calling the
* _local function, so the _local guard never sees a NULL rng. The reachable
* row is c0-F + c1-T (valid rng, seed == NULL).
* ------------------------------------------------------------------------- */
Expand All @@ -1320,13 +1320,13 @@ static void wb_stir_nonce_null_rng(void)
XMEMSET(nonce, 0xBB, sizeof(nonce));

/* 2550 c0-T: rng == NULL (seed present, so the row is c0's). */
(void)wc_RNG_DRBG_Stir_Nonce(NULL, seed, sizeof(seed), nonce,
(void)wc_RNG_DRBG_Stir_AddIn(NULL, seed, sizeof(seed), nonce,
sizeof(nonce));

/* 2550 c0-F: valid rng, seed == NULL (decision true via the seed arm). */
XMEMSET(&rng, 0, sizeof(rng));
if (wc_InitRng(&rng) == 0) {
(void)wc_RNG_DRBG_Stir_Nonce(&rng, NULL, 0, nonce, sizeof(nonce));
(void)wc_RNG_DRBG_Stir_AddIn(&rng, NULL, 0, nonce, sizeof(nonce));
(void)wc_FreeRng(&rng);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/unit-mcdc/test_random_whitebox.c
Original file line number Diff line number Diff line change
Expand Up @@ -765,21 +765,21 @@ static void wb_stir_nonce_local(void)
}

/* :2550 rows: (rng==NULL) and (rng!=NULL, seed==NULL). */
if (wc_RNG_DRBG_Stir_Nonce_local(NULL, seed, sizeof(seed),
if (wc_RNG_DRBG_Stir_AddIn_local(NULL, seed, sizeof(seed),
nonce, sizeof(nonce)) !=
WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
WB_NOTE("stir-nonce rng==NULL not rejected");
wb_fail = 1;
}
if (wc_RNG_DRBG_Stir_Nonce_local(&rng, NULL, 0,
if (wc_RNG_DRBG_Stir_AddIn_local(&rng, NULL, 0,
nonce, sizeof(nonce)) !=
WC_NO_ERR_TRACE(BAD_FUNC_ARG)) {
WB_NOTE("stir-nonce seed==NULL not rejected");
wb_fail = 1;
}

/* Baseline: all-valid stir, nonce chunk evaluated with ret==0. */
ret = wc_RNG_DRBG_Stir_Nonce_local(&rng, seed, sizeof(seed),
ret = wc_RNG_DRBG_Stir_AddIn_local(&rng, seed, sizeof(seed),
nonce, sizeof(nonce));
if (ret != 0) {
WB_NOTE("stir-nonce valid call failed");
Expand All @@ -788,13 +788,13 @@ static void wb_stir_nonce_local(void)

/* :2566 nonce-operand rows: ret==0 with nonce==NULL and with
* nonce!=NULL/nonceSz==0, pairing the nonce-true baseline above. */
ret = wc_RNG_DRBG_Stir_Nonce_local(&rng, seed, sizeof(seed),
ret = wc_RNG_DRBG_Stir_AddIn_local(&rng, seed, sizeof(seed),
NULL, 0);
if (ret != 0) {
WB_NOTE("stir-nonce no-nonce call failed");
wb_fail = 1;
}
ret = wc_RNG_DRBG_Stir_Nonce_local(&rng, seed, sizeof(seed),
ret = wc_RNG_DRBG_Stir_AddIn_local(&rng, seed, sizeof(seed),
nonce, 0);
if (ret != 0) {
WB_NOTE("stir-nonce zero-length-nonce call failed");
Expand All @@ -804,7 +804,7 @@ static void wb_stir_nonce_local(void)
/* :2566 ret!=0 row: reseed due, live nonce pending. The reseed counter
* now belongs to WC_RNG and is shared by both DRBG widths. */
rng.reseedCtr = WC_RESEED_INTERVAL;
ret = wc_RNG_DRBG_Stir_Nonce_local(&rng, seed, sizeof(seed),
ret = wc_RNG_DRBG_Stir_AddIn_local(&rng, seed, sizeof(seed),
nonce, sizeof(nonce));
if (ret == 0) {
WB_NOTE("stir-nonce with saturated reseed counter succeeded");
Expand Down
Loading
Loading