Use secp256k1_memclear() to clear stack memory instead of memset()

All of the invocations of secp256k1_memclear() operate on stack
memory and happen after the function is done with the memory object.
This commit replaces existing memset() invocations and also adds
secp256k1_memclear() to code locations where clearing was missing;
there is no guarantee that this commit covers all code locations
where clearing is necessary.

Co-Authored-By: isle2983 <isle2983@yahoo.com>
This commit is contained in:
Tim Ruffing
2019-06-08 13:54:14 +02:00
committed by Sebastian Falbesoner
parent e3497bbf00
commit 9bb368d146
8 changed files with 23 additions and 21 deletions

View File

@@ -580,7 +580,7 @@ int secp256k1_ellswift_xdh(const secp256k1_context *ctx, unsigned char *output,
/* Invoke hasher */
ret = hashfp(output, sx, ell_a64, ell_b64, data);
memset(sx, 0, 32);
secp256k1_memclear(sx, sizeof(sx));
secp256k1_fe_clear(&px);
secp256k1_scalar_clear(&s);