Fixed key derivation issues, moved tag encoding into crypto component.

This commit is contained in:
akwizgran
2012-10-24 20:05:18 +01:00
parent 5628342c58
commit d940c637c2
16 changed files with 103 additions and 82 deletions

View File

@@ -53,6 +53,10 @@ public interface CryptoComponent {
*/
byte[] deriveNextSecret(byte[] secret, long period);
/** Encodes the pseudo-random tag that is used to recognise a connection. */
void encodeTag(byte[] tag, Cipher tagCipher, ErasableKey tagKey,
long connection);
KeyPair generateAgreementKeyPair();
KeyPair generateSignatureKeyPair();

View File

@@ -9,6 +9,7 @@ public class TemporarySecret extends ContactTransport {
private final long period, outgoing, centre;
private final byte[] secret, bitmap;
/** Creates a temporary secret with the given connection window. */
public TemporarySecret(ContactId contactId, TransportId transportId,
long epoch, long clockDiff, long latency, boolean alice,
long period, byte[] secret, long outgoing, long centre,
@@ -21,14 +22,19 @@ public class TemporarySecret extends ContactTransport {
this.bitmap = bitmap;
}
/** Creates a temporary secret with a new connection window. */
public TemporarySecret(ContactId contactId, TransportId transportId,
long epoch, long clockDiff, long latency, boolean alice,
long period, byte[] secret) {
this(contactId, transportId, epoch, clockDiff, latency, alice, period,
secret, 0L, 0L, new byte[CONNECTION_WINDOW_SIZE / 8]);
}
/** Creates a temporary secret derived from the given temporary secret. */
public TemporarySecret(TemporarySecret old, long period, byte[] secret) {
super(old.getContactId(), old.getTransportId(), old.getEpoch(),
old.getClockDifference(), old.getLatency(), old.getAlice());
this.period = period;
this.secret = secret;
outgoing = 0L;
centre = 0L;
bitmap = new byte[CONNECTION_WINDOW_SIZE / 8];
this(old.getContactId(), old.getTransportId(), old.getEpoch(),
old.getClockDifference(), old.getLatency(), old.getAlice(),
period, secret);
}
public long getPeriod() {

View File

@@ -8,5 +8,5 @@ public interface ConnectionReaderFactory {
* Creates a connection reader for one side of a connection.
*/
ConnectionReader createConnectionReader(InputStream in,
ConnectionContext ctx, boolean initiator);
ConnectionContext ctx, boolean incoming, boolean initiator);
}

View File

@@ -8,5 +8,5 @@ public interface ConnectionWriterFactory {
* Creates a connection writer for one side of a connection.
*/
ConnectionWriter createConnectionWriter(OutputStream out, long capacity,
ConnectionContext ctx, boolean initiator);
ConnectionContext ctx, boolean incoming, boolean initiator);
}