Re: [PATCH] crypto: drbg: check blocklen is non zero

From: Stephan Mueller
Date: Sun Aug 02 2020 - 14:29:17 EST


Am Sonntag, 2. August 2020, 19:12:47 CEST schrieb trix@xxxxxxxxxx:

Hi Tom,

> From: Tom Rix <trix@xxxxxxxxxx>
>
> Clang static analysis reports this error
>
> crypto/drbg.c:441:40: warning: Division by zero
> padlen = (inputlen + sizeof(L_N) + 1) % (drbg_blocklen(drbg));
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
>
> When drbg_bocklen fails it returns 0.
>
> if (drbg && drbg->core)
> return drbg->core->blocklen_bytes;
> return 0;
>
> In many places in drbg_ctr_df drbg_bocklen is assumed to be non zero.
> So turn the assumption into a check.
>
> Fixes: 541af946fe13 ("crypto: drbg - SP800-90A Deterministic Random Bit
> Generator")
>
> Signed-off-by: Tom Rix <trix@xxxxxxxxxx>

Thank you.

Reviewed-by: Stephan Mueller <smueller@xxxxxxxxxx>

Ciao
Stephan