Timestamp isn't needed for deriving root key.

This commit is contained in:
akwizgran
2021-06-09 10:07:36 +01:00
committed by Torsten Grote
parent 0df57c82cb
commit f406de6b0c
4 changed files with 6 additions and 10 deletions

View File

@@ -14,8 +14,8 @@ interface TransportKeyAgreementCrypto {
KeyPair generateKeyPair(); KeyPair generateKeyPair();
SecretKey deriveRootKey(KeyPair localKeyPair, PublicKey remotePublicKey, SecretKey deriveRootKey(KeyPair localKeyPair, PublicKey remotePublicKey)
long timestamp) throws GeneralSecurityException; throws GeneralSecurityException;
PublicKey parsePublicKey(byte[] encoded) throws FormatException; PublicKey parsePublicKey(byte[] encoded) throws FormatException;

View File

@@ -34,8 +34,7 @@ class TransportKeyAgreementCryptoImpl implements TransportKeyAgreementCrypto {
@Override @Override
public SecretKey deriveRootKey(KeyPair localKeyPair, public SecretKey deriveRootKey(KeyPair localKeyPair,
PublicKey remotePublicKey, long timestamp) PublicKey remotePublicKey) throws GeneralSecurityException {
throws GeneralSecurityException {
byte[] theirPublic = remotePublicKey.getEncoded(); byte[] theirPublic = remotePublicKey.getEncoded();
byte[] ourPublic = localKeyPair.getPublic().getEncoded(); byte[] ourPublic = localKeyPair.getPublic().getEncoded();
boolean alice = compare(ourPublic, theirPublic) < 0; boolean alice = compare(ourPublic, theirPublic) < 0;

View File

@@ -255,8 +255,7 @@ class TransportKeyAgreementManagerImpl extends BdfIncomingMessageHook
long minTimestamp = min(keyMessage.getTimestamp(), m.getTimestamp()); long minTimestamp = min(keyMessage.getTimestamp(), m.getTimestamp());
SecretKey rootKey; SecretKey rootKey;
try { try {
rootKey = crypto.deriveRootKey(localKeyPair, remotePublicKey, rootKey = crypto.deriveRootKey(localKeyPair, remotePublicKey);
minTimestamp);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
return REJECT; // Invalid public key return REJECT; // Invalid public key
} }
@@ -281,8 +280,7 @@ class TransportKeyAgreementManagerImpl extends BdfIncomingMessageHook
long minTimestamp = min(localTimestamp, m.getTimestamp()); long minTimestamp = min(localTimestamp, m.getTimestamp());
SecretKey rootKey; SecretKey rootKey;
try { try {
rootKey = crypto.deriveRootKey(localKeyPair, remotePublicKey, rootKey = crypto.deriveRootKey(localKeyPair, remotePublicKey);
minTimestamp);
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
return REJECT; // Invalid public key return REJECT; // Invalid public key
} }

View File

@@ -530,8 +530,7 @@ public class TransportKeyAgreementManagerImplTest extends BrambleMockTestCase {
private void expectDeriveAndStoreTransportKeys(Transaction txn) private void expectDeriveAndStoreTransportKeys(Transaction txn)
throws Exception { throws Exception {
context.checking(new Expectations() {{ context.checking(new Expectations() {{
oneOf(crypto).deriveRootKey(localKeyPair, remotePublicKey, oneOf(crypto).deriveRootKey(localKeyPair, remotePublicKey);
min(localTimestamp, remoteTimestamp));
will(returnValue(rootKey)); will(returnValue(rootKey));
oneOf(db).getContact(txn, contact.getId()); oneOf(db).getContact(txn, contact.getId());
will(returnValue(contact)); will(returnValue(contact));