Derive and store secrets when a contact transport is added.

This commit is contained in:
akwizgran
2012-10-24 23:34:46 +01:00
parent 79a8d1c19d
commit 1b8478df84
4 changed files with 88 additions and 38 deletions

View File

@@ -1,15 +1,15 @@
package net.sf.briar.api.crypto;
import net.sf.briar.api.ContactId;
import net.sf.briar.api.db.ContactTransport;
import net.sf.briar.api.protocol.TransportId;
import net.sf.briar.api.transport.ConnectionContext;
public interface KeyManager {
/**
* Starts the key manager and returns true if the manager started
* successfully. This method must be called after the database has been
* opened.
* Starts the key manager and returns true if it started successfully. This
* method must be called after the database has been opened.
*/
boolean start();
@@ -22,4 +22,10 @@ public interface KeyManager {
* support the transport.
*/
ConnectionContext getConnectionContext(ContactId c, TransportId t);
/**
* Called whenever a contact transport has been added. The initial secret
* is erased before returning.
*/
void contactTransportAdded(ContactTransport ct, byte[] initialSecret);
}

View File

@@ -30,10 +30,10 @@ public class TemporarySecret extends ContactTransport {
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) {
this(old.getContactId(), old.getTransportId(), old.getEpoch(),
old.getClockDifference(), old.getLatency(), old.getAlice(),
/** Creates a temporary secret derived from the given contact transport. */
public TemporarySecret(ContactTransport ct, long period, byte[] secret) {
this(ct.getContactId(), ct.getTransportId(), ct.getEpoch(),
ct.getClockDifference(), ct.getLatency(), ct.getAlice(),
period, secret);
}