Revert "crypto: drbg - use memzero_explicit() for clearing sensitive data"
This reverts commit 421d82f5b3
.
None of the data zeroed are on the stack so the compiler cannot
optimise them away.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
2f3755381d
commit
1471f09f9b
|
@ -98,7 +98,6 @@
|
|||
*/
|
||||
|
||||
#include <crypto/drbg.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
/***************************************************************
|
||||
* Backend cipher definitions available to DRBG
|
||||
|
@ -491,9 +490,9 @@ static int drbg_ctr_df(struct drbg_state *drbg,
|
|||
ret = 0;
|
||||
|
||||
out:
|
||||
memzero_explicit(iv, drbg_blocklen(drbg));
|
||||
memzero_explicit(temp, drbg_statelen(drbg));
|
||||
memzero_explicit(pad, drbg_blocklen(drbg));
|
||||
memset(iv, 0, drbg_blocklen(drbg));
|
||||
memset(temp, 0, drbg_statelen(drbg));
|
||||
memset(pad, 0, drbg_blocklen(drbg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -567,9 +566,9 @@ static int drbg_ctr_update(struct drbg_state *drbg, struct list_head *seed,
|
|||
ret = 0;
|
||||
|
||||
out:
|
||||
memzero_explicit(temp, drbg_statelen(drbg) + drbg_blocklen(drbg));
|
||||
memset(temp, 0, drbg_statelen(drbg) + drbg_blocklen(drbg));
|
||||
if (2 != reseed)
|
||||
memzero_explicit(df_data, drbg_statelen(drbg));
|
||||
memset(df_data, 0, drbg_statelen(drbg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -627,7 +626,7 @@ static int drbg_ctr_generate(struct drbg_state *drbg,
|
|||
len = ret;
|
||||
|
||||
out:
|
||||
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg));
|
||||
memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
|
||||
return len;
|
||||
}
|
||||
|
||||
|
@ -865,7 +864,7 @@ static int drbg_hash_df(struct drbg_state *drbg,
|
|||
}
|
||||
|
||||
out:
|
||||
memzero_explicit(tmp, drbg_blocklen(drbg));
|
||||
memset(tmp, 0, drbg_blocklen(drbg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -909,7 +908,7 @@ static int drbg_hash_update(struct drbg_state *drbg, struct list_head *seed,
|
|||
ret = drbg_hash_df(drbg, drbg->C, drbg_statelen(drbg), &datalist2);
|
||||
|
||||
out:
|
||||
memzero_explicit(drbg->scratchpad, drbg_statelen(drbg));
|
||||
memset(drbg->scratchpad, 0, drbg_statelen(drbg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -944,7 +943,7 @@ static int drbg_hash_process_addtl(struct drbg_state *drbg,
|
|||
drbg->scratchpad, drbg_blocklen(drbg));
|
||||
|
||||
out:
|
||||
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg));
|
||||
memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -991,7 +990,7 @@ static int drbg_hash_hashgen(struct drbg_state *drbg,
|
|||
}
|
||||
|
||||
out:
|
||||
memzero_explicit(drbg->scratchpad,
|
||||
memset(drbg->scratchpad, 0,
|
||||
(drbg_statelen(drbg) + drbg_blocklen(drbg)));
|
||||
return len;
|
||||
}
|
||||
|
@ -1040,7 +1039,7 @@ static int drbg_hash_generate(struct drbg_state *drbg,
|
|||
drbg_add_buf(drbg->V, drbg_statelen(drbg), u.req, 8);
|
||||
|
||||
out:
|
||||
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg));
|
||||
memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue