From 9bd0b60dec79f4ed3c1209cd122390ac6ce29c82 Mon Sep 17 00:00:00 2001
From: akwizgran <akwizgran@users.sourceforge.net>
Date: Tue, 17 Jan 2012 13:19:40 +0000
Subject: [PATCH] Renamed some classes.

---
 .../ConnectionReaderFactoryImpl.java          |  2 +-
 .../briar/transport/ConnectionReaderImpl.java |  4 +--
 .../ConnectionWriterFactoryImpl.java          |  2 +-
 .../briar/transport/ConnectionWriterImpl.java |  4 +--
 .../net/sf/briar/transport/FrameSink.java     |  9 -----
 ...urce.java => IncomingEncryptionLayer.java} |  2 +-
 ....java => IncomingEncryptionLayerImpl.java} |  8 ++---
 ... => IncomingSegmentedEncryptionLayer.java} |  4 +--
 ...pter.java => OutgoingEncryptionLayer.java} |  5 ++-
 ....java => OutgoingEncryptionLayerImpl.java} |  4 +--
 ... => OutgoingSegmentedEncryptionLayer.java} |  4 +--
 test/build.xml                                |  8 ++---
 .../transport/ConnectionReaderImplTest.java   | 16 ++++-----
 .../transport/ConnectionWriterImplTest.java   | 10 +++---
 .../briar/transport/FrameReadWriteTest.java   |  4 +--
 ...a => IncomingEncryptionLayerImplTest.java} | 16 ++++-----
 ...IncomingSegmentedEncryptionLayerTest.java} | 30 +++++++++--------
 .../transport/NullConnectionDecrypter.java    |  2 +-
 .../transport/NullConnectionEncrypter.java    |  2 +-
 ...a => OutgoingEncryptionLayerImplTest.java} | 31 +++++++++--------
 ...OutgoingSegmentedEncryptionLayerTest.java} | 33 ++++++++++---------
 21 files changed, 101 insertions(+), 99 deletions(-)
 delete mode 100644 components/net/sf/briar/transport/FrameSink.java
 rename components/net/sf/briar/transport/{FrameSource.java => IncomingEncryptionLayer.java} (86%)
 rename components/net/sf/briar/transport/{ConnectionDecrypter.java => IncomingEncryptionLayerImpl.java} (93%)
 rename components/net/sf/briar/transport/{SegmentedConnectionDecrypter.java => IncomingSegmentedEncryptionLayer.java} (95%)
 rename components/net/sf/briar/transport/{ConnectionEncrypter.java => OutgoingEncryptionLayer.java} (70%)
 rename components/net/sf/briar/transport/{ConnectionEncrypterImpl.java => OutgoingEncryptionLayerImpl.java} (92%)
 rename components/net/sf/briar/transport/{SegmentedConnectionEncrypter.java => OutgoingSegmentedEncryptionLayer.java} (94%)
 rename test/net/sf/briar/transport/{ConnectionDecrypterTest.java => IncomingEncryptionLayerImplTest.java} (89%)
 rename test/net/sf/briar/transport/{SegmentedConnectionDecrypterTest.java => IncomingSegmentedEncryptionLayerTest.java} (85%)
 rename test/net/sf/briar/transport/{ConnectionEncrypterImplTest.java => OutgoingEncryptionLayerImplTest.java} (79%)
 rename test/net/sf/briar/transport/{SegmentedConnectionEncrypterTest.java => OutgoingSegmentedEncryptionLayerTest.java} (80%)

diff --git a/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java b/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java
index 4149b37689..1a82bd8359 100644
--- a/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java
+++ b/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java
@@ -49,7 +49,7 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory {
 		Cipher tagCipher = crypto.getTagCipher();
 		Cipher frameCipher = crypto.getFrameCipher();
 		Mac mac = crypto.getMac();
-		FrameSource decrypter = new ConnectionDecrypter(in, tagCipher,
+		IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in, tagCipher,
 				frameCipher, tagKey, frameKey, mac.getMacLength(), false);
 		// Create the reader
 		return new ConnectionReaderImpl(decrypter, mac, macKey);
diff --git a/components/net/sf/briar/transport/ConnectionReaderImpl.java b/components/net/sf/briar/transport/ConnectionReaderImpl.java
index 1d7b1de19e..9ee8b7180b 100644
--- a/components/net/sf/briar/transport/ConnectionReaderImpl.java
+++ b/components/net/sf/briar/transport/ConnectionReaderImpl.java
@@ -16,7 +16,7 @@ import net.sf.briar.api.transport.ConnectionReader;
 
 class ConnectionReaderImpl extends InputStream implements ConnectionReader {
 
-	private final FrameSource decrypter;
+	private final IncomingEncryptionLayer decrypter;
 	private final Mac mac;
 	private final int macLength;
 	private final byte[] buf;
@@ -24,7 +24,7 @@ class ConnectionReaderImpl extends InputStream implements ConnectionReader {
 	private long frame = 0L;
 	private int bufOffset = 0, bufLength = 0;
 
-	ConnectionReaderImpl(FrameSource decrypter, Mac mac, ErasableKey macKey) {
+	ConnectionReaderImpl(IncomingEncryptionLayer decrypter, Mac mac, ErasableKey macKey) {
 		this.decrypter = decrypter;
 		this.mac = mac;
 		// Initialise the MAC
diff --git a/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java b/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java
index e368d1f39b..3af3e0a56a 100644
--- a/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java
+++ b/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java
@@ -48,7 +48,7 @@ class ConnectionWriterFactoryImpl implements ConnectionWriterFactory {
 		// Create the encrypter
 		Cipher tagCipher = crypto.getTagCipher();
 		Cipher frameCipher = crypto.getFrameCipher();
-		ConnectionEncrypter encrypter = new ConnectionEncrypterImpl(out,
+		OutgoingEncryptionLayer encrypter = new OutgoingEncryptionLayerImpl(out,
 				capacity, tagCipher, frameCipher, tagKey, frameKey, false);
 		// Create the writer
 		Mac mac = crypto.getMac();
diff --git a/components/net/sf/briar/transport/ConnectionWriterImpl.java b/components/net/sf/briar/transport/ConnectionWriterImpl.java
index fd823dd0fd..87e7089f9f 100644
--- a/components/net/sf/briar/transport/ConnectionWriterImpl.java
+++ b/components/net/sf/briar/transport/ConnectionWriterImpl.java
@@ -22,14 +22,14 @@ import net.sf.briar.api.transport.ConnectionWriter;
  */
 class ConnectionWriterImpl extends OutputStream implements ConnectionWriter {
 
-	private final ConnectionEncrypter encrypter;
+	private final OutgoingEncryptionLayer encrypter;
 	private final Mac mac;
 	private final byte[] buf;
 
 	private int bufLength = FRAME_HEADER_LENGTH;
 	private long frame = 0L;
 
-	ConnectionWriterImpl(ConnectionEncrypter encrypter, Mac mac,
+	ConnectionWriterImpl(OutgoingEncryptionLayer encrypter, Mac mac,
 			ErasableKey macKey) {
 		this.encrypter = encrypter;
 		this.mac = mac;
diff --git a/components/net/sf/briar/transport/FrameSink.java b/components/net/sf/briar/transport/FrameSink.java
deleted file mode 100644
index 710f60a5e3..0000000000
--- a/components/net/sf/briar/transport/FrameSink.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package net.sf.briar.transport;
-
-import java.io.IOException;
-
-interface FrameSink {
-
-	/** Writes the given frame. */
-	void writeFrame(byte[] b, int len) throws IOException;
-}
diff --git a/components/net/sf/briar/transport/FrameSource.java b/components/net/sf/briar/transport/IncomingEncryptionLayer.java
similarity index 86%
rename from components/net/sf/briar/transport/FrameSource.java
rename to components/net/sf/briar/transport/IncomingEncryptionLayer.java
index 7347b6ccba..bd4bd19829 100644
--- a/components/net/sf/briar/transport/FrameSource.java
+++ b/components/net/sf/briar/transport/IncomingEncryptionLayer.java
@@ -2,7 +2,7 @@ package net.sf.briar.transport;
 
 import java.io.IOException;
 
-interface FrameSource {
+interface IncomingEncryptionLayer {
 
 	/**
 	 * Reads a frame into the given buffer and returns its length, or -1 if no
diff --git a/components/net/sf/briar/transport/ConnectionDecrypter.java b/components/net/sf/briar/transport/IncomingEncryptionLayerImpl.java
similarity index 93%
rename from components/net/sf/briar/transport/ConnectionDecrypter.java
rename to components/net/sf/briar/transport/IncomingEncryptionLayerImpl.java
index 928f56ca74..b8f684d0aa 100644
--- a/components/net/sf/briar/transport/ConnectionDecrypter.java
+++ b/components/net/sf/briar/transport/IncomingEncryptionLayerImpl.java
@@ -16,7 +16,7 @@ import javax.crypto.spec.IvParameterSpec;
 import net.sf.briar.api.FormatException;
 import net.sf.briar.api.crypto.ErasableKey;
 
-class ConnectionDecrypter implements FrameSource {
+class IncomingEncryptionLayerImpl implements IncomingEncryptionLayer {
 
 	private final InputStream in;
 	private final Cipher tagCipher, frameCipher;
@@ -27,9 +27,9 @@ class ConnectionDecrypter implements FrameSource {
 
 	private long frame = 0L;
 
-	ConnectionDecrypter(InputStream in, Cipher tagCipher, Cipher frameCipher,
-			ErasableKey tagKey, ErasableKey frameKey, int macLength,
-			boolean tagEverySegment) {
+	IncomingEncryptionLayerImpl(InputStream in, Cipher tagCipher,
+			Cipher frameCipher, ErasableKey tagKey, ErasableKey frameKey,
+			int macLength, boolean tagEverySegment) {
 		this.in = in;
 		this.tagCipher = tagCipher;
 		this.frameCipher = frameCipher;
diff --git a/components/net/sf/briar/transport/SegmentedConnectionDecrypter.java b/components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java
similarity index 95%
rename from components/net/sf/briar/transport/SegmentedConnectionDecrypter.java
rename to components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java
index 59af5f185c..dfa063c93b 100644
--- a/components/net/sf/briar/transport/SegmentedConnectionDecrypter.java
+++ b/components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java
@@ -16,7 +16,7 @@ import net.sf.briar.api.crypto.ErasableKey;
 import net.sf.briar.api.plugins.Segment;
 import net.sf.briar.api.plugins.SegmentSource;
 
-class SegmentedConnectionDecrypter implements FrameSource {
+class IncomingSegmentedEncryptionLayer implements IncomingEncryptionLayer {
 
 	private final SegmentSource in;
 	private final Cipher tagCipher, frameCipher;
@@ -28,7 +28,7 @@ class SegmentedConnectionDecrypter implements FrameSource {
 
 	private long frame = 0L;
 
-	SegmentedConnectionDecrypter(SegmentSource in, Cipher tagCipher,
+	IncomingSegmentedEncryptionLayer(SegmentSource in, Cipher tagCipher,
 			Cipher frameCipher, ErasableKey tagKey, ErasableKey frameKey,
 			int macLength, boolean tagEverySegment) {
 		this.in = in;
diff --git a/components/net/sf/briar/transport/ConnectionEncrypter.java b/components/net/sf/briar/transport/OutgoingEncryptionLayer.java
similarity index 70%
rename from components/net/sf/briar/transport/ConnectionEncrypter.java
rename to components/net/sf/briar/transport/OutgoingEncryptionLayer.java
index 82bbf357af..bd902736a2 100644
--- a/components/net/sf/briar/transport/ConnectionEncrypter.java
+++ b/components/net/sf/briar/transport/OutgoingEncryptionLayer.java
@@ -3,7 +3,10 @@ package net.sf.briar.transport;
 import java.io.IOException;
 
 /** Encrypts authenticated data to be sent over a connection. */
-interface ConnectionEncrypter extends FrameSink {
+interface OutgoingEncryptionLayer {
+
+	/** Writes the given frame. */
+	void writeFrame(byte[] b, int len) throws IOException;
 
 	/** Flushes the output stream. */
 	void flush() throws IOException;
diff --git a/components/net/sf/briar/transport/ConnectionEncrypterImpl.java b/components/net/sf/briar/transport/OutgoingEncryptionLayerImpl.java
similarity index 92%
rename from components/net/sf/briar/transport/ConnectionEncrypterImpl.java
rename to components/net/sf/briar/transport/OutgoingEncryptionLayerImpl.java
index 08e40577ac..33cb929435 100644
--- a/components/net/sf/briar/transport/ConnectionEncrypterImpl.java
+++ b/components/net/sf/briar/transport/OutgoingEncryptionLayerImpl.java
@@ -12,7 +12,7 @@ import javax.crypto.spec.IvParameterSpec;
 
 import net.sf.briar.api.crypto.ErasableKey;
 
-class ConnectionEncrypterImpl implements ConnectionEncrypter {
+class OutgoingEncryptionLayerImpl implements OutgoingEncryptionLayer {
 
 	private final OutputStream out;
 	private final Cipher tagCipher, frameCipher;
@@ -22,7 +22,7 @@ class ConnectionEncrypterImpl implements ConnectionEncrypter {
 
 	private long capacity, frame = 0L;
 
-	ConnectionEncrypterImpl(OutputStream out, long capacity, Cipher tagCipher,
+	OutgoingEncryptionLayerImpl(OutputStream out, long capacity, Cipher tagCipher,
 			Cipher frameCipher, ErasableKey tagKey, ErasableKey frameKey,
 			boolean tagEverySegment) {
 		this.out = out;
diff --git a/components/net/sf/briar/transport/SegmentedConnectionEncrypter.java b/components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java
similarity index 94%
rename from components/net/sf/briar/transport/SegmentedConnectionEncrypter.java
rename to components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java
index 29af654f2a..99ce32f90d 100644
--- a/components/net/sf/briar/transport/SegmentedConnectionEncrypter.java
+++ b/components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java
@@ -14,7 +14,7 @@ import net.sf.briar.api.crypto.ErasableKey;
 import net.sf.briar.api.plugins.Segment;
 import net.sf.briar.api.plugins.SegmentSink;
 
-class SegmentedConnectionEncrypter implements ConnectionEncrypter {
+class OutgoingSegmentedEncryptionLayer implements OutgoingEncryptionLayer {
 
 	private final SegmentSink out;
 	private final Cipher tagCipher, frameCipher;
@@ -25,7 +25,7 @@ class SegmentedConnectionEncrypter implements ConnectionEncrypter {
 
 	private long capacity, frame = 0L;
 
-	SegmentedConnectionEncrypter(SegmentSink out, long capacity,
+	OutgoingSegmentedEncryptionLayer(SegmentSink out, long capacity,
 			Cipher tagCipher, Cipher frameCipher, ErasableKey tagKey,
 			ErasableKey frameKey, boolean tagEverySegment) {
 		this.out = out;
diff --git a/test/build.xml b/test/build.xml
index f0d6316227..a92959b505 100644
--- a/test/build.xml
+++ b/test/build.xml
@@ -49,8 +49,6 @@
 			<test name='net.sf.briar.serial.ReaderImplTest'/>
 			<test name='net.sf.briar.serial.WriterImplTest'/>
 			<test name='net.sf.briar.setup.SetupWorkerTest'/>
-			<test name='net.sf.briar.transport.ConnectionDecrypterTest'/>
-			<test name='net.sf.briar.transport.ConnectionEncrypterImplTest'/>
 			<test name='net.sf.briar.transport.ConnectionReaderImplTest'/>
 			<test name='net.sf.briar.transport.ConnectionRecogniserImplTest'/>
 			<test name='net.sf.briar.transport.ConnectionRegistryImplTest'/>
@@ -58,8 +56,10 @@
 			<test name='net.sf.briar.transport.ConnectionWriterImplTest'/>
 			<test name='net.sf.briar.transport.ConnectionWriterTest'/>
 			<test name='net.sf.briar.transport.FrameReadWriteTest'/>
-			<test name='net.sf.briar.transport.SegmentedConnectionDecrypterTest'/>
-			<test name='net.sf.briar.transport.SegmentedConnectionEncrypterTest'/>
+			<test name='net.sf.briar.transport.IncomingEncryptionLayerImplTest'/>
+			<test name='net.sf.briar.transport.IncomingSegmentedEncryptionLayerTest'/>
+			<test name='net.sf.briar.transport.OutgoingEncryptionLayerImplTest'/>
+			<test name='net.sf.briar.transport.OutgoingSegmentedEncryptionLayerTest'/>
 			<test name='net.sf.briar.util.ByteUtilsTest'/>
 			<test name='net.sf.briar.util.FileUtilsTest'/>
 			<test name='net.sf.briar.util.StringUtilsTest'/>
diff --git a/test/net/sf/briar/transport/ConnectionReaderImplTest.java b/test/net/sf/briar/transport/ConnectionReaderImplTest.java
index 798f8e4572..bb385b9192 100644
--- a/test/net/sf/briar/transport/ConnectionReaderImplTest.java
+++ b/test/net/sf/briar/transport/ConnectionReaderImplTest.java
@@ -31,7 +31,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		mac.doFinal(frame, FRAME_HEADER_LENGTH + payloadLength);
 		// Read the frame
 		ByteArrayInputStream in = new ByteArrayInputStream(frame);
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		// There should be no bytes available before EOF
 		assertEquals(-1, r.getInputStream().read());
@@ -49,7 +49,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		mac.doFinal(frame, FRAME_HEADER_LENGTH + payloadLength);
 		// Read the frame
 		ByteArrayInputStream in = new ByteArrayInputStream(frame);
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		// There should be one byte available before EOF
 		assertEquals(0, r.getInputStream().read());
@@ -75,7 +75,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		out.write(frame1);
 		// Read the first frame
 		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		byte[] read = new byte[maxPayloadLength];
 		TestUtils.readFully(r.getInputStream(), read);
@@ -109,7 +109,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		out.write(frame1);
 		// Read the first frame
 		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		byte[] read = new byte[maxPayloadLength - paddingLength];
 		TestUtils.readFully(r.getInputStream(), read);
@@ -135,7 +135,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		mac.doFinal(frame, FRAME_HEADER_LENGTH + payloadLength + paddingLength);
 		// Read the frame
 		ByteArrayInputStream in = new ByteArrayInputStream(frame);
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		// The non-zero padding should be rejected
 		try {
@@ -167,7 +167,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		out.write(frame1);
 		// Read the frames
 		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		byte[] read = new byte[payloadLength];
 		TestUtils.readFully(r.getInputStream(), read);
@@ -191,7 +191,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		frame[12] ^= 1;
 		// Try to read the frame - not a single byte should be read
 		ByteArrayInputStream in = new ByteArrayInputStream(frame);
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		try {
 			r.getInputStream().read();
@@ -213,7 +213,7 @@ public class ConnectionReaderImplTest extends TransportTest {
 		frame[17] ^= 1;
 		// Try to read the frame - not a single byte should be read
 		ByteArrayInputStream in = new ByteArrayInputStream(frame);
-		FrameSource d = new NullConnectionDecrypter(in, macLength);
+		IncomingEncryptionLayer d = new NullConnectionDecrypter(in, macLength);
 		ConnectionReader r = new ConnectionReaderImpl(d, mac, macKey);
 		try {
 			r.getInputStream().read();
diff --git a/test/net/sf/briar/transport/ConnectionWriterImplTest.java b/test/net/sf/briar/transport/ConnectionWriterImplTest.java
index 7076deb49e..43f6cf47cb 100644
--- a/test/net/sf/briar/transport/ConnectionWriterImplTest.java
+++ b/test/net/sf/briar/transport/ConnectionWriterImplTest.java
@@ -20,7 +20,7 @@ public class ConnectionWriterImplTest extends TransportTest {
 	@Test
 	public void testFlushWithoutWriteProducesNothing() throws Exception {
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		ConnectionEncrypter e = new NullConnectionEncrypter(out);
+		OutgoingEncryptionLayer e = new NullConnectionEncrypter(out);
 		ConnectionWriter w = new ConnectionWriterImpl(e, mac, macKey);
 		w.getOutputStream().flush();
 		w.getOutputStream().flush();
@@ -40,7 +40,7 @@ public class ConnectionWriterImplTest extends TransportTest {
 		mac.doFinal(frame, FRAME_HEADER_LENGTH + payloadLength);
 		// Check that the ConnectionWriter gets the same results
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		ConnectionEncrypter e = new NullConnectionEncrypter(out);
+		OutgoingEncryptionLayer e = new NullConnectionEncrypter(out);
 		ConnectionWriter w = new ConnectionWriterImpl(e, mac, macKey);
 		w.getOutputStream().write(0);
 		w.getOutputStream().flush();
@@ -50,7 +50,7 @@ public class ConnectionWriterImplTest extends TransportTest {
 	@Test
 	public void testWriteByteToMaxLengthWritesFrame() throws Exception {
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		ConnectionEncrypter e = new NullConnectionEncrypter(out);
+		OutgoingEncryptionLayer e = new NullConnectionEncrypter(out);
 		ConnectionWriter w = new ConnectionWriterImpl(e, mac, macKey);
 		OutputStream out1 = w.getOutputStream();
 		// The first maxPayloadLength - 1 bytes should be buffered
@@ -64,7 +64,7 @@ public class ConnectionWriterImplTest extends TransportTest {
 	@Test
 	public void testWriteArrayToMaxLengthWritesFrame() throws Exception {
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		ConnectionEncrypter e = new NullConnectionEncrypter(out);
+		OutgoingEncryptionLayer e = new NullConnectionEncrypter(out);
 		ConnectionWriter w = new ConnectionWriterImpl(e, mac, macKey);
 		OutputStream out1 = w.getOutputStream();
 		// The first maxPayloadLength - 1 bytes should be buffered
@@ -99,7 +99,7 @@ public class ConnectionWriterImplTest extends TransportTest {
 		byte[] expected = out.toByteArray();
 		// Check that the ConnectionWriter gets the same results
 		out.reset();
-		ConnectionEncrypter e = new NullConnectionEncrypter(out);
+		OutgoingEncryptionLayer e = new NullConnectionEncrypter(out);
 		ConnectionWriter w = new ConnectionWriterImpl(e, mac, macKey);
 		w.getOutputStream().write(new byte[123]);
 		w.getOutputStream().flush();
diff --git a/test/net/sf/briar/transport/FrameReadWriteTest.java b/test/net/sf/briar/transport/FrameReadWriteTest.java
index 051f9f66bc..53b4a8f1cf 100644
--- a/test/net/sf/briar/transport/FrameReadWriteTest.java
+++ b/test/net/sf/briar/transport/FrameReadWriteTest.java
@@ -74,7 +74,7 @@ public class FrameReadWriteTest extends BriarTestCase {
 		ErasableKey macCopy = macKey.copy();
 		// Write the frames
 		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		ConnectionEncrypter encrypter = new ConnectionEncrypterImpl(out,
+		OutgoingEncryptionLayer encrypter = new OutgoingEncryptionLayerImpl(out,
 				Long.MAX_VALUE, tagCipher, frameCipher, tagCopy, frameCopy,
 				false);
 		ConnectionWriter writer = new ConnectionWriterImpl(encrypter, mac,
@@ -91,7 +91,7 @@ public class FrameReadWriteTest extends BriarTestCase {
 		assertArrayEquals(tag, recoveredTag);
 		assertTrue(TagEncoder.validateTag(tag, 0, tagCipher, tagKey));
 		// Read the frames back
-		FrameSource decrypter = new ConnectionDecrypter(in, tagCipher,
+		IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in, tagCipher,
 				frameCipher, tagKey, frameKey, mac.getMacLength(), false);
 		ConnectionReader reader = new ConnectionReaderImpl(decrypter, mac,
 				macKey);
diff --git a/test/net/sf/briar/transport/ConnectionDecrypterTest.java b/test/net/sf/briar/transport/IncomingEncryptionLayerImplTest.java
similarity index 89%
rename from test/net/sf/briar/transport/ConnectionDecrypterTest.java
rename to test/net/sf/briar/transport/IncomingEncryptionLayerImplTest.java
index b79bff4d42..6ac04ef08a 100644
--- a/test/net/sf/briar/transport/ConnectionDecrypterTest.java
+++ b/test/net/sf/briar/transport/IncomingEncryptionLayerImplTest.java
@@ -20,14 +20,14 @@ import org.junit.Test;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class ConnectionDecrypterTest extends BriarTestCase {
+public class IncomingEncryptionLayerImplTest extends BriarTestCase {
 
 	private static final int MAC_LENGTH = 32;
 
 	private final Cipher tagCipher, frameCipher;
 	private final ErasableKey tagKey, frameKey;
 
-	public ConnectionDecrypterTest() {
+	public IncomingEncryptionLayerImplTest() {
 		super();
 		Injector i = Guice.createInjector(new CryptoModule());
 		CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -59,9 +59,9 @@ public class ConnectionDecrypterTest extends BriarTestCase {
 		out.write(ciphertext);
 		out.write(ciphertext1);
 		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-		// Use a ConnectionDecrypter to decrypt the ciphertext
-		FrameSource decrypter = new ConnectionDecrypter(in, tagCipher,
-				frameCipher, tagKey, frameKey, MAC_LENGTH, false);
+		// Use the encryption layer to decrypt the ciphertext
+		IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in,
+				tagCipher, frameCipher, tagKey, frameKey, MAC_LENGTH, false);
 		// First frame
 		byte[] decrypted = new byte[MAX_FRAME_LENGTH];
 		assertEquals(plaintext.length, decrypter.readFrame(decrypted));
@@ -99,9 +99,9 @@ public class ConnectionDecrypterTest extends BriarTestCase {
 		out.write(ciphertext);
 		out.write(ciphertext1);
 		ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-		// Use a ConnectionDecrypter to decrypt the ciphertext
-		FrameSource decrypter = new ConnectionDecrypter(in, tagCipher,
-				frameCipher, tagKey, frameKey, MAC_LENGTH, true);
+		// Use the encryption layer to decrypt the ciphertext
+		IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in,
+				tagCipher, frameCipher, tagKey, frameKey, MAC_LENGTH, true);
 		// First frame
 		byte[] decrypted = new byte[MAX_FRAME_LENGTH];
 		assertEquals(plaintext.length, decrypter.readFrame(decrypted));
diff --git a/test/net/sf/briar/transport/SegmentedConnectionDecrypterTest.java b/test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java
similarity index 85%
rename from test/net/sf/briar/transport/SegmentedConnectionDecrypterTest.java
rename to test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java
index 539b6dd0b2..d3e580ff5a 100644
--- a/test/net/sf/briar/transport/SegmentedConnectionDecrypterTest.java
+++ b/test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java
@@ -21,14 +21,14 @@ import org.junit.Test;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class SegmentedConnectionDecrypterTest extends BriarTestCase {
+public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase {
 
 	private static final int MAC_LENGTH = 32;
 
 	private final Cipher tagCipher, frameCipher;
 	private final ErasableKey tagKey, frameKey;
 
-	public SegmentedConnectionDecrypterTest() {
+	public IncomingSegmentedEncryptionLayerTest() {
 		super();
 		Injector i = Guice.createInjector(new CryptoModule());
 		CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -55,11 +55,12 @@ public class SegmentedConnectionDecrypterTest extends BriarTestCase {
 		frameCipher.init(Cipher.ENCRYPT_MODE, frameKey, ivSpec);
 		byte[] ciphertext1 = frameCipher.doFinal(plaintext1, 0,
 				plaintext1.length);
-		// Use a connection decrypter to decrypt the ciphertext
+		// Use the encryption layer to decrypt the ciphertext
 		byte[][] frames = new byte[][] { ciphertext, ciphertext1 };
 		SegmentSource in = new ByteArraySegmentSource(frames);
-		FrameSource decrypter = new SegmentedConnectionDecrypter(in, tagCipher,
-				frameCipher, tagKey, frameKey, MAC_LENGTH, false);
+		IncomingEncryptionLayer decrypter =
+			new IncomingSegmentedEncryptionLayer(in, tagCipher, frameCipher,
+					tagKey, frameKey, MAC_LENGTH, false);
 		// First frame
 		byte[] decrypted = new byte[MAX_FRAME_LENGTH];
 		assertEquals(plaintext.length, decrypter.readFrame(decrypted));
@@ -92,11 +93,12 @@ public class SegmentedConnectionDecrypterTest extends BriarTestCase {
 		frameCipher.init(Cipher.ENCRYPT_MODE, frameKey, ivSpec);
 		frameCipher.doFinal(plaintext1, 0, plaintext1.length, ciphertext1,
 				TAG_LENGTH);
-		// Use a connection decrypter to decrypt the ciphertext
+		// Use the encryption layer to decrypt the ciphertext
 		byte[][] frames = new byte[][] { ciphertext, ciphertext1 };
 		SegmentSource in = new ByteArraySegmentSource(frames);
-		FrameSource decrypter = new SegmentedConnectionDecrypter(in, tagCipher,
-				frameCipher, tagKey, frameKey, MAC_LENGTH, true);
+		IncomingEncryptionLayer decrypter =
+			new IncomingSegmentedEncryptionLayer(in, tagCipher, frameCipher,
+					tagKey, frameKey, MAC_LENGTH, true);
 		// First frame
 		byte[] decrypted = new byte[MAX_FRAME_LENGTH];
 		assertEquals(plaintext.length, decrypter.readFrame(decrypted));
@@ -112,20 +114,20 @@ public class SegmentedConnectionDecrypterTest extends BriarTestCase {
 
 	private static class ByteArraySegmentSource implements SegmentSource {
 
-		private final byte[][] frames;
+		private final byte[][] segments;
 
-		private int frame = 0;
+		private int segmentNumber = 0;
 
 		private ByteArraySegmentSource(byte[][] frames) {
-			this.frames = frames;
+			this.segments = frames;
 		}
 
 		public boolean readSegment(Segment s) throws IOException {
-			if(frame == frames.length) return false;
-			byte[] src = frames[frame];
+			if(segmentNumber == segments.length) return false;
+			byte[] src = segments[segmentNumber];
 			System.arraycopy(src, 0, s.getBuffer(), 0, src.length);
 			s.setLength(src.length);
-			frame++;
+			segmentNumber++;
 			return true;
 		}
 	}
diff --git a/test/net/sf/briar/transport/NullConnectionDecrypter.java b/test/net/sf/briar/transport/NullConnectionDecrypter.java
index 32b5a21649..ac1a59ddc2 100644
--- a/test/net/sf/briar/transport/NullConnectionDecrypter.java
+++ b/test/net/sf/briar/transport/NullConnectionDecrypter.java
@@ -10,7 +10,7 @@ import java.io.InputStream;
 import net.sf.briar.api.FormatException;
 
 /** A connection decrypter that performs no decryption. */
-class NullConnectionDecrypter implements FrameSource {
+class NullConnectionDecrypter implements IncomingEncryptionLayer {
 
 	private final InputStream in;
 	private final int macLength;
diff --git a/test/net/sf/briar/transport/NullConnectionEncrypter.java b/test/net/sf/briar/transport/NullConnectionEncrypter.java
index 5f59c78969..182f612ca0 100644
--- a/test/net/sf/briar/transport/NullConnectionEncrypter.java
+++ b/test/net/sf/briar/transport/NullConnectionEncrypter.java
@@ -4,7 +4,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 
 /** A ConnectionEncrypter that performs no encryption. */
-class NullConnectionEncrypter implements ConnectionEncrypter {
+class NullConnectionEncrypter implements OutgoingEncryptionLayer {
 
 	private final OutputStream out;
 
diff --git a/test/net/sf/briar/transport/ConnectionEncrypterImplTest.java b/test/net/sf/briar/transport/OutgoingEncryptionLayerImplTest.java
similarity index 79%
rename from test/net/sf/briar/transport/ConnectionEncrypterImplTest.java
rename to test/net/sf/briar/transport/OutgoingEncryptionLayerImplTest.java
index ddc9325180..8aa93d68e8 100644
--- a/test/net/sf/briar/transport/ConnectionEncrypterImplTest.java
+++ b/test/net/sf/briar/transport/OutgoingEncryptionLayerImplTest.java
@@ -18,14 +18,14 @@ import org.junit.Test;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class ConnectionEncrypterImplTest extends BriarTestCase {
+public class OutgoingEncryptionLayerImplTest extends BriarTestCase {
 
 	private static final int MAC_LENGTH = 32;
 
 	private final Cipher tagCipher, frameCipher;
 	private final ErasableKey tagKey, frameKey;
 
-	public ConnectionEncrypterImplTest() {
+	public OutgoingEncryptionLayerImplTest() {
 		super();
 		Injector i = Guice.createInjector(new CryptoModule());
 		CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -58,16 +58,18 @@ public class ConnectionEncrypterImplTest extends BriarTestCase {
 		out.write(ciphertext);
 		out.write(ciphertext1);
 		byte[] expected = out.toByteArray();
-		// Use a ConnectionEncrypter to encrypt the plaintext
+		// Use the encryption layer to encrypt the plaintext
 		out.reset();
-		ConnectionEncrypter e = new ConnectionEncrypterImpl(out, Long.MAX_VALUE,
-				tagCipher, frameCipher, tagKey, frameKey, false);
-		e.writeFrame(plaintext, plaintext.length);
-		e.writeFrame(plaintext1, plaintext1.length);
+		OutgoingEncryptionLayer encrypter = new OutgoingEncryptionLayerImpl(out,
+				Long.MAX_VALUE, tagCipher, frameCipher, tagKey, frameKey,
+				false);
+		encrypter.writeFrame(plaintext, plaintext.length);
+		encrypter.writeFrame(plaintext1, plaintext1.length);
 		byte[] actual = out.toByteArray();
 		// Check that the actual ciphertext matches the expected ciphertext
 		assertArrayEquals(expected, actual);
-		assertEquals(Long.MAX_VALUE - actual.length, e.getRemainingCapacity());
+		assertEquals(Long.MAX_VALUE - actual.length,
+				encrypter.getRemainingCapacity());
 	}
 
 	@Test
@@ -97,15 +99,16 @@ public class ConnectionEncrypterImplTest extends BriarTestCase {
 		out.write(tag1);
 		out.write(ciphertext1);
 		byte[] expected = out.toByteArray();
-		// Use a ConnectionEncrypter to encrypt the plaintext
+		// Use the encryption layer to encrypt the plaintext
 		out.reset();
-		ConnectionEncrypter e = new ConnectionEncrypterImpl(out, Long.MAX_VALUE,
-				tagCipher, frameCipher, tagKey, frameKey, true);
-		e.writeFrame(plaintext, plaintext.length);
-		e.writeFrame(plaintext1, plaintext1.length);
+		OutgoingEncryptionLayer encrypter = new OutgoingEncryptionLayerImpl(out,
+				Long.MAX_VALUE, tagCipher, frameCipher, tagKey, frameKey, true);
+		encrypter.writeFrame(plaintext, plaintext.length);
+		encrypter.writeFrame(plaintext1, plaintext1.length);
 		byte[] actual = out.toByteArray();
 		// Check that the actual ciphertext matches the expected ciphertext
 		assertArrayEquals(expected, actual);
-		assertEquals(Long.MAX_VALUE - actual.length, e.getRemainingCapacity());
+		assertEquals(Long.MAX_VALUE - actual.length,
+				encrypter.getRemainingCapacity());
 	}
 }
diff --git a/test/net/sf/briar/transport/SegmentedConnectionEncrypterTest.java b/test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java
similarity index 80%
rename from test/net/sf/briar/transport/SegmentedConnectionEncrypterTest.java
rename to test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java
index ab981dbef2..ecbbbc1c68 100644
--- a/test/net/sf/briar/transport/SegmentedConnectionEncrypterTest.java
+++ b/test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java
@@ -21,14 +21,14 @@ import org.junit.Test;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
-public class SegmentedConnectionEncrypterTest extends BriarTestCase {
+public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase {
 
 	private static final int MAC_LENGTH = 32;
 
 	private final Cipher tagCipher, frameCipher;
 	private final ErasableKey tagKey, frameKey;
 
-	public SegmentedConnectionEncrypterTest() {
+	public OutgoingSegmentedEncryptionLayerTest() {
 		super();
 		Injector i = Guice.createInjector(new CryptoModule());
 		CryptoComponent crypto = i.getInstance(CryptoComponent.class);
@@ -61,18 +61,19 @@ public class SegmentedConnectionEncrypterTest extends BriarTestCase {
 		out.write(ciphertext);
 		out.write(ciphertext1);
 		byte[] expected = out.toByteArray();
-		// Use a connection encrypter to encrypt the plaintext
+		// Use the encryption layer to encrypt the plaintext
 		ByteArraySegmentSink sink = new ByteArraySegmentSink();
-		ConnectionEncrypter e = new SegmentedConnectionEncrypter(sink,
-				Long.MAX_VALUE, tagCipher, frameCipher, tagKey, frameKey,
-				false);
+		OutgoingEncryptionLayer encrypter =
+			new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE,
+					tagCipher, frameCipher, tagKey, frameKey, false);
 		// The first frame's buffer must have enough space for the tag
-		e.writeFrame(plaintext, plaintext.length);
-		e.writeFrame(plaintext1, plaintext1.length);
+		encrypter.writeFrame(plaintext, plaintext.length);
+		encrypter.writeFrame(plaintext1, plaintext1.length);
 		byte[] actual = out.toByteArray();
 		// Check that the actual ciphertext matches the expected ciphertext
 		assertArrayEquals(expected, actual);
-		assertEquals(Long.MAX_VALUE - actual.length, e.getRemainingCapacity());
+		assertEquals(Long.MAX_VALUE - actual.length,
+				encrypter.getRemainingCapacity());
 	}
 
 	@Test
@@ -102,16 +103,18 @@ public class SegmentedConnectionEncrypterTest extends BriarTestCase {
 		out.write(tag1);
 		out.write(ciphertext1);
 		byte[] expected = out.toByteArray();
-		// Use a connection encrypter to encrypt the plaintext
+		// Use the encryption layer to encrypt the plaintext
 		SegmentSink sink = new ByteArraySegmentSink();
-		ConnectionEncrypter e = new SegmentedConnectionEncrypter(sink,
-				Long.MAX_VALUE, tagCipher, frameCipher, tagKey, frameKey, true);
-		e.writeFrame(plaintext, plaintext.length);
-		e.writeFrame(plaintext1, plaintext1.length);
+		OutgoingEncryptionLayer encrypter =
+			new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE,
+					tagCipher, frameCipher, tagKey, frameKey, true);
+		encrypter.writeFrame(plaintext, plaintext.length);
+		encrypter.writeFrame(plaintext1, plaintext1.length);
 		byte[] actual = out.toByteArray();
 		// Check that the actual ciphertext matches the expected ciphertext
 		assertArrayEquals(expected, actual);
-		assertEquals(Long.MAX_VALUE - actual.length, e.getRemainingCapacity());
+		assertEquals(Long.MAX_VALUE - actual.length,
+				encrypter.getRemainingCapacity());
 	}
 
 	private static class ByteArraySegmentSink extends ByteArrayOutputStream
-- 
GitLab