Don't send tags for invitation connections.

This commit is contained in:
akwizgran
2014-11-09 17:11:16 +00:00
parent 8584194138
commit c280e213c8
5 changed files with 38 additions and 16 deletions

View File

@@ -133,11 +133,11 @@ class AliceConnector extends Connector {
int maxFrameLength = conn.getReader().getMaxFrameLength();
StreamReader streamReader =
streamReaderFactory.createInvitationStreamReader(in,
maxFrameLength, secret, false);
maxFrameLength, secret, false); // Bob's stream
r = readerFactory.createReader(streamReader.getInputStream());
StreamWriter streamWriter =
streamWriterFactory.createInvitationStreamWriter(out,
maxFrameLength, secret, true);
maxFrameLength, secret, true); // Alice's stream
w = writerFactory.createWriter(streamWriter.getOutputStream());
// Derive the invitation nonces
byte[][] nonces = crypto.deriveInvitationNonces(secret);

View File

@@ -133,11 +133,11 @@ class BobConnector extends Connector {
int maxFrameLength = conn.getReader().getMaxFrameLength();
StreamReader streamReader =
streamReaderFactory.createInvitationStreamReader(in,
maxFrameLength, secret, true);
maxFrameLength, secret, true); // Alice's stream
r = readerFactory.createReader(streamReader.getInputStream());
StreamWriter streamWriter =
streamWriterFactory.createInvitationStreamWriter(out,
maxFrameLength, secret, false);
maxFrameLength, secret, false); // Bob's stream
w = writerFactory.createWriter(streamWriter.getOutputStream());
// Derive the nonces
byte[][] nonces = crypto.deriveInvitationNonces(secret);

View File

@@ -35,7 +35,7 @@ class OutgoingEncryptionLayer implements FrameWriter {
aad = new byte[AAD_LENGTH];
ciphertext = new byte[frameLength];
frameNumber = 0;
writeTag = true;
writeTag = (tag != null);
}
public void writeFrame(byte[] frame, int payloadLength, boolean finalFrame)

View File

@@ -38,13 +38,9 @@ class StreamWriterFactoryImpl implements StreamWriterFactory {
public StreamWriter createInvitationStreamWriter(OutputStream out,
int maxFrameLength, byte[] secret, boolean alice) {
byte[] tag = new byte[TAG_LENGTH];
SecretKey tagKey = crypto.deriveTagKey(secret, alice);
crypto.encodeTag(tag, tagKey, 0);
tagKey.erase();
SecretKey frameKey = crypto.deriveFrameKey(secret, 0, alice);
FrameWriter frameWriter = new OutgoingEncryptionLayer(out,
crypto.getFrameCipher(), frameKey, maxFrameLength, tag);
crypto.getFrameCipher(), frameKey, maxFrameLength, null);
return new StreamWriterImpl(frameWriter, maxFrameLength);
}
}