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 Ruffingandisle2983 authored and Sebastian Falbesoner committed 2024-10-25 18:44:48 +02:00
1 parent e3497bbf00
commit 9bb368d146
8 files changed
+23 -21

No files matched your search

+3 -2
View File
@@ -61,9 +61,10 @@ int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *output, const se
ret = hashfp(output, x, y, data);
memset(x, 0, 32);
memset(y, 0, 32);
secp256k1_memclear(x, sizeof(x));
secp256k1_memclear(y, sizeof(y));
secp256k1_scalar_clear(&s);
secp256k1_ge_clear(&pt);
return !!ret & !overflow;
}