mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Timestamp isn't needed for deriving root key.
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
Reference in New Issue
Block a user