Add a method to get stream context in handshake mode

This commit is contained in:
ameba23
2021-08-27 09:54:24 +02:00
parent 5adbf18851
commit a425a33209

View File

@@ -128,6 +128,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
throws DbException, GeneralSecurityException {
SecretKey staticMasterKey = transportCrypto
.deriveStaticMasterKey(theirPublicKey, ourKeyPair);
LOG.info("Deriving root handshake key " + c.toString() + " " + ourKeyPair.getPublic().toString() + " them: " + theirPublicKey.toString());
SecretKey rootKey =
transportCrypto.deriveHandshakeRootKey(staticMasterKey, false);
boolean alice = transportCrypto.isAlice(theirPublicKey, ourKeyPair);
@@ -135,6 +136,7 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
for (Entry<TransportId, TransportKeyManager> e : managers.entrySet()) {
TransportId t = e.getKey();
TransportKeyManager m = e.getValue();
LOG.info("Adding handshake keys for transport " + t.getString());
ids.put(t, m.addHandshakeKeys(txn, c, rootKey, alice));
}
return ids;
@@ -205,6 +207,14 @@ class KeyManagerImpl implements KeyManager, Service, EventListener {
m.getStreamContext(txn, tag)));
}
@Override
public StreamContext getStreamContextInHandshakeMode(ContactId c, TransportId t)
throws DbException {
return withManager(t, m ->
db.transactionWithNullableResult(false, txn ->
m.getStreamContextInHandshakeMode(txn, c)));
}
@Override
public void eventOccurred(Event e) {
if (e instanceof ContactRemovedEvent) {