mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Add key derivation for static keys.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.bramble.api.crypto;
|
||||
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.transport.StaticTransportKeys;
|
||||
import org.briarproject.bramble.api.transport.TransportKeys;
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,23 @@ public interface TransportCrypto {
|
||||
*/
|
||||
TransportKeys rotateTransportKeys(TransportKeys k, long timePeriod);
|
||||
|
||||
/**
|
||||
* Derives static transport keys for the given transport in the given time
|
||||
* period from the given root key.
|
||||
*
|
||||
* @param alice whether the keys are for use by Alice or Bob.
|
||||
*/
|
||||
StaticTransportKeys deriveStaticTransportKeys(TransportId t,
|
||||
SecretKey rootKey, boolean alice, long timePeriod);
|
||||
|
||||
/**
|
||||
* Updates the given static transport keys to the given time period. If
|
||||
* the keys are for the given period or any later period they are not
|
||||
* updated.
|
||||
*/
|
||||
StaticTransportKeys updateTransportKeys(StaticTransportKeys k,
|
||||
long timePeriod);
|
||||
|
||||
/**
|
||||
* Encodes the pseudo-random tag that is used to recognise a stream.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.briarproject.bramble.api.transport;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.plugin.TransportId;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class StaticTransportKeys extends TransportKeys {
|
||||
|
||||
private final SecretKey rootKey;
|
||||
private final boolean alice;
|
||||
|
||||
public StaticTransportKeys(TransportId transportId, IncomingKeys inPrev,
|
||||
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr,
|
||||
SecretKey rootKey, boolean alice) {
|
||||
super(transportId, inPrev, inCurr, inNext, outCurr);
|
||||
this.rootKey = rootKey;
|
||||
this.alice = alice;
|
||||
}
|
||||
|
||||
public SecretKey getRootKey() {
|
||||
return rootKey;
|
||||
}
|
||||
|
||||
public boolean isAlice() {
|
||||
return alice;
|
||||
}
|
||||
}
|
||||
@@ -108,4 +108,27 @@ public interface TransportConstants {
|
||||
*/
|
||||
String ROTATE_LABEL = "org.briarproject.bramble.transport/ROTATE";
|
||||
|
||||
/**
|
||||
* Label for deriving Alice's static tag key from the root key.
|
||||
*/
|
||||
String ALICE_STATIC_TAG_LABEL =
|
||||
"org.briarproject.bramble.transport/ALICE_STATIC_TAG_KEY";
|
||||
|
||||
/**
|
||||
* Label for deriving Bob's static tag key from the root key.
|
||||
*/
|
||||
String BOB_STATIC_TAG_LABEL =
|
||||
"org.briarproject.bramble.transport/BOB_STATIC_TAG_KEY";
|
||||
|
||||
/**
|
||||
* Label for deriving Alice's static header key from the root key.
|
||||
*/
|
||||
String ALICE_STATIC_HEADER_LABEL =
|
||||
"org.briarproject.bramble.transport/ALICE_STATIC_HEADER_KEY";
|
||||
|
||||
/**
|
||||
* Label for deriving Bob's static header key from the root key.
|
||||
*/
|
||||
String BOB_STATIC_HEADER_LABEL =
|
||||
"org.briarproject.bramble.transport/BOB_STATIC_HEADER_KEY";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user