mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 06:09:55 +01:00
Add a key manager method for adding a single set of transport keys.
This commit is contained in:
@@ -22,8 +22,23 @@ public interface KeyManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Derives and stores a set of rotation mode transport keys for
|
* Derives and stores a set of rotation mode transport keys for
|
||||||
* communicating with the given contact over each transport and returns the
|
* communicating with the given contact over the given transport and
|
||||||
* key set IDs.
|
* returns the key set ID.
|
||||||
|
* <p/>
|
||||||
|
* {@link StreamContext StreamContexts} for the contact can be created
|
||||||
|
* after this method has returned.
|
||||||
|
*
|
||||||
|
* @param alice True if the local party is Alice
|
||||||
|
* @param active Whether the derived keys can be used for outgoing streams
|
||||||
|
*/
|
||||||
|
KeySetId addRotationKeys(Transaction txn, ContactId c, TransportId t,
|
||||||
|
SecretKey rootKey, long timestamp, boolean alice,
|
||||||
|
boolean active) throws DbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derives and stores a set of rotation mode transport keys for
|
||||||
|
* communicating with the given contact over each supported transport and
|
||||||
|
* returns the key set IDs.
|
||||||
* <p/>
|
* <p/>
|
||||||
* {@link StreamContext StreamContexts} for the contact can be created
|
* {@link StreamContext StreamContexts} for the contact can be created
|
||||||
* after this method has returned.
|
* after this method has returned.
|
||||||
|
|||||||
@@ -101,9 +101,17 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<TransportId, KeySetId> addRotationKeys(
|
public KeySetId addRotationKeys(Transaction txn, ContactId c,
|
||||||
Transaction txn, ContactId c, SecretKey rootKey, long timestamp,
|
TransportId t, SecretKey rootKey, long timestamp, boolean alice,
|
||||||
boolean alice, boolean active) throws DbException {
|
boolean active) throws DbException {
|
||||||
|
return withManager(t, m ->
|
||||||
|
m.addRotationKeys(txn, c, rootKey, timestamp, alice, active));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<TransportId, KeySetId> addRotationKeys(Transaction txn,
|
||||||
|
ContactId c, SecretKey rootKey, long timestamp, boolean alice,
|
||||||
|
boolean active) throws DbException {
|
||||||
Map<TransportId, KeySetId> ids = new HashMap<>();
|
Map<TransportId, KeySetId> ids = new HashMap<>();
|
||||||
for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) {
|
for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) {
|
||||||
TransportId t = e.getKey();
|
TransportId t = e.getKey();
|
||||||
@@ -137,7 +145,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
|
|||||||
PendingContactId p, PublicKey theirPublicKey, KeyPair ourKeyPair)
|
PendingContactId p, PublicKey theirPublicKey, KeyPair ourKeyPair)
|
||||||
throws DbException, GeneralSecurityException {
|
throws DbException, GeneralSecurityException {
|
||||||
SecretKey staticMasterKey = transportCrypto
|
SecretKey staticMasterKey = transportCrypto
|
||||||
.deriveStaticMasterKey(theirPublicKey, ourKeyPair);
|
.deriveStaticMasterKey(theirPublicKey, ourKeyPair);
|
||||||
SecretKey rootKey =
|
SecretKey rootKey =
|
||||||
transportCrypto.deriveHandshakeRootKey(staticMasterKey, true);
|
transportCrypto.deriveHandshakeRootKey(staticMasterKey, true);
|
||||||
boolean alice = transportCrypto.isAlice(theirPublicKey, ourKeyPair);
|
boolean alice = transportCrypto.isAlice(theirPublicKey, ourKeyPair);
|
||||||
|
|||||||
Reference in New Issue
Block a user