From d4bf8009b172ce06a12f604beb28799ebd2725d9 Mon Sep 17 00:00:00 2001 From: Armin Preiml Date: Fri, 23 Jun 2023 08:17:08 +0200 Subject: [PATCH] rsa: fix clearing privkey params on decode --- format/ssh/rsa.ha | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/format/ssh/rsa.ha b/format/ssh/rsa.ha index b6a277f..b65d31d 100644 --- a/format/ssh/rsa.ha +++ b/format/ssh/rsa.ha @@ -143,20 +143,28 @@ fn rsa_decoderawpriv(key: *key, src: io::handle) (void | error) = { }; let d = readumpint(src)?; - defer bytes::zero(d); - defer free(d); + defer { + bytes::zero(d); + free(d); + }; priv.iq = readumpint(src)?; - defer bytes::zero(priv.iq); - defer free(priv.iq); + defer { + bytes::zero(priv.iq); + free(priv.iq); + }; priv.p = readumpint(src)?; - defer bytes::zero(priv.p); - defer free(priv.p); + defer { + bytes::zero(priv.p); + free(priv.p); + }; priv.q = readumpint(src)?; - defer bytes::zero(priv.q); - defer free(priv.q); + defer { + bytes::zero(priv.q); + free(priv.q); + }; assert(len(key.pubkey) > 0, "pubkey required when decoding privkey"); let pubp = rsa::pubkey_params(key.pubkey); -- 2.45.2