mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Make room for the ack header.
This commit is contained in:
@@ -222,9 +222,9 @@ public class ConnectionReaderImplTest extends TransportTest {
|
||||
IncomingErrorCorrectionLayer correction =
|
||||
new NullIncomingErrorCorrectionLayer(encryption);
|
||||
IncomingAuthenticationLayer authentication =
|
||||
new IncomingAuthenticationLayerImpl(correction, mac, macKey);
|
||||
new IncomingAuthenticationLayerImpl(correction, mac, macKey, false);
|
||||
IncomingReliabilityLayer reliability =
|
||||
new NullIncomingReliabilityLayer(authentication);
|
||||
return new ConnectionReaderImpl(reliability, false);
|
||||
return new ConnectionReaderImpl(reliability, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,6 @@ public class ConnectionWriterImplTest extends TransportTest {
|
||||
new OutgoingAuthenticationLayerImpl(correction, mac, macKey);
|
||||
OutgoingReliabilityLayer reliability =
|
||||
new NullOutgoingReliabilityLayer(authentication);
|
||||
return new ConnectionWriterImpl(reliability);
|
||||
return new ConnectionWriterImpl(reliability, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ public class FrameReadWriteTest extends BriarTestCase {
|
||||
new OutgoingAuthenticationLayerImpl(correctionOut, mac, macCopy);
|
||||
OutgoingReliabilityLayer reliabilityOut =
|
||||
new NullOutgoingReliabilityLayer(authenticationOut);
|
||||
ConnectionWriter writer = new ConnectionWriterImpl(reliabilityOut);
|
||||
ConnectionWriter writer = new ConnectionWriterImpl(reliabilityOut,
|
||||
false);
|
||||
OutputStream out1 = writer.getOutputStream();
|
||||
out1.write(frame);
|
||||
out1.flush();
|
||||
@@ -97,14 +98,16 @@ public class FrameReadWriteTest extends BriarTestCase {
|
||||
assertEquals(0L, TagEncoder.decodeTag(tag, tagCipher, tagKey));
|
||||
// Read the frames back
|
||||
IncomingEncryptionLayer encryptionIn = new IncomingEncryptionLayerImpl(
|
||||
in, tagCipher, segCipher, tagKey, segKey, false, recoveredTag);
|
||||
in, tagCipher, segCipher, tagKey, segKey, false, false,
|
||||
recoveredTag);
|
||||
IncomingErrorCorrectionLayer correctionIn =
|
||||
new NullIncomingErrorCorrectionLayer(encryptionIn);
|
||||
IncomingAuthenticationLayer authenticationIn =
|
||||
new IncomingAuthenticationLayerImpl(correctionIn, mac, macKey);
|
||||
new IncomingAuthenticationLayerImpl(correctionIn, mac, macKey,
|
||||
false);
|
||||
IncomingReliabilityLayer reliabilityIn =
|
||||
new NullIncomingReliabilityLayer(authenticationIn);
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliabilityIn,
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliabilityIn, false,
|
||||
false);
|
||||
InputStream in1 = reader.getInputStream();
|
||||
byte[] recovered = new byte[frame.length];
|
||||
|
||||
@@ -63,7 +63,7 @@ public class IncomingEncryptionLayerImplTest extends BriarTestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
// Use the encryption layer to decrypt the ciphertext
|
||||
IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in,
|
||||
tagCipher, segCipher, tagKey, segKey, false, tag);
|
||||
tagCipher, segCipher, tagKey, segKey, false, false, tag);
|
||||
// First segment
|
||||
Segment s = new SegmentImpl();
|
||||
assertTrue(decrypter.readSegment(s));
|
||||
@@ -114,7 +114,7 @@ public class IncomingEncryptionLayerImplTest extends BriarTestCase {
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
|
||||
// Use the encryption layer to decrypt the ciphertext
|
||||
IncomingEncryptionLayer decrypter = new IncomingEncryptionLayerImpl(in,
|
||||
tagCipher, segCipher, tagKey, segKey, true, tag);
|
||||
tagCipher, segCipher, tagKey, segKey, true, false, tag);
|
||||
// First segment
|
||||
Segment s = new SegmentImpl();
|
||||
assertTrue(decrypter.readSegment(s));
|
||||
|
||||
@@ -25,7 +25,8 @@ public class IncomingReliabilityLayerImplTest extends BriarTestCase {
|
||||
new TestIncomingAuthenticationLayer(frameNumbers);
|
||||
IncomingReliabilityLayerImpl reliability =
|
||||
new IncomingReliabilityLayerImpl(authentication);
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliability, false);
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliability, false,
|
||||
false);
|
||||
InputStream in = reader.getInputStream();
|
||||
for(int i = 0; i < FRAME_WINDOW_SIZE * 2; i++) {
|
||||
for(int j = 0; j < 100; j++) assertEquals(i, in.read());
|
||||
@@ -50,7 +51,8 @@ public class IncomingReliabilityLayerImplTest extends BriarTestCase {
|
||||
new TestIncomingAuthenticationLayer(frameNumbers);
|
||||
IncomingReliabilityLayerImpl reliability =
|
||||
new IncomingReliabilityLayerImpl(authentication);
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliability, false);
|
||||
ConnectionReader reader = new ConnectionReaderImpl(reliability, false,
|
||||
false);
|
||||
InputStream in = reader.getInputStream();
|
||||
for(int i = 0; i < FRAME_WINDOW_SIZE * 2; i++) {
|
||||
for(int j = 0; j < 100; j++) assertEquals(i, in.read());
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SegmentedIncomingEncryptionLayerTest extends BriarTestCase {
|
||||
// Use the encryption layer to decrypt the ciphertext
|
||||
IncomingEncryptionLayer decrypter =
|
||||
new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher,
|
||||
tagKey, segKey, false, buffered);
|
||||
tagKey, segKey, false, false, buffered);
|
||||
// First segment
|
||||
Segment s = new SegmentImpl();
|
||||
assertTrue(decrypter.readSegment(s));
|
||||
@@ -117,7 +117,7 @@ public class SegmentedIncomingEncryptionLayerTest extends BriarTestCase {
|
||||
// Use the encryption layer to decrypt the ciphertext
|
||||
IncomingEncryptionLayer decrypter =
|
||||
new SegmentedIncomingEncryptionLayer(in, tagCipher, segCipher,
|
||||
tagKey, segKey, true, buffered);
|
||||
tagKey, segKey, true, false, buffered);
|
||||
// First segment
|
||||
Segment s = new SegmentImpl();
|
||||
assertTrue(decrypter.readSegment(s));
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SegmentedOutgoingEncryptionLayerTest extends BriarTestCase {
|
||||
ByteArraySegmentSink sink = new ByteArraySegmentSink();
|
||||
OutgoingEncryptionLayer encrypter =
|
||||
new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE,
|
||||
tagCipher, segCipher, tagKey, segKey, false);
|
||||
tagCipher, segCipher, tagKey, segKey, false, false);
|
||||
Segment s = new SegmentImpl();
|
||||
System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length);
|
||||
s.setLength(plaintext.length);
|
||||
@@ -114,7 +114,7 @@ public class SegmentedOutgoingEncryptionLayerTest extends BriarTestCase {
|
||||
SegmentSink sink = new ByteArraySegmentSink();
|
||||
OutgoingEncryptionLayer encrypter =
|
||||
new SegmentedOutgoingEncryptionLayer(sink, Long.MAX_VALUE,
|
||||
tagCipher, segCipher, tagKey, segKey, true);
|
||||
tagCipher, segCipher, tagKey, segKey, true, false);
|
||||
Segment s = new SegmentImpl();
|
||||
System.arraycopy(plaintext, 0, s.getBuffer(), 0, plaintext.length);
|
||||
s.setLength(plaintext.length);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class XorErasureCodeTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testEncodingAndDecodingWithAllSegments() throws Exception {
|
||||
XorErasureEncoder e = new XorErasureEncoder(5);
|
||||
XorErasureDecoder d = new XorErasureDecoder(5);
|
||||
XorErasureDecoder d = new XorErasureDecoder(5, false);
|
||||
Frame f = new Frame(1234);
|
||||
new Random().nextBytes(f.getBuffer());
|
||||
int payload = 1234 - FRAME_HEADER_LENGTH - MAC_LENGTH;
|
||||
@@ -32,7 +32,7 @@ public class XorErasureCodeTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testEncodingAndDecodingWithMissingSegment() throws Exception {
|
||||
XorErasureEncoder e = new XorErasureEncoder(5);
|
||||
XorErasureDecoder d = new XorErasureDecoder(5);
|
||||
XorErasureDecoder d = new XorErasureDecoder(5, false);
|
||||
Frame f = new Frame(1234);
|
||||
new Random().nextBytes(f.getBuffer());
|
||||
int payload = 1234 - FRAME_HEADER_LENGTH - MAC_LENGTH;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class XorErasureDecoderTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testMaximumLength() throws Exception {
|
||||
XorErasureDecoder d = new XorErasureDecoder(5);
|
||||
XorErasureDecoder d = new XorErasureDecoder(5, false);
|
||||
// A frame of the maximum length should be decoded successfully
|
||||
Segment[] set = encodeEmptyFrame(MAX_FRAME_LENGTH / 4, 5);
|
||||
Frame f = new Frame();
|
||||
@@ -37,7 +37,7 @@ public class XorErasureDecoderTest extends BriarTestCase {
|
||||
set[1] = new SegmentImpl(251);
|
||||
set[1].setLength(251);
|
||||
// The frame should be decoded successfully
|
||||
XorErasureDecoder d = new XorErasureDecoder(4);
|
||||
XorErasureDecoder d = new XorErasureDecoder(4, false);
|
||||
Frame f = new Frame(750);
|
||||
assertTrue(d.decodeFrame(f, set));
|
||||
// The minimum of the segments' lengths should have been used
|
||||
@@ -46,7 +46,7 @@ public class XorErasureDecoderTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testDecodingWithMissingSegment() throws Exception {
|
||||
XorErasureDecoder d = new XorErasureDecoder(4);
|
||||
XorErasureDecoder d = new XorErasureDecoder(4, false);
|
||||
for(int i = 0; i < 4; i++) {
|
||||
Segment[] set = encodeEmptyFrame(250, 4);
|
||||
set[i] = null;
|
||||
@@ -59,7 +59,7 @@ public class XorErasureDecoderTest extends BriarTestCase {
|
||||
|
||||
@Test
|
||||
public void testDecodingWithTwoMissingSegments() throws Exception {
|
||||
XorErasureDecoder d = new XorErasureDecoder(4);
|
||||
XorErasureDecoder d = new XorErasureDecoder(4, false);
|
||||
Segment[] set = encodeEmptyFrame(250, 4);
|
||||
set[0] = null;
|
||||
set[1] = null;
|
||||
|
||||
Reference in New Issue
Block a user