Derive handshake root key when adding a pending contact.

This commit is contained in:
akwizgran
2019-05-30 15:48:26 +01:00
parent 9b4f60088f
commit 810d45d6b9
6 changed files with 79 additions and 19 deletions

View File

@@ -11,6 +11,12 @@ import java.security.GeneralSecurityException;
*/
public interface TransportCrypto {
/**
* Returns true if the local peer is Alice.
*/
boolean isAlice(PublicKey theirHandshakePublicKey,
KeyPair ourHandshakeKeyPair);
/**
* Derives the static master key shared with a contact or pending contact.
*/
@@ -19,6 +25,7 @@ public interface TransportCrypto {
/**
* Derives the handshake mode root key from the static master key.
*
* @param pendingContact Whether the static master key is shared with a
* pending contact or a contact
*/

View File

@@ -1,12 +1,15 @@
package org.briarproject.bramble.api.transport;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.contact.PendingContact;
import org.briarproject.bramble.api.contact.PendingContactId;
import org.briarproject.bramble.api.crypto.KeyPair;
import org.briarproject.bramble.api.crypto.SecretKey;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.db.Transaction;
import org.briarproject.bramble.api.plugin.TransportId;
import java.security.GeneralSecurityException;
import java.util.Map;
import javax.annotation.Nullable;
@@ -53,12 +56,10 @@ public interface KeyManager {
* <p/>
* {@link StreamContext StreamContexts} for the pending contact can be
* created after this method has returned.
*
* @param alice True if the local party is Alice
*/
Map<TransportId, KeySetId> addPendingContact(Transaction txn,
PendingContactId p, SecretKey rootKey, boolean alice)
throws DbException;
PendingContact p, KeyPair ourKeyPair)
throws DbException, GeneralSecurityException;
/**
* Marks the given transport keys as usable for outgoing streams.