mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Implemented KeyManager (untested).
A test is failing due to key derivation errors - must be fixed!
This commit is contained in:
@@ -6,10 +6,20 @@ 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.
|
||||
*/
|
||||
boolean start();
|
||||
|
||||
/** Stops the key manager. */
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Returns a connection context for connecting to the given contact over
|
||||
* the given transport, or null if the contact does not support the
|
||||
* transport.
|
||||
* the given transport, or null if an error occurs or the contact does not
|
||||
* support the transport.
|
||||
*/
|
||||
ConnectionContext getConnectionContext(ContactId c, TransportId t);
|
||||
}
|
||||
|
||||
@@ -114,9 +114,6 @@ public interface DatabaseComponent {
|
||||
/** Returns the IDs of all contacts. */
|
||||
Collection<ContactId> getContacts() throws DbException;
|
||||
|
||||
/** Returns all contact transports. */
|
||||
Collection<ContactTransport> getContactTransports() throws DbException;
|
||||
|
||||
/** Returns the local transport properties for the given transport. */
|
||||
TransportProperties getLocalProperties(TransportId t) throws DbException;
|
||||
|
||||
@@ -150,9 +147,9 @@ public interface DatabaseComponent {
|
||||
|
||||
/**
|
||||
* Increments the outgoing connection counter for the given contact
|
||||
* transport in the given rotation period.
|
||||
* transport in the given rotation period and returns the old value.
|
||||
*/
|
||||
void incrementConnectionCounter(ContactId c, TransportId t, long period)
|
||||
long incrementConnectionCounter(ContactId c, TransportId t, long period)
|
||||
throws DbException;
|
||||
|
||||
/** Processes an acknowledgement from the given contact. */
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package net.sf.briar.api.db;
|
||||
|
||||
import static net.sf.briar.api.transport.TransportConstants.CONNECTION_WINDOW_SIZE;
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
|
||||
public class TemporarySecret {
|
||||
public class TemporarySecret extends ContactTransport {
|
||||
|
||||
private final ContactId contactId;
|
||||
private final TransportId transportId;
|
||||
private final long period, outgoing, centre;
|
||||
private final byte[] secret, bitmap;
|
||||
|
||||
public TemporarySecret(ContactId contactId, TransportId transportId,
|
||||
long epoch, long clockDiff, long latency, boolean alice,
|
||||
long period, byte[] secret, long outgoing, long centre,
|
||||
byte[] bitmap) {
|
||||
this.contactId = contactId;
|
||||
this.transportId = transportId;
|
||||
super(contactId, transportId, epoch, clockDiff, latency, alice);
|
||||
this.period = period;
|
||||
this.secret = secret;
|
||||
this.outgoing = outgoing;
|
||||
@@ -22,12 +21,14 @@ public class TemporarySecret {
|
||||
this.bitmap = bitmap;
|
||||
}
|
||||
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public TransportId getTransportId() {
|
||||
return transportId;
|
||||
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];
|
||||
}
|
||||
|
||||
public long getPeriod() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.sf.briar.api.transport;
|
||||
|
||||
import net.sf.briar.api.ContactId;
|
||||
import net.sf.briar.api.db.DbException;
|
||||
import net.sf.briar.api.db.TemporarySecret;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
|
||||
/**
|
||||
@@ -17,10 +18,11 @@ public interface ConnectionRecogniser {
|
||||
ConnectionContext acceptConnection(TransportId t, byte[] tag)
|
||||
throws DbException;
|
||||
|
||||
void addWindow(ContactId c, TransportId t, long period, boolean alice,
|
||||
byte[] secret, long centre, byte[] bitmap) throws DbException;
|
||||
void addSecret(TemporarySecret s) throws DbException;
|
||||
|
||||
void removeWindow(ContactId c, TransportId t, long period);
|
||||
void removeSecret(ContactId c, TransportId t, long period);
|
||||
|
||||
void removeWindows(ContactId c);
|
||||
void removeSecrets(ContactId c);
|
||||
|
||||
void removeSecrets();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user