From 67decc3a8511f979b92abde66c4f82104b07b9e9 Mon Sep 17 00:00:00 2001 From: kdeme Date: Tue, 9 Jun 2020 10:59:52 +0200 Subject: [PATCH] Clear after aes encrypt/decrypt --- eth/p2p/rlpx_protocols/whisper/whisper_types.nim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eth/p2p/rlpx_protocols/whisper/whisper_types.nim b/eth/p2p/rlpx_protocols/whisper/whisper_types.nim index f990222..063fdcb 100644 --- a/eth/p2p/rlpx_protocols/whisper/whisper_types.nim +++ b/eth/p2p/rlpx_protocols/whisper/whisper_types.nim @@ -199,6 +199,7 @@ proc encryptAesGcm(plain: openarray[byte], key: SymKey, gcm.encrypt(plain, result) var tag: array[gcmTagLen, byte] gcm.getTag(tag) + gcm.clear() result.add tag result.add iv @@ -217,6 +218,7 @@ proc decryptAesGcm(cipher: openarray[byte], key: SymKey): Option[seq[byte]] = gcm.decrypt(cipher[0 ..< ^(gcmIVLen + gcmTagLen)], res) var tag2: array[gcmTagLen, byte] gcm.getTag(tag2) + gcm.clear() if tag != tag2: debug "cipher tag mismatch", len = cipher.len, tag, tag2