summaryrefslogtreecommitdiff
path: root/user/yubikey-personalization/wipe-mem.patch
diff options
context:
space:
mode:
Diffstat (limited to 'user/yubikey-personalization/wipe-mem.patch')
-rw-r--r--user/yubikey-personalization/wipe-mem.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/user/yubikey-personalization/wipe-mem.patch b/user/yubikey-personalization/wipe-mem.patch
new file mode 100644
index 000000000..a5ef05e8d
--- /dev/null
+++ b/user/yubikey-personalization/wipe-mem.patch
@@ -0,0 +1,29 @@
+From 13f69440ac7cca05a94bd9cf9011e2ea352dad68 Mon Sep 17 00:00:00 2001
+From: Gabriel Kihlman <g.kihlman@yubico.com>
+Date: Mon, 27 Apr 2020 14:56:00 +0200
+Subject: [PATCH] Wipe stack memory containing key material before returning
+
+---
+ ykpers.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/ykpers.c b/ykpers.c
+index 81cb0df..2413b35 100644
+--- a/ykpers.c
++++ b/ykpers.c
+@@ -280,6 +280,7 @@ int ykp_AES_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
+
+ yubikey_hex_decode(aesbin, hexkey, sizeof(aesbin));
+ memcpy(cfg->ykcore_config.key, aesbin, sizeof(cfg->ykcore_config.key));
++ insecure_memzero (aesbin, sizeof(aesbin));
+
+ return 0;
+ }
+@@ -330,6 +331,7 @@ int ykp_HMAC_key_from_hex(YKP_CONFIG *cfg, const char *hexkey) {
+ i = sizeof(cfg->ykcore_config.key);
+ memcpy(cfg->ykcore_config.key, aesbin, i);
+ memcpy(cfg->ykcore_config.uid, aesbin + i, 20 - i);
++ insecure_memzero (aesbin, sizeof(aesbin));
+
+ return 0;
+ }