Rename static transport keys to handshake keys.

This commit is contained in:
akwizgran
2019-04-17 14:52:52 +01:00
parent e91a7c64d8
commit fafd0c7ff9
16 changed files with 585 additions and 603 deletions

View File

@@ -1,7 +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.HandshakeKeys;
import org.briarproject.bramble.api.transport.TransportKeys;
/**
@@ -27,21 +27,19 @@ 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.
* Derives handshake 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, long timePeriod, boolean alice);
HandshakeKeys deriveHandshakeKeys(TransportId t, SecretKey rootKey,
long timePeriod, boolean alice);
/**
* 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.
* Updates the given handshake keys to the given time period. If the keys
* are for the given period or any later period they are not updated.
*/
StaticTransportKeys updateStaticTransportKeys(StaticTransportKeys k,
long timePeriod);
HandshakeKeys updateHandshakeKeys(HandshakeKeys k, long timePeriod);
/**
* Encodes the pseudo-random tag that is used to recognise a stream.

View File

@@ -21,9 +21,9 @@ import org.briarproject.bramble.api.sync.MessageStatus;
import org.briarproject.bramble.api.sync.Offer;
import org.briarproject.bramble.api.sync.Request;
import org.briarproject.bramble.api.sync.validation.MessageState;
import org.briarproject.bramble.api.transport.StaticTransportKeySet;
import org.briarproject.bramble.api.transport.StaticTransportKeySetId;
import org.briarproject.bramble.api.transport.StaticTransportKeys;
import org.briarproject.bramble.api.transport.HandshakeKeySet;
import org.briarproject.bramble.api.transport.HandshakeKeySetId;
import org.briarproject.bramble.api.transport.HandshakeKeys;
import org.briarproject.bramble.api.transport.TransportKeySet;
import org.briarproject.bramble.api.transport.TransportKeySetId;
import org.briarproject.bramble.api.transport.TransportKeys;
@@ -112,6 +112,20 @@ public interface DatabaseComponent {
*/
void addGroup(Transaction txn, Group g) throws DbException;
/**
* Stores the given handshake keys for the given contact and returns a
* key set ID.
*/
HandshakeKeySetId addHandshakeKeys(Transaction txn, ContactId c,
HandshakeKeys k) throws DbException;
/**
* Stores the given handshake keys for the given pending contact and
* returns a key set ID.
*/
HandshakeKeySetId addHandshakeKeys(Transaction txn, PendingContactId p,
HandshakeKeys k) throws DbException;
/**
* Stores a local pseudonym.
*/
@@ -123,20 +137,6 @@ public interface DatabaseComponent {
void addLocalMessage(Transaction txn, Message m, Metadata meta,
boolean shared) throws DbException;
/**
* Stores the given static transport keys for the given contact and returns
* a key set ID.
*/
StaticTransportKeySetId addStaticTransportKeys(Transaction txn, ContactId c,
StaticTransportKeys k) throws DbException;
/**
* Stores the given static transport keys for the given pending contact and
* returns a key set ID.
*/
StaticTransportKeySetId addStaticTransportKeys(Transaction txn,
PendingContactId p, StaticTransportKeys k) throws DbException;
/**
* Stores a transport.
*/
@@ -287,6 +287,14 @@ public interface DatabaseComponent {
Visibility getGroupVisibility(Transaction txn, ContactId c, GroupId g)
throws DbException;
/**
* Returns all handshake keys for the given transport.
* <p/>
* Read-only.
*/
Collection<HandshakeKeySet> getHandshakeKeys(Transaction txn,
TransportId t) throws DbException;
/**
* Returns the local pseudonym with the given ID.
* <p/>
@@ -442,14 +450,6 @@ public interface DatabaseComponent {
*/
Settings getSettings(Transaction txn, String namespace) throws DbException;
/**
* Returns all static transport keys for the given transport.
* <p/>
* Read-only.
*/
Collection<StaticTransportKeySet> getStaticTransportKeys(Transaction txn,
TransportId t) throws DbException;
/**
* Returns all transport keys for the given transport.
* <p/>
@@ -459,11 +459,10 @@ public interface DatabaseComponent {
throws DbException;
/**
* Increments the outgoing stream counter for the given static transport
* keys.
* Increments the outgoing stream counter for the given handshake keys.
*/
void incrementStreamCounter(Transaction txn, TransportId t,
StaticTransportKeySetId k) throws DbException;
HandshakeKeySetId k) throws DbException;
/**
* Increments the outgoing stream counter for the given transport keys.
@@ -524,6 +523,12 @@ public interface DatabaseComponent {
*/
void removeGroup(Transaction txn, Group g) throws DbException;
/**
* Removes the given handshake keys from the database.
*/
void removeHandshakeKeys(Transaction txn, TransportId t,
HandshakeKeySetId k) throws DbException;
/**
* Removes a local pseudonym (and all associated state) from the database.
*/
@@ -534,12 +539,6 @@ public interface DatabaseComponent {
*/
void removeMessage(Transaction txn, MessageId m) throws DbException;
/**
* Removes the given static transport keys from the database.
*/
void removeStaticTransportKeys(Transaction txn, TransportId t,
StaticTransportKeySetId k) throws DbException;
/**
* Removes a transport (and all associated state) from the database.
*/
@@ -606,11 +605,10 @@ public interface DatabaseComponent {
TransportKeySetId k) throws DbException;
/**
* Stores the given static transport keys, deleting any keys they have
* replaced.
* Stores the given handshake keys, deleting any keys they have replaced.
*/
void updateStaticTransportKeys(Transaction txn,
Collection<StaticTransportKeySet> keys) throws DbException;
void updateHandshakeKeys(Transaction txn, Collection<HandshakeKeySet> keys)
throws DbException;
/**
* Stores the given transport keys, deleting any keys they have replaced.

View File

@@ -6,8 +6,7 @@ import org.briarproject.bramble.api.plugin.TransportId;
import javax.annotation.concurrent.Immutable;
/**
* Abstract superclass for {@link TransportKeys} and
* {@link StaticTransportKeys}.
* Abstract superclass for {@link TransportKeys} and {@link HandshakeKeys}.
*/
@Immutable
@NotNullByDefault

View File

@@ -8,37 +8,38 @@ import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
/**
* A set of transport keys for communicating with a contact or pending contact.
* Unlike a {@link TransportKeySet} these keys do not provide forward secrecy.
* A set of keys for handshaking with a given contact or pending contact over a
* given transport. Unlike a {@link TransportKeySet} these keys do not provide
* forward secrecy.
*/
@Immutable
@NotNullByDefault
public class StaticTransportKeySet {
public class HandshakeKeySet {
private final StaticTransportKeySetId keySetId;
private final HandshakeKeySetId keySetId;
@Nullable
private final ContactId contactId;
@Nullable
private final PendingContactId pendingContactId;
private final StaticTransportKeys keys;
private final HandshakeKeys keys;
public StaticTransportKeySet(StaticTransportKeySetId keySetId,
ContactId contactId, StaticTransportKeys keys) {
public HandshakeKeySet(HandshakeKeySetId keySetId, ContactId contactId,
HandshakeKeys keys) {
this.keySetId = keySetId;
this.contactId = contactId;
this.keys = keys;
pendingContactId = null;
}
public StaticTransportKeySet(StaticTransportKeySetId keySetId,
PendingContactId pendingContactId, StaticTransportKeys keys) {
public HandshakeKeySet(HandshakeKeySetId keySetId,
PendingContactId pendingContactId, HandshakeKeys keys) {
this.keySetId = keySetId;
this.pendingContactId = pendingContactId;
this.keys = keys;
contactId = null;
}
public StaticTransportKeySetId getKeySetId() {
public HandshakeKeySetId getKeySetId() {
return keySetId;
}
@@ -52,7 +53,7 @@ public class StaticTransportKeySet {
return pendingContactId;
}
public StaticTransportKeys getKeys() {
public HandshakeKeys getKeys() {
return keys;
}
@@ -63,7 +64,7 @@ public class StaticTransportKeySet {
@Override
public boolean equals(Object o) {
return o instanceof StaticTransportKeySet &&
keySetId.equals(((StaticTransportKeySet) o).keySetId);
return o instanceof HandshakeKeySet &&
keySetId.equals(((HandshakeKeySet) o).keySetId);
}
}

View File

@@ -6,16 +6,16 @@ import javax.annotation.concurrent.Immutable;
/**
* Type-safe wrapper for an integer that uniquely identifies a
* {@link StaticTransportKeySet set of static transport keys} within the scope
* of the local device.
* {@link HandshakeKeySet set of handshake keys} within the scope of the local
* device.
*/
@Immutable
@NotNullByDefault
public class StaticTransportKeySetId {
public class HandshakeKeySetId {
private final int id;
public StaticTransportKeySetId(int id) {
public HandshakeKeySetId(int id) {
this.id = id;
}
@@ -30,7 +30,7 @@ public class StaticTransportKeySetId {
@Override
public boolean equals(Object o) {
return o instanceof StaticTransportKeySetId &&
id == ((StaticTransportKeySetId) o).id;
return o instanceof HandshakeKeySetId &&
id == ((HandshakeKeySetId) o).id;
}
}

View File

@@ -7,17 +7,18 @@ import org.briarproject.bramble.api.plugin.TransportId;
import javax.annotation.concurrent.Immutable;
/**
* Keys for communicating with a given contact or pending contact over a given
* transport. Unlike {@link TransportKeys} these do not provide forward secrecy.
* Keys for handshaking with a given contact or pending contact over a given
* transport. Unlike {@link TransportKeys} these keys do not provide forward
* secrecy.
*/
@Immutable
@NotNullByDefault
public class StaticTransportKeys extends AbstractTransportKeys {
public class HandshakeKeys extends AbstractTransportKeys {
private final SecretKey rootKey;
private final boolean alice;
public StaticTransportKeys(TransportId transportId, IncomingKeys inPrev,
public HandshakeKeys(TransportId transportId, IncomingKeys inPrev,
IncomingKeys inCurr, IncomingKeys inNext, OutgoingKeys outCurr,
SecretKey rootKey, boolean alice) {
super(transportId, inPrev, inCurr, inNext, outCurr);

View File

@@ -109,26 +109,26 @@ public interface TransportConstants {
String ROTATE_LABEL = "org.briarproject.bramble.transport/ROTATE";
/**
* Label for deriving Alice's static tag key from the root key.
* Label for deriving Alice's handshake tag key from the root key.
*/
String ALICE_STATIC_TAG_LABEL =
String ALICE_HANDSHAKE_TAG_LABEL =
"org.briarproject.bramble.transport/ALICE_STATIC_TAG_KEY";
/**
* Label for deriving Bob's static tag key from the root key.
* Label for deriving Bob's handshake tag key from the root key.
*/
String BOB_STATIC_TAG_LABEL =
String BOB_HANDSHAKE_TAG_LABEL =
"org.briarproject.bramble.transport/BOB_STATIC_TAG_KEY";
/**
* Label for deriving Alice's static header key from the root key.
* Label for deriving Alice's handshake header key from the root key.
*/
String ALICE_STATIC_HEADER_LABEL =
String ALICE_HANDSHAKE_HEADER_LABEL =
"org.briarproject.bramble.transport/ALICE_STATIC_HEADER_KEY";
/**
* Label for deriving Bob's static header key from the root key.
* Label for deriving Bob's handshake header key from the root key.
*/
String BOB_STATIC_HEADER_LABEL =
String BOB_HANDSHAKE_HEADER_LABEL =
"org.briarproject.bramble.transport/BOB_STATIC_HEADER_KEY";
}

View File

@@ -6,7 +6,8 @@ import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import javax.annotation.concurrent.Immutable;
/**
* A set of transport keys for communicating with a contact.
* A set of keys for communicating with a given contact over a given transport.
* Unlike a {@link HandshakeKeySet} these keys provide forward secrecy.
*/
@Immutable
@NotNullByDefault

View File

@@ -7,7 +7,7 @@ import javax.annotation.concurrent.Immutable;
/**
* Keys for communicating with a given contact over a given transport. Unlike
* {@link StaticTransportKeys}, these keys provide forward secrecy.
* {@link HandshakeKeys} these keys provide forward secrecy.
*/
@Immutable
@NotNullByDefault