Create DB tables for static keys.

This commit is contained in:
akwizgran
2019-04-09 14:48:45 +01:00
parent ff2f710495
commit b568405f59
17 changed files with 324 additions and 196 deletions

View File

@@ -11,19 +11,19 @@ public interface TransportCrypto {
/**
* Derives initial transport keys for the given transport in the given
* rotation period from the given master secret.
* time period from the given master secret.
*
* @param alice whether the keys are for use by Alice or Bob.
* @param active whether the keys are usable for outgoing streams.
*/
TransportKeys deriveTransportKeys(TransportId t, SecretKey master,
long rotationPeriod, boolean alice, boolean active);
long timePeriod, boolean alice, boolean active);
/**
* Rotates the given transport keys to the given rotation period. If the
* keys are for the given period or any later period they are not rotated.
* Rotates the given transport keys to the given time period. If the keys
* are for the given period or any later period they are not rotated.
*/
TransportKeys rotateTransportKeys(TransportKeys k, long rotationPeriod);
TransportKeys rotateTransportKeys(TransportKeys k, long timePeriod);
/**
* Encodes the pseudo-random tag that is used to recognise a stream.

View File

@@ -554,10 +554,10 @@ public interface DatabaseComponent {
/**
* Sets the reordering window for the given key set and transport in the
* given rotation period.
* given time period.
*/
void setReorderingWindow(Transaction txn, KeySetId k, TransportId t,
long rotationPeriod, long base, byte[] bitmap) throws DbException;
long timePeriod, long base, byte[] bitmap) throws DbException;
/**
* Marks the given transport keys as usable for outgoing streams.

View File

@@ -9,27 +9,27 @@ import static org.briarproject.bramble.api.transport.TransportConstants.REORDERI
/**
* Contains transport keys for receiving streams from a given contact over a
* given transport in a given rotation period.
* given transport in a given time period.
*/
@Immutable
@NotNullByDefault
public class IncomingKeys {
private final SecretKey tagKey, headerKey;
private final long rotationPeriod, windowBase;
private final long timePeriod, windowBase;
private final byte[] windowBitmap;
public IncomingKeys(SecretKey tagKey, SecretKey headerKey,
long rotationPeriod) {
this(tagKey, headerKey, rotationPeriod, 0,
long timePeriod) {
this(tagKey, headerKey, timePeriod, 0,
new byte[REORDERING_WINDOW_SIZE / 8]);
}
public IncomingKeys(SecretKey tagKey, SecretKey headerKey,
long rotationPeriod, long windowBase, byte[] windowBitmap) {
long timePeriod, long windowBase, byte[] windowBitmap) {
this.tagKey = tagKey;
this.headerKey = headerKey;
this.rotationPeriod = rotationPeriod;
this.timePeriod = timePeriod;
this.windowBase = windowBase;
this.windowBitmap = windowBitmap;
}
@@ -42,8 +42,8 @@ public class IncomingKeys {
return headerKey;
}
public long getRotationPeriod() {
return rotationPeriod;
public long getTimePeriod() {
return timePeriod;
}
public long getWindowBase() {

View File

@@ -7,26 +7,26 @@ import javax.annotation.concurrent.Immutable;
/**
* Contains transport keys for sending streams to a given contact over a given
* transport in a given rotation period.
* transport in a given time period.
*/
@Immutable
@NotNullByDefault
public class OutgoingKeys {
private final SecretKey tagKey, headerKey;
private final long rotationPeriod, streamCounter;
private final long timePeriod, streamCounter;
private final boolean active;
public OutgoingKeys(SecretKey tagKey, SecretKey headerKey,
long rotationPeriod, boolean active) {
this(tagKey, headerKey, rotationPeriod, 0, active);
long timePeriod, boolean active) {
this(tagKey, headerKey, timePeriod, 0, active);
}
public OutgoingKeys(SecretKey tagKey, SecretKey headerKey,
long rotationPeriod, long streamCounter, boolean active) {
long timePeriod, long streamCounter, boolean active) {
this.tagKey = tagKey;
this.headerKey = headerKey;
this.rotationPeriod = rotationPeriod;
this.timePeriod = timePeriod;
this.streamCounter = streamCounter;
this.active = active;
}
@@ -39,8 +39,8 @@ public class OutgoingKeys {
return headerKey;
}
public long getRotationPeriod() {
return rotationPeriod;
public long getTimePeriod() {
return timePeriod;
}
public long getStreamCounter() {

View File

@@ -18,11 +18,11 @@ public class TransportKeys {
public TransportKeys(TransportId transportId, IncomingKeys inPrev,
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr) {
if (inPrev.getRotationPeriod() != outCurr.getRotationPeriod() - 1)
if (inPrev.getTimePeriod() != outCurr.getTimePeriod() - 1)
throw new IllegalArgumentException();
if (inCurr.getRotationPeriod() != outCurr.getRotationPeriod())
if (inCurr.getTimePeriod() != outCurr.getTimePeriod())
throw new IllegalArgumentException();
if (inNext.getRotationPeriod() != outCurr.getRotationPeriod() + 1)
if (inNext.getTimePeriod() != outCurr.getTimePeriod() + 1)
throw new IllegalArgumentException();
this.transportId = transportId;
this.inPrev = inPrev;
@@ -51,7 +51,7 @@ public class TransportKeys {
return outCurr;
}
public long getRotationPeriod() {
return outCurr.getRotationPeriod();
public long getTimePeriod() {
return outCurr.getTimePeriod();
}
}