Merge bitcoin-core/secp256k1#1212: Prevent dead-store elimination when clearing secrets in examples
5660c13755prevent optimization in algorithms (Harshil Jani) Pull request description: Signed-off-by: Harshil Jani <harshiljani2002@gmail.com> ACKs for top commit: sipa: utACK5660c13755real-or-random: utACK5660c13755Tree-SHA512: 90024b7445c04e18a88af4099fc1ac6d1b9b2309b88dd22ae2b1f50aed7bac28b2c180cc28e1a95d5e9ec94b4c4adc44b9ada1477e6abe8efae7884c2382645c
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#include <secp256k1_extrakeys.h>
|
||||
#include <secp256k1_schnorrsig.h>
|
||||
|
||||
#include "random.h"
|
||||
#include "examples_util.h"
|
||||
|
||||
int main(void) {
|
||||
unsigned char msg[12] = "Hello World!";
|
||||
@@ -149,9 +149,8 @@ int main(void) {
|
||||
* example through "out of bounds" array access (see Heartbleed), Or the OS
|
||||
* swapping them to disk. Hence, we overwrite the secret key buffer with zeros.
|
||||
*
|
||||
* TODO: Prevent these writes from being optimized out, as any good compiler
|
||||
* Here we are preventing these writes from being optimized out, as any good compiler
|
||||
* will remove any writes that aren't used. */
|
||||
memset(seckey, 0, sizeof(seckey));
|
||||
|
||||
secure_erase(seckey, sizeof(seckey));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user