mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Minor refactoring.
This commit is contained in:
@@ -80,12 +80,12 @@ public class ConnectionDecrypterImplTest extends TestCase {
|
||||
byte[] decrypted = new byte[ciphertext.length];
|
||||
TestUtils.readFully(d.getInputStream(), decrypted);
|
||||
byte[] decryptedMac = new byte[MAC_LENGTH];
|
||||
d.readMac(decryptedMac);
|
||||
d.readFinal(decryptedMac);
|
||||
// Second frame
|
||||
byte[] decrypted1 = new byte[ciphertext1.length];
|
||||
TestUtils.readFully(d.getInputStream(), decrypted1);
|
||||
byte[] decryptedMac1 = new byte[MAC_LENGTH];
|
||||
d.readMac(decryptedMac1);
|
||||
d.readFinal(decryptedMac1);
|
||||
// Check that the actual plaintext matches the expected plaintext
|
||||
out.reset();
|
||||
out.write(plaintext);
|
||||
|
||||
@@ -79,9 +79,9 @@ public class ConnectionEncrypterImplTest extends TestCase {
|
||||
ConnectionEncrypter e = new ConnectionEncrypterImpl(out, Long.MAX_VALUE,
|
||||
tagCipher, frameCipher, tagKey, frameKey);
|
||||
e.getOutputStream().write(plaintext);
|
||||
e.writeMac(plaintextMac);
|
||||
e.writeFinal(plaintextMac);
|
||||
e.getOutputStream().write(plaintext1);
|
||||
e.writeMac(plaintextMac);
|
||||
e.writeFinal(plaintextMac);
|
||||
byte[] actual = out.toByteArray();
|
||||
// Check that the actual ciphertext matches the expected ciphertext
|
||||
assertArrayEquals(expected, actual);
|
||||
|
||||
@@ -17,7 +17,7 @@ class NullConnectionDecrypter implements ConnectionDecrypter {
|
||||
return in;
|
||||
}
|
||||
|
||||
public void readMac(byte[] mac) throws IOException {
|
||||
public void readFinal(byte[] mac) throws IOException {
|
||||
int offset = 0;
|
||||
while(offset < mac.length) {
|
||||
int read = in.read(mac, offset, mac.length - offset);
|
||||
|
||||
@@ -23,7 +23,7 @@ implements ConnectionEncrypter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void writeMac(byte[] mac) throws IOException {
|
||||
public void writeFinal(byte[] mac) throws IOException {
|
||||
out.write(mac);
|
||||
capacity -= mac.length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user