Erase keys after using them. (Copies created by ciphers, etc, may

still exist.)
This commit is contained in:
akwizgran
2011-11-16 16:22:35 +00:00
parent ece03038f4
commit f10512d787
10 changed files with 115 additions and 62 deletions

View File

@@ -74,12 +74,16 @@ public class FrameReadWriteTest extends TestCase {
random.nextBytes(frame);
byte[] frame1 = new byte[321];
random.nextBytes(frame1);
// Copy the keys - the copies will be erased
ErasableKey frameCopy = frameKey.copy();
ErasableKey ivCopy = ivKey.copy();
ErasableKey macCopy = macKey.copy();
// Write the frames
ByteArrayOutputStream out = new ByteArrayOutputStream();
ConnectionEncrypter encrypter = new ConnectionEncrypterImpl(out,
Long.MAX_VALUE, iv, ivCipher, frameCipher, ivKey, frameKey);
Long.MAX_VALUE, iv, ivCipher, frameCipher, ivCopy, frameCopy);
ConnectionWriter writer = new ConnectionWriterImpl(encrypter, mac,
macKey);
macCopy);
OutputStream out1 = writer.getOutputStream();
out1.write(frame);
out1.flush();