diff --git a/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java b/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java index a2d73e9a39f240feedd6514e5dc95ce64463701c..a2725ef2d9a0205230211a54fbac230742fe5cbb 100644 --- a/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java +++ b/components/net/sf/briar/transport/ConnectionReaderFactoryImpl.java @@ -55,7 +55,8 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory { new IncomingAuthenticationLayerImpl(correction, mac, macKey); // No reordering or retransmission IncomingReliabilityLayer reliability = - new NullIncomingReliabilityLayer(authentication); + new IncomingReliabilityLayerImpl(authentication, + new NullFrameWindow()); // Create the reader - don't tolerate errors return new ConnectionReaderImpl(reliability, false); } @@ -81,7 +82,7 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory { Cipher tagCipher = crypto.getTagCipher(); Cipher segCipher = crypto.getSegmentCipher(); IncomingEncryptionLayer encryption = - new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, + new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher, tagKey, segKey, false, bufferedSegment); // No error correction IncomingErrorCorrectionLayer correction = @@ -92,7 +93,8 @@ class ConnectionReaderFactoryImpl implements ConnectionReaderFactory { new IncomingAuthenticationLayerImpl(correction, mac, macKey); // No reordering or retransmission IncomingReliabilityLayer reliability = - new NullIncomingReliabilityLayer(authentication); + new IncomingReliabilityLayerImpl(authentication, + new NullFrameWindow()); // Create the reader - don't tolerate errors return new ConnectionReaderImpl(reliability, false); } diff --git a/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java b/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java index 6382955245b48b4ed6b24c7cf61107e46c57dec8..404a9bc231c4442a5ff68c7b7696e16b22cc1453 100644 --- a/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java +++ b/components/net/sf/briar/transport/ConnectionWriterFactoryImpl.java @@ -60,7 +60,7 @@ class ConnectionWriterFactoryImpl implements ConnectionWriterFactory { Cipher tagCipher = crypto.getTagCipher(); Cipher segCipher = crypto.getSegmentCipher(); OutgoingEncryptionLayer encryption = - new OutgoingSegmentedEncryptionLayer(out, capacity, tagCipher, + new SegmentedOutgoingEncryptionLayer(out, capacity, tagCipher, segCipher, tagKey, segKey, false); // No error correction OutgoingErrorCorrectionLayer correction = diff --git a/components/net/sf/briar/transport/NullIncomingReliabilityLayer.java b/components/net/sf/briar/transport/IncomingReliabilityLayerImpl.java similarity index 77% rename from components/net/sf/briar/transport/NullIncomingReliabilityLayer.java rename to components/net/sf/briar/transport/IncomingReliabilityLayerImpl.java index ecd871d22f27eef6474936eafe5be01a9874f917..a5943a50abe1dfad150cdfaa1e872fad59b5d7f6 100644 --- a/components/net/sf/briar/transport/NullIncomingReliabilityLayer.java +++ b/components/net/sf/briar/transport/IncomingReliabilityLayerImpl.java @@ -2,16 +2,17 @@ package net.sf.briar.transport; import java.io.IOException; -class NullIncomingReliabilityLayer implements IncomingReliabilityLayer { +class IncomingReliabilityLayerImpl implements IncomingReliabilityLayer { private final IncomingAuthenticationLayer in; - private final int maxFrameLength; private final FrameWindow window; + private final int maxFrameLength; - NullIncomingReliabilityLayer(IncomingAuthenticationLayer in) { + IncomingReliabilityLayerImpl(IncomingAuthenticationLayer in, + FrameWindow window) { this.in = in; + this.window = window; maxFrameLength = in.getMaxFrameLength(); - window = new NullFrameWindow(); } public boolean readFrame(Frame f) throws IOException, InvalidDataException { diff --git a/components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java b/components/net/sf/briar/transport/SegmentedIncomingEncryptionLayer.java similarity index 96% rename from components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java rename to components/net/sf/briar/transport/SegmentedIncomingEncryptionLayer.java index 50dacb4485d2c24d847c967fda8666e0140d066d..7f378c0ebba45ed270e542e45dc00cd8e96e4862 100644 --- a/components/net/sf/briar/transport/IncomingSegmentedEncryptionLayer.java +++ b/components/net/sf/briar/transport/SegmentedIncomingEncryptionLayer.java @@ -15,7 +15,7 @@ import net.sf.briar.api.crypto.ErasableKey; import net.sf.briar.api.plugins.SegmentSource; import net.sf.briar.api.transport.Segment; -class IncomingSegmentedEncryptionLayer implements IncomingEncryptionLayer { +class SegmentedIncomingEncryptionLayer implements IncomingEncryptionLayer { private final SegmentSource in; private final Cipher tagCipher, segCipher; @@ -29,7 +29,7 @@ class IncomingSegmentedEncryptionLayer implements IncomingEncryptionLayer { private boolean firstSegment = true; private long segmentNumber = 0L; - IncomingSegmentedEncryptionLayer(SegmentSource in, Cipher tagCipher, + SegmentedIncomingEncryptionLayer(SegmentSource in, Cipher tagCipher, Cipher segCipher, ErasableKey tagKey, ErasableKey segKey, boolean tagEverySegment, Segment bufferedSegment) { this.in = in; diff --git a/components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java b/components/net/sf/briar/transport/SegmentedOutgoingEncryptionLayer.java similarity index 95% rename from components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java rename to components/net/sf/briar/transport/SegmentedOutgoingEncryptionLayer.java index eb188ff608d8546c6ace6710dda8c8d45ef59e2a..4807e0d09e299b6b34c2b1d2e74608156f3c0429 100644 --- a/components/net/sf/briar/transport/OutgoingSegmentedEncryptionLayer.java +++ b/components/net/sf/briar/transport/SegmentedOutgoingEncryptionLayer.java @@ -15,7 +15,7 @@ import net.sf.briar.api.crypto.ErasableKey; import net.sf.briar.api.plugins.SegmentSink; import net.sf.briar.api.transport.Segment; -class OutgoingSegmentedEncryptionLayer implements OutgoingEncryptionLayer { +class SegmentedOutgoingEncryptionLayer implements OutgoingEncryptionLayer { private final SegmentSink out; private final Cipher tagCipher, segCipher; @@ -27,7 +27,7 @@ class OutgoingSegmentedEncryptionLayer implements OutgoingEncryptionLayer { private long capacity; - OutgoingSegmentedEncryptionLayer(SegmentSink out, long capacity, + SegmentedOutgoingEncryptionLayer(SegmentSink out, long capacity, Cipher tagCipher, Cipher segCipher, ErasableKey tagKey, ErasableKey segKey, boolean tagEverySegment) { this.out = out; diff --git a/test/build.xml b/test/build.xml index a0c9523ccb24fb6ffa87cca4c9c22b095dcea6f0..8d73c651a6a796bc76d2bb482fe776533b5fdf7c 100644 --- a/test/build.xml +++ b/test/build.xml @@ -59,9 +59,9 @@ <test name='net.sf.briar.transport.FrameWindowImplTest'/> <test name='net.sf.briar.transport.IncomingEncryptionLayerImplTest'/> <test name='net.sf.briar.transport.IncomingErrorCorrectionLayerImplTest'/> - <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.transport.SegmentedIncomingEncryptionLayerTest'/> + <test name='net.sf.briar.transport.SegmentedOutgoingEncryptionLayerTest'/> <test name='net.sf.briar.transport.XorErasureCodeTest'/> <test name='net.sf.briar.transport.XorErasureDecoderTest'/> <test name='net.sf.briar.transport.XorErasureEncoderTest'/> diff --git a/test/net/sf/briar/transport/ConnectionReaderImplTest.java b/test/net/sf/briar/transport/ConnectionReaderImplTest.java index feaddea5ce670569c7afed45d770f8f404dcf1c0..3559501c4d093a09b0b508896da53da268f9d814 100644 --- a/test/net/sf/briar/transport/ConnectionReaderImplTest.java +++ b/test/net/sf/briar/transport/ConnectionReaderImplTest.java @@ -224,7 +224,8 @@ public class ConnectionReaderImplTest extends TransportTest { IncomingAuthenticationLayer authentication = new IncomingAuthenticationLayerImpl(correction, mac, macKey); IncomingReliabilityLayer reliability = - new NullIncomingReliabilityLayer(authentication); + new IncomingReliabilityLayerImpl(authentication, + new NullFrameWindow()); return new ConnectionReaderImpl(reliability, false); } } diff --git a/test/net/sf/briar/transport/FrameReadWriteTest.java b/test/net/sf/briar/transport/FrameReadWriteTest.java index 5ca19087826e3778623d9121ee9096b789350435..98f50444db1624539188e9c96269351b6963142c 100644 --- a/test/net/sf/briar/transport/FrameReadWriteTest.java +++ b/test/net/sf/briar/transport/FrameReadWriteTest.java @@ -103,7 +103,8 @@ public class FrameReadWriteTest extends BriarTestCase { IncomingAuthenticationLayer authenticationIn = new IncomingAuthenticationLayerImpl(correctionIn, mac, macKey); IncomingReliabilityLayer reliabilityIn = - new NullIncomingReliabilityLayer(authenticationIn); + new IncomingReliabilityLayerImpl(authenticationIn, + new NullFrameWindow()); ConnectionReader reader = new ConnectionReaderImpl(reliabilityIn, false); InputStream in1 = reader.getInputStream(); diff --git a/test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java b/test/net/sf/briar/transport/SegmentedIncomingEncryptionLayerTest.java similarity index 96% rename from test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java rename to test/net/sf/briar/transport/SegmentedIncomingEncryptionLayerTest.java index 13243605ed0a2ca9c1aa202f49b740f682a9cb80..8f8f5bc31f5568b4733833f04d79d4fb175c936a 100644 --- a/test/net/sf/briar/transport/IncomingSegmentedEncryptionLayerTest.java +++ b/test/net/sf/briar/transport/SegmentedIncomingEncryptionLayerTest.java @@ -22,12 +22,12 @@ import org.junit.Test; import com.google.inject.Guice; import com.google.inject.Injector; -public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase { +public class SegmentedIncomingEncryptionLayerTest extends BriarTestCase { private final Cipher tagCipher, segCipher; private final ErasableKey tagKey, segKey; - public IncomingSegmentedEncryptionLayerTest() { + public SegmentedIncomingEncryptionLayerTest() { super(); Injector i = Guice.createInjector(new CryptoModule()); CryptoComponent crypto = i.getInstance(CryptoComponent.class); @@ -65,7 +65,7 @@ public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase { SegmentSource in = new ByteArraySegmentSource(ciphertext1); // Use the encryption layer to decrypt the ciphertext IncomingEncryptionLayer decrypter = - new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, + new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher, tagKey, segKey, false, buffered); // First segment Segment s = new SegmentImpl(); @@ -116,7 +116,7 @@ public class IncomingSegmentedEncryptionLayerTest extends BriarTestCase { SegmentSource in = new ByteArraySegmentSource(ciphertext1); // Use the encryption layer to decrypt the ciphertext IncomingEncryptionLayer decrypter = - new IncomingSegmentedEncryptionLayer(in, tagCipher, segCipher, + new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher, tagKey, segKey, true, buffered); // First segment Segment s = new SegmentImpl(); diff --git a/test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java b/test/net/sf/briar/transport/SegmentedOutgoingEncryptionLayerTest.java similarity index 95% rename from test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java rename to test/net/sf/briar/transport/SegmentedOutgoingEncryptionLayerTest.java index 00d467e92c99d43ffc0861a21f5f14a23d6a9161..22bb21208a6cf1e42af956f55b2d4740ea33192c 100644 --- a/test/net/sf/briar/transport/OutgoingSegmentedEncryptionLayerTest.java +++ b/test/net/sf/briar/transport/SegmentedOutgoingEncryptionLayerTest.java @@ -22,14 +22,14 @@ import org.junit.Test; import com.google.inject.Guice; import com.google.inject.Injector; -public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase { +public class SegmentedOutgoingEncryptionLayerTest extends BriarTestCase { private static final int MAC_LENGTH = 32; private final Cipher tagCipher, segCipher; private final ErasableKey tagKey, segKey; - public OutgoingSegmentedEncryptionLayerTest() { + public SegmentedOutgoingEncryptionLayerTest() { super(); Injector i = Guice.createInjector(new CryptoModule()); CryptoComponent crypto = i.getInstance(CryptoComponent.class); @@ -65,7 +65,7 @@ public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase { // Use the encryption layer to encrypt the plaintext ByteArraySegmentSink sink = new ByteArraySegmentSink(); OutgoingEncryptionLayer encrypter = - new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE, + new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE, tagCipher, segCipher, tagKey, segKey, false); Segment s = new SegmentImpl(); System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length); @@ -113,7 +113,7 @@ public class OutgoingSegmentedEncryptionLayerTest extends BriarTestCase { // Use the encryption layer to encrypt the plaintext SegmentSink sink = new ByteArraySegmentSink(); OutgoingEncryptionLayer encrypter = - new OutgoingSegmentedEncryptionLayer(sink, Long.MAX_VALUE, + new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE, tagCipher, segCipher, tagKey, segKey, true); Segment s = new SegmentImpl(); System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length);