RNG Tweak

1. Remove a redundant test. The duplicate data test is not required and
   is checking for something that potentially can happen normally,
   albeit rarely.
This commit is contained in:
John Safranek
2023-03-10 11:08:35 -08:00
parent 90f1c26211
commit 907a29ab9e
2 changed files with 0 additions and 24 deletions

View File

@ -489,8 +489,6 @@ static int Hash_DRBG_Reseed(DRBG_internal* drbg, const byte* seed, word32 seedSz
}
if (ret == DRBG_SUCCESS) {
drbg->reseedCtr = 1;
drbg->lastBlock = 0;
drbg->matchCount = 0;
}
#ifdef WOLFSSL_SMALL_STACK
@ -541,7 +539,6 @@ static int Hash_gen(DRBG_internal* drbg, byte* out, word32 outSz, const byte* V)
#endif
int i;
int len;
word32 checkBlock;
#ifdef WOLFSSL_SMALL_STACK_CACHE
wc_Sha256* sha = &drbg->sha256;
#else
@ -590,23 +587,6 @@ static int Hash_gen(DRBG_internal* drbg, byte* out, word32 outSz, const byte* V)
#endif
if (ret == 0) {
XMEMCPY(&checkBlock, digest, sizeof(word32));
if (drbg->reseedCtr > 1 && checkBlock == drbg->lastBlock) {
if (drbg->matchCount == 1) {
return DRBG_CONT_FAILURE;
}
else {
if (i == (len-1)) {
len++;
}
drbg->matchCount = 1;
}
}
else {
drbg->matchCount = 0;
drbg->lastBlock = checkBlock;
}
if (out != NULL && outSz != 0) {
if (outSz >= OUTPUT_BLOCK_LEN) {
XMEMCPY(out, digest, OUTPUT_BLOCK_LEN);
@ -762,8 +742,6 @@ static int Hash_DRBG_Instantiate(DRBG_internal* drbg, const byte* seed, word32 s
sizeof(drbg->V), NULL, 0) == DRBG_SUCCESS) {
drbg->reseedCtr = 1;
drbg->lastBlock = 0;
drbg->matchCount = 0;
ret = DRBG_SUCCESS;
}

View File

@ -159,14 +159,12 @@ struct OS_Seed {
#ifdef HAVE_HASHDRBG
struct DRBG_internal {
word32 reseedCtr;
word32 lastBlock;
byte V[DRBG_SEED_LEN];
byte C[DRBG_SEED_LEN];
void* heap;
#if defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLF_CRYPTO_CB)
int devId;
#endif
byte matchCount;
#ifdef WOLFSSL_SMALL_STACK_CACHE
wc_Sha256 sha256;
#endif