Removed tag from connection context.

This commit is contained in:
akwizgran
2012-10-19 21:19:52 +01:00
parent 708e4f87dc
commit a12d5ac340
9 changed files with 22 additions and 31 deletions

View File

@@ -1,9 +1,12 @@
package net.sf.briar.transport;
import static net.sf.briar.api.transport.TransportConstants.MAX_FRAME_LENGTH;
import static net.sf.briar.api.transport.TransportConstants.TAG_LENGTH;
import java.io.OutputStream;
import javax.crypto.Cipher;
import net.sf.briar.api.crypto.CryptoComponent;
import net.sf.briar.api.crypto.ErasableKey;
import net.sf.briar.api.transport.ConnectionContext;
@@ -30,9 +33,12 @@ class ConnectionWriterFactoryImpl implements ConnectionWriterFactory {
initiator);
FrameWriter encryption;
if(initiator) {
byte[] tag = new byte[TAG_LENGTH];
Cipher tagCipher = crypto.getTagCipher();
ErasableKey tagKey = crypto.deriveTagKey(secret, alice);
TagEncoder.encodeTag(tag, tagCipher, tagKey, connection);
encryption = new OutgoingEncryptionLayer(out, capacity,
crypto.getFrameCipher(), frameKey, MAX_FRAME_LENGTH,
ctx.getTag());
crypto.getFrameCipher(), frameKey, MAX_FRAME_LENGTH, tag);
} else {
encryption = new OutgoingEncryptionLayer(out, capacity,
crypto.getFrameCipher(), frameKey, MAX_FRAME_LENGTH);

View File

@@ -59,7 +59,7 @@ class TransportConnectionRecogniser {
assert old == null;
} else {
ConnectionContext ctx1 = new ConnectionContext(contactId,
transportId, tag1, secret, connection1, alice);
transportId, secret, connection1, alice);
WindowContext wctx1 = new WindowContext(window, ctx1, period);
WindowContext old = tagMap.put(new Bytes(tag1), wctx1);
assert old == null;
@@ -83,7 +83,7 @@ class TransportConnectionRecogniser {
byte[] tag = new byte[TAG_LENGTH];
TagEncoder.encodeTag(tag, cipher, key, connection);
ConnectionContext ctx = new ConnectionContext(contactId,
transportId, tag, secret, connection, alice);
transportId, secret, connection, alice);
WindowContext wctx = new WindowContext(window, ctx, period);
WindowContext old = tagMap.put(new Bytes(tag), wctx);
assert old == null;