mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Made secret keys erasable from memory.
This commit is contained in:
@@ -6,7 +6,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.sf.briar.api.crypto.ErasableKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -26,7 +26,7 @@ public class ConnectionDecrypterImplTest extends TestCase {
|
||||
private static final int MAC_LENGTH = 32;
|
||||
|
||||
private final Cipher ivCipher, frameCipher;
|
||||
private final SecretKey ivKey, frameKey;
|
||||
private final ErasableKey ivKey, frameKey;
|
||||
private final TransportIndex transportIndex = new TransportIndex(13);
|
||||
private final long connection = 12345L;
|
||||
|
||||
@@ -36,8 +36,8 @@ public class ConnectionDecrypterImplTest extends TestCase {
|
||||
CryptoComponent crypto = i.getInstance(CryptoComponent.class);
|
||||
ivCipher = crypto.getIvCipher();
|
||||
frameCipher = crypto.getFrameCipher();
|
||||
ivKey = crypto.generateSecretKey();
|
||||
frameKey = crypto.generateSecretKey();
|
||||
ivKey = crypto.generateTestKey();
|
||||
frameKey = crypto.generateTestKey();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,7 +6,7 @@ import static org.junit.Assert.assertArrayEquals;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.sf.briar.api.crypto.ErasableKey;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -24,7 +24,7 @@ public class ConnectionEncrypterImplTest extends TestCase {
|
||||
private static final int MAC_LENGTH = 32;
|
||||
|
||||
private final Cipher ivCipher, frameCipher;
|
||||
private final SecretKey ivKey, frameKey;
|
||||
private final ErasableKey ivKey, frameKey;
|
||||
private final TransportIndex transportIndex = new TransportIndex(13);
|
||||
private final long connection = 12345L;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class ConnectionEncrypterImplTest extends TestCase {
|
||||
CryptoComponent crypto = i.getInstance(CryptoComponent.class);
|
||||
ivCipher = crypto.getIvCipher();
|
||||
frameCipher = crypto.getFrameCipher();
|
||||
ivKey = crypto.generateSecretKey();
|
||||
frameKey = crypto.generateSecretKey();
|
||||
ivKey = crypto.generateTestKey();
|
||||
frameKey = crypto.generateTestKey();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.sf.briar.api.crypto.ErasableKey;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.briar.TestUtils;
|
||||
@@ -79,7 +79,7 @@ public class ConnectionRecogniserImplTest extends TestCase {
|
||||
@Test
|
||||
public void testExpectedIv() throws Exception {
|
||||
// Calculate the expected IV for connection number 3
|
||||
SecretKey ivKey = crypto.deriveIncomingIvKey(secret);
|
||||
ErasableKey ivKey = crypto.deriveIncomingIvKey(secret);
|
||||
Cipher ivCipher = crypto.getIvCipher();
|
||||
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
|
||||
byte[] iv = IvEncoder.encodeIv(true, remoteIndex, 3L);
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Random;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.sf.briar.api.crypto.ErasableKey;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.briar.api.crypto.CryptoComponent;
|
||||
@@ -29,7 +29,7 @@ public class FrameReadWriteTest extends TestCase {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
private final Cipher ivCipher, frameCipher;
|
||||
private final SecretKey ivKey, frameKey, macKey;
|
||||
private final ErasableKey ivKey, frameKey, macKey;
|
||||
private final Mac mac;
|
||||
private final Random random;
|
||||
private final byte[] secret = new byte[100];
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.sf.briar.transport;
|
||||
import static net.sf.briar.api.transport.TransportConstants.MAX_FRAME_LENGTH;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.sf.briar.api.crypto.ErasableKey;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.briar.api.crypto.CryptoComponent;
|
||||
@@ -16,7 +16,7 @@ import com.google.inject.Injector;
|
||||
public abstract class TransportTest extends TestCase {
|
||||
|
||||
protected final Mac mac;
|
||||
protected final SecretKey macKey;
|
||||
protected final ErasableKey macKey;
|
||||
protected final int headerLength = 4, macLength, maxPayloadLength;
|
||||
|
||||
public TransportTest() throws Exception {
|
||||
@@ -24,7 +24,7 @@ public abstract class TransportTest extends TestCase {
|
||||
Injector i = Guice.createInjector(new CryptoModule());
|
||||
CryptoComponent crypto = i.getInstance(CryptoComponent.class);
|
||||
mac = crypto.getMac();
|
||||
macKey = crypto.generateSecretKey();
|
||||
macKey = crypto.generateTestKey();
|
||||
macLength = mac.getMacLength();
|
||||
maxPayloadLength = MAX_FRAME_LENGTH - headerLength - macLength;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user