Commit 1471f09f authored by Herbert Xu's avatar Herbert Xu

Revert "crypto: drbg - use memzero_explicit() for clearing sensitive data"

    
This reverts commit 421d82f5.

None of the data zeroed are on the stack so the compiler cannot
optimise them away.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 2f375538
...@@ -98,7 +98,6 @@ ...@@ -98,7 +98,6 @@
*/ */
#include <crypto/drbg.h> #include <crypto/drbg.h>
#include <linux/string.h>
/*************************************************************** /***************************************************************
* Backend cipher definitions available to DRBG * Backend cipher definitions available to DRBG
...@@ -491,9 +490,9 @@ static int drbg_ctr_df(struct drbg_state *drbg, ...@@ -491,9 +490,9 @@ static int drbg_ctr_df(struct drbg_state *drbg,
ret = 0; ret = 0;
out: out:
memzero_explicit(iv, drbg_blocklen(drbg)); memset(iv, 0, drbg_blocklen(drbg));
memzero_explicit(temp, drbg_statelen(drbg)); memset(temp, 0, drbg_statelen(drbg));
memzero_explicit(pad, drbg_blocklen(drbg)); memset(pad, 0, drbg_blocklen(drbg));
return ret; return ret;
} }
...@@ -567,9 +566,9 @@ static int drbg_ctr_update(struct drbg_state *drbg, struct list_head *seed, ...@@ -567,9 +566,9 @@ static int drbg_ctr_update(struct drbg_state *drbg, struct list_head *seed,
ret = 0; ret = 0;
out: out:
memzero_explicit(temp, drbg_statelen(drbg) + drbg_blocklen(drbg)); memset(temp, 0, drbg_statelen(drbg) + drbg_blocklen(drbg));
if (2 != reseed) if (2 != reseed)
memzero_explicit(df_data, drbg_statelen(drbg)); memset(df_data, 0, drbg_statelen(drbg));
return ret; return ret;
} }
...@@ -627,7 +626,7 @@ static int drbg_ctr_generate(struct drbg_state *drbg, ...@@ -627,7 +626,7 @@ static int drbg_ctr_generate(struct drbg_state *drbg,
len = ret; len = ret;
out: out:
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg)); memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
return len; return len;
} }
...@@ -865,7 +864,7 @@ static int drbg_hash_df(struct drbg_state *drbg, ...@@ -865,7 +864,7 @@ static int drbg_hash_df(struct drbg_state *drbg,
} }
out: out:
memzero_explicit(tmp, drbg_blocklen(drbg)); memset(tmp, 0, drbg_blocklen(drbg));
return ret; return ret;
} }
...@@ -909,7 +908,7 @@ static int drbg_hash_update(struct drbg_state *drbg, struct list_head *seed, ...@@ -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); ret = drbg_hash_df(drbg, drbg->C, drbg_statelen(drbg), &datalist2);
out: out:
memzero_explicit(drbg->scratchpad, drbg_statelen(drbg)); memset(drbg->scratchpad, 0, drbg_statelen(drbg));
return ret; return ret;
} }
...@@ -944,7 +943,7 @@ static int drbg_hash_process_addtl(struct drbg_state *drbg, ...@@ -944,7 +943,7 @@ static int drbg_hash_process_addtl(struct drbg_state *drbg,
drbg->scratchpad, drbg_blocklen(drbg)); drbg->scratchpad, drbg_blocklen(drbg));
out: out:
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg)); memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
return ret; return ret;
} }
...@@ -991,7 +990,7 @@ static int drbg_hash_hashgen(struct drbg_state *drbg, ...@@ -991,7 +990,7 @@ static int drbg_hash_hashgen(struct drbg_state *drbg,
} }
out: out:
memzero_explicit(drbg->scratchpad, memset(drbg->scratchpad, 0,
(drbg_statelen(drbg) + drbg_blocklen(drbg))); (drbg_statelen(drbg) + drbg_blocklen(drbg)));
return len; return len;
} }
...@@ -1040,7 +1039,7 @@ static int drbg_hash_generate(struct drbg_state *drbg, ...@@ -1040,7 +1039,7 @@ static int drbg_hash_generate(struct drbg_state *drbg,
drbg_add_buf(drbg->V, drbg_statelen(drbg), u.req, 8); drbg_add_buf(drbg->V, drbg_statelen(drbg), u.req, 8);
out: out:
memzero_explicit(drbg->scratchpad, drbg_blocklen(drbg)); memset(drbg->scratchpad, 0, drbg_blocklen(drbg));
return len; return len;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment