1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

wipe secret key as soon as it is no longer needed.

This commit is contained in:
Sven Neuhaus 2015-12-22 11:15:18 +01:00
parent 15285e4743
commit 0900de8c1d

View File

@ -45,6 +45,8 @@ sign(void)
printf("Signing message with %s...\n", crypto_sign_primitive()); printf("Signing message with %s...\n", crypto_sign_primitive());
crypto_sign(message_signed, &message_signed_len, message, message_len, sk); crypto_sign(message_signed, &message_signed_len, message, message_len, sk);
sodium_memzero(sk, sizeof sk); /* wipe sensitive data */
printf("Signed message:"); printf("Signed message:");
print_hex(message_signed, message_signed_len); print_hex(message_signed, message_signed_len);
printf("A %u bytes signature was prepended to the message\n", printf("A %u bytes signature was prepended to the message\n",
@ -64,8 +66,6 @@ sign(void)
if (ret == 0) if (ret == 0)
printf("Message: %s\n", message); printf("Message: %s\n", message);
sodium_memzero(sk, sizeof sk); /* wipe sensitive data */
return ret; return ret;
} }