From: Niki Roo Date: Tue, 23 Apr 2019 11:50:45 +0000 (+0200) Subject: CryptUtils: clear the key array after use X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=272f5c86957c3caf4b3ed7d59448573914b7b33f;p=fanfix-jexer.git CryptUtils: clear the key array after use --- diff --git a/src/be/nikiroo/utils/CryptUtils.java b/src/be/nikiroo/utils/CryptUtils.java index fdf0556..681692a 100644 --- a/src/be/nikiroo/utils/CryptUtils.java +++ b/src/be/nikiroo/utils/CryptUtils.java @@ -42,7 +42,11 @@ public class CryptUtils { */ public CryptUtils(String key) { try { - init(key2key(key)); + byte[] bytes32 = key2key(key); + init(bytes32); + for (int i = 0 ; i < bytes32.length ; i++) { + bytes32[i] = 0; + } } catch (InvalidKeyException e) { // We made sure that the key is correct, so nothing here e.printStackTrace(); @@ -62,6 +66,9 @@ public class CryptUtils { */ public CryptUtils(byte[] bytes32) throws InvalidKeyException { init(bytes32); + for (int i = 0 ; i < bytes32.length ; i++) { + bytes32[i] = 0; + } } /**