Minor refactoring.

This commit is contained in:
akwizgran
2011-12-02 16:32:50 +00:00
parent 6752781835
commit ab722f9371
11 changed files with 37 additions and 53 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}