From a3067dbff883498295026176c6a10011c24b57d1 Mon Sep 17 00:00:00 2001 From: akwizgran <akwizgran@users.sourceforge.net> Date: Tue, 29 Nov 2011 11:03:57 +0000 Subject: [PATCH] Don't create copies of erasable keys. --- components/net/sf/briar/crypto/ErasableKeyImpl.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/components/net/sf/briar/crypto/ErasableKeyImpl.java b/components/net/sf/briar/crypto/ErasableKeyImpl.java index b1b43ea0e2..34d29893c0 100644 --- a/components/net/sf/briar/crypto/ErasableKeyImpl.java +++ b/components/net/sf/briar/crypto/ErasableKeyImpl.java @@ -1,8 +1,5 @@ package net.sf.briar.crypto; -import java.util.ArrayList; -import java.util.Collection; - import net.sf.briar.api.crypto.ErasableKey; import net.sf.briar.util.ByteUtils; @@ -13,7 +10,6 @@ class ErasableKeyImpl implements ErasableKey { private final byte[] key; private final String algorithm; - private Collection<byte[]> copies = null; // Locking: this private boolean erased = false; // Locking: this ErasableKeyImpl(byte[] key, String algorithm) { @@ -27,11 +23,7 @@ class ErasableKeyImpl implements ErasableKey { public synchronized byte[] getEncoded() { if(erased) throw new IllegalStateException(); - byte[] b = new byte[key.length]; - System.arraycopy(key, 0, b, 0, key.length); - if(copies == null) copies = new ArrayList<byte[]>(); - copies.add(b); - return b; + return key; } public String getFormat() { @@ -45,7 +37,6 @@ class ErasableKeyImpl implements ErasableKey { public synchronized void erase() { if(erased) throw new IllegalStateException(); ByteUtils.erase(key); - if(copies != null) for(byte[] b : copies) ByteUtils.erase(b); erased = true; } } -- GitLab