mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Removed the initiator flag from the IV (no longer needed with the new
key derivation rules).
This commit is contained in:
@@ -52,8 +52,7 @@ public class ConnectionDecrypterImplTest extends TestCase {
|
||||
|
||||
private void testDecryption(boolean initiator) throws Exception {
|
||||
// Calculate the plaintext and ciphertext for the IV
|
||||
byte[] iv = IvEncoder.encodeIv(initiator, transportIndex.getInt(),
|
||||
connection);
|
||||
byte[] iv = IvEncoder.encodeIv(transportIndex.getInt(), connection);
|
||||
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
|
||||
byte[] encryptedIv = ivCipher.doFinal(iv);
|
||||
assertEquals(IV_LENGTH, encryptedIv.length);
|
||||
@@ -86,8 +85,8 @@ public class ConnectionDecrypterImplTest extends TestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
// Use a ConnectionDecrypter to decrypt the ciphertext
|
||||
ConnectionDecrypter d = new ConnectionDecrypterImpl(in,
|
||||
IvEncoder.encodeIv(initiator, transportIndex.getInt(),
|
||||
connection), frameCipher, frameKey);
|
||||
IvEncoder.encodeIv(transportIndex.getInt(), connection),
|
||||
frameCipher, frameKey);
|
||||
// First frame
|
||||
byte[] decrypted = new byte[ciphertext.length];
|
||||
TestUtils.readFully(d.getInputStream(), decrypted);
|
||||
|
||||
@@ -50,8 +50,7 @@ public class ConnectionEncrypterImplTest extends TestCase {
|
||||
|
||||
private void testEncryption(boolean initiator) throws Exception {
|
||||
// Calculate the expected ciphertext for the IV
|
||||
byte[] iv = IvEncoder.encodeIv(initiator, transportIndex.getInt(),
|
||||
connection);
|
||||
byte[] iv = IvEncoder.encodeIv(transportIndex.getInt(), connection);
|
||||
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
|
||||
byte[] encryptedIv = ivCipher.doFinal(iv);
|
||||
assertEquals(IV_LENGTH, encryptedIv.length);
|
||||
@@ -83,7 +82,7 @@ public class ConnectionEncrypterImplTest extends TestCase {
|
||||
byte[] expected = out.toByteArray();
|
||||
// Use a ConnectionEncrypter to encrypt the plaintext
|
||||
out.reset();
|
||||
iv = IvEncoder.encodeIv(initiator, transportIndex.getInt(), connection);
|
||||
iv = IvEncoder.encodeIv(transportIndex.getInt(), connection);
|
||||
ConnectionEncrypter e = new ConnectionEncrypterImpl(out, Long.MAX_VALUE,
|
||||
iv, ivCipher, frameCipher, ivKey, frameKey);
|
||||
e.getOutputStream().write(plaintext);
|
||||
|
||||
@@ -618,7 +618,7 @@ public class ConnectionRecogniserImplTest extends TestCase {
|
||||
ErasableKey ivKey = crypto.deriveIvKey(secret, true);
|
||||
Cipher ivCipher = crypto.getIvCipher();
|
||||
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
|
||||
byte[] iv = IvEncoder.encodeIv(true, remoteIndex.getInt(), 3);
|
||||
byte[] iv = IvEncoder.encodeIv(remoteIndex.getInt(), 3);
|
||||
return ivCipher.doFinal(iv);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ public class FrameReadWriteTest extends TestCase {
|
||||
|
||||
private void testWriteAndRead(boolean initiator) throws Exception {
|
||||
// Create and encrypt the IV
|
||||
byte[] iv = IvEncoder.encodeIv(initiator, transportIndex.getInt(),
|
||||
connection);
|
||||
byte[] iv = IvEncoder.encodeIv(transportIndex.getInt(), connection);
|
||||
ivCipher.init(Cipher.ENCRYPT_MODE, ivKey);
|
||||
byte[] encryptedIv = ivCipher.doFinal(iv);
|
||||
assertEquals(IV_LENGTH, encryptedIv.length);
|
||||
@@ -97,7 +96,7 @@ public class FrameReadWriteTest extends TestCase {
|
||||
// Decrypt the IV
|
||||
ivCipher.init(Cipher.DECRYPT_MODE, ivKey);
|
||||
byte[] recoveredIv = ivCipher.doFinal(recoveredEncryptedIv);
|
||||
iv = IvEncoder.encodeIv(initiator, transportIndex.getInt(), connection);
|
||||
iv = IvEncoder.encodeIv(transportIndex.getInt(), connection);
|
||||
assertArrayEquals(iv, recoveredIv);
|
||||
// Read the frames back
|
||||
ConnectionDecrypter decrypter = new ConnectionDecrypterImpl(in, iv,
|
||||
|
||||
Reference in New Issue
Block a user