Make room for the ack header.

This commit is contained in:
akwizgran
2012-01-24 09:28:28 +00:00
parent ffe3bafce4
commit 3d4b5e6282
21 changed files with 100 additions and 66 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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