mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-14 16:23:51 +08:00
crypto: drbg - use kmalloc instead of kzalloc for V and C
When allocating V, C, the zeroization is only needed when allocating a new instance of the DRBG, i.e. when performing an initial seeding. For all other allocations, the memcpy implemented in drbg_copy_drbg ensures that the memory is filled with the correct information. Signed-off-by: Stephan Mueller <smueller@chronox.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
f072f0e0fe
commit
e6c0244ad3
@ -1142,6 +1142,11 @@ static int drbg_seed(struct drbg_state *drbg, struct drbg_string *pers,
|
|||||||
pr_devel("DRBG: using personalization string\n");
|
pr_devel("DRBG: using personalization string\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!reseed) {
|
||||||
|
memset(drbg->V, 0, drbg_statelen(drbg));
|
||||||
|
memset(drbg->C, 0, drbg_statelen(drbg));
|
||||||
|
}
|
||||||
|
|
||||||
ret = drbg->d_ops->update(drbg, &seedlist, reseed);
|
ret = drbg->d_ops->update(drbg, &seedlist, reseed);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
@ -1186,14 +1191,14 @@ static inline int drbg_alloc_state(struct drbg_state *drbg)
|
|||||||
if (!drbg)
|
if (!drbg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
drbg->V = kzalloc(drbg_statelen(drbg), GFP_KERNEL);
|
drbg->V = kmalloc(drbg_statelen(drbg), GFP_KERNEL);
|
||||||
if (!drbg->V)
|
if (!drbg->V)
|
||||||
goto err;
|
goto err;
|
||||||
drbg->C = kzalloc(drbg_statelen(drbg), GFP_KERNEL);
|
drbg->C = kmalloc(drbg_statelen(drbg), GFP_KERNEL);
|
||||||
if (!drbg->C)
|
if (!drbg->C)
|
||||||
goto err;
|
goto err;
|
||||||
#ifdef CONFIG_CRYPTO_FIPS
|
#ifdef CONFIG_CRYPTO_FIPS
|
||||||
drbg->prev = kzalloc(drbg_blocklen(drbg), GFP_KERNEL);
|
drbg->prev = kmalloc(drbg_blocklen(drbg), GFP_KERNEL);
|
||||||
if (!drbg->prev)
|
if (!drbg->prev)
|
||||||
goto err;
|
goto err;
|
||||||
drbg->fips_primed = false;
|
drbg->fips_primed = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user