blob: a5ef05e8dc1a996a0b26361e3f723fb1e2f548aa (
plain) (
tree)
|
|
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;
}
|