Skip to content

Commit b201c3e

Browse files
authored
Fix DRBG size cast issue (#386)
* Fix fenrir issue and test PRB trigger * Force fail for testing * Fix up for CI
1 parent 53b3f85 commit b201c3e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/wp_drbg.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ static int wp_drbg_generate(wp_DrbgCtx* ctx, unsigned char* out,
303303
(void)addIn;
304304
(void)addInLen;
305305
#endif
306+
if (ok && (outLen > 0xFFFFFFFFU)) {
307+
ok = 0;
308+
}
306309
if (ok) {
307310
rc = wc_RNG_GenerateBlock(ctx->rng, out, (word32)outLen);
308311
if (rc != 0) {
@@ -595,6 +598,11 @@ static size_t wp_drbg_get_seed(wp_DrbgCtx* ctx, unsigned char** pSeed,
595598
goto end;
596599
}
597600

601+
if (minLen > 0xFFFFFFFFU) {
602+
OPENSSL_secure_free(buffer);
603+
goto end;
604+
}
605+
598606
rc = wc_RNG_GenerateBlock(ctx->rng, buffer, (word32)minLen);
599607
if (rc != 0) {
600608
WOLFPROV_MSG_DEBUG_RETCODE(WP_LOG_COMP_RNG,

0 commit comments

Comments
 (0)