mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Reuse TransportCrypto#isAlice().
This commit is contained in:
@@ -10,9 +10,6 @@ import java.security.GeneralSecurityException;
|
||||
@NotNullByDefault
|
||||
interface HandshakeCrypto {
|
||||
|
||||
boolean isLocalPeerAlice(PublicKey theirStaticPublicKey,
|
||||
KeyPair ourStaticKeyPair);
|
||||
|
||||
KeyPair generateEphemeralKeyPair();
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ import java.security.GeneralSecurityException;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.Bytes.compare;
|
||||
import static org.briarproject.bramble.contact.HandshakeConstants.ALICE_PROOF_LABEL;
|
||||
import static org.briarproject.bramble.contact.HandshakeConstants.BOB_PROOF_LABEL;
|
||||
import static org.briarproject.bramble.contact.HandshakeConstants.MASTER_KEY_LABEL;
|
||||
@@ -27,14 +26,6 @@ class HandshakeCryptoImpl implements HandshakeCrypto {
|
||||
this.crypto = crypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocalPeerAlice(PublicKey theirStaticPublicKey,
|
||||
KeyPair ourStaticKeyPair) {
|
||||
byte[] ours = ourStaticKeyPair.getPublic().getEncoded();
|
||||
byte[] theirs = theirStaticPublicKey.getEncoded();
|
||||
return compare(ours, theirs) < 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyPair generateEphemeralKeyPair() {
|
||||
return crypto.generateAgreementKeyPair();
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.briarproject.bramble.api.crypto.AgreementPublicKey;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.crypto.TransportCrypto;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.TransactionManager;
|
||||
@@ -54,6 +55,7 @@ class HandshakeManagerImpl implements HandshakeManager {
|
||||
private final TransactionManager db;
|
||||
private final IdentityManager identityManager;
|
||||
private final ContactManager contactManager;
|
||||
private final TransportCrypto transportCrypto;
|
||||
private final HandshakeCrypto handshakeCrypto;
|
||||
private final RecordReaderFactory recordReaderFactory;
|
||||
private final RecordWriterFactory recordWriterFactory;
|
||||
@@ -62,12 +64,14 @@ class HandshakeManagerImpl implements HandshakeManager {
|
||||
HandshakeManagerImpl(DatabaseComponent db,
|
||||
IdentityManager identityManager,
|
||||
ContactManager contactManager,
|
||||
TransportCrypto transportCrypto,
|
||||
HandshakeCrypto handshakeCrypto,
|
||||
RecordReaderFactory recordReaderFactory,
|
||||
RecordWriterFactory recordWriterFactory) {
|
||||
this.db = db;
|
||||
this.identityManager = identityManager;
|
||||
this.contactManager = contactManager;
|
||||
this.transportCrypto = transportCrypto;
|
||||
this.handshakeCrypto = handshakeCrypto;
|
||||
this.recordReaderFactory = recordReaderFactory;
|
||||
this.recordWriterFactory = recordWriterFactory;
|
||||
@@ -84,7 +88,7 @@ class HandshakeManagerImpl implements HandshakeManager {
|
||||
});
|
||||
PublicKey theirStaticPublicKey = keys.getFirst();
|
||||
KeyPair ourStaticKeyPair = keys.getSecond();
|
||||
boolean alice = handshakeCrypto.isLocalPeerAlice(theirStaticPublicKey,
|
||||
boolean alice = transportCrypto.isAlice(theirStaticPublicKey,
|
||||
ourStaticKeyPair);
|
||||
RecordReader recordReader = recordReaderFactory.createRecordReader(in);
|
||||
RecordWriter recordWriter = recordWriterFactory
|
||||
|
||||
Reference in New Issue
Block a user