mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Address second round of review comments
This commit is contained in:
@@ -11,23 +11,25 @@ import org.briarproject.bramble.api.plugin.TransportId;
|
||||
import org.briarproject.bramble.api.properties.TransportProperties;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||
import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTransportPropertiesMap;
|
||||
import static org.briarproject.bramble.util.StringUtils.fromHexString;
|
||||
import static org.briarproject.briar.introduction.IntroduceeSession.Local;
|
||||
import static org.briarproject.briar.introduction.IntroduceeSession.Remote;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.getRealAuthor;
|
||||
import static org.briarproject.briar.test.BriarTestUtils.getRealLocalAuthor;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class IntroductionCryptoImplTest extends BrambleTestCase {
|
||||
public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
|
||||
|
||||
@Inject
|
||||
ClientHelper clientHelper;
|
||||
@@ -42,33 +44,28 @@ public class IntroductionCryptoImplTest extends BrambleTestCase {
|
||||
private final LocalAuthor alice, bob;
|
||||
private final long aliceAcceptTimestamp = 42L;
|
||||
private final long bobAcceptTimestamp = 1337L;
|
||||
private final SecretKey masterKey =
|
||||
new SecretKey(getRandomBytes(SecretKey.LENGTH));
|
||||
private final SecretKey masterKey = getSecretKey();
|
||||
private final KeyPair aliceEphemeral, bobEphemeral;
|
||||
private final Map<TransportId, TransportProperties> aliceTransport =
|
||||
getTransportPropertiesMap(3);
|
||||
private final Map<TransportId, TransportProperties> bobTransport =
|
||||
getTransportPropertiesMap(3);
|
||||
|
||||
public IntroductionCryptoImplTest() {
|
||||
BriarIntegrationTestComponent component =
|
||||
DaggerBriarIntegrationTestComponent.builder().build();
|
||||
public IntroductionCryptoIntegrationTest() {
|
||||
IntroductionIntegrationTestComponent component =
|
||||
DaggerIntroductionIntegrationTestComponent.builder().build();
|
||||
component.inject(this);
|
||||
crypto = new IntroductionCryptoImpl(cryptoComponent, clientHelper);
|
||||
|
||||
// create actual deterministic authors for testing
|
||||
introducer = authorFactory
|
||||
.createAuthor("Introducer", new byte[] {0x1, 0x2, 0x3});
|
||||
alice = authorFactory.createLocalAuthor("Alice",
|
||||
fromHexString(
|
||||
"A626F080C94771698F86B4B4094C4F560904B53398805AE02BA2343F1829187A"),
|
||||
fromHexString(
|
||||
"60F010187AF91ACA15141E8C811EC8E79C7CAA6461C21A852BB03066C89B0A70"));
|
||||
bob = authorFactory.createLocalAuthor("Bob",
|
||||
fromHexString(
|
||||
"A0D0FED1CE4674D8B6441AD0A664E41BF60D489F35DA11F52AF923540848546F"),
|
||||
fromHexString(
|
||||
"20B25BE7E999F68FE07189449E91984FA79121DBFF28A651669A3CF512D6A758"));
|
||||
introducer = getRealAuthor(authorFactory);
|
||||
LocalAuthor introducee1 =
|
||||
getRealLocalAuthor(cryptoComponent, authorFactory);
|
||||
LocalAuthor introducee2 =
|
||||
getRealLocalAuthor(cryptoComponent, authorFactory);
|
||||
boolean isAlice =
|
||||
crypto.isAlice(introducee1.getId(), introducee2.getId());
|
||||
alice = isAlice ? introducee1 : introducee2;
|
||||
bob = isAlice ? introducee2 : introducee1;
|
||||
aliceEphemeral = crypto.generateKeyPair();
|
||||
bobEphemeral = crypto.generateKeyPair();
|
||||
}
|
||||
@@ -78,6 +75,9 @@ public class IntroductionCryptoImplTest extends BrambleTestCase {
|
||||
SessionId s1 = crypto.getSessionId(introducer, alice, bob);
|
||||
SessionId s2 = crypto.getSessionId(introducer, bob, alice);
|
||||
assertEquals(s1, s2);
|
||||
|
||||
SessionId s3 = crypto.getSessionId(alice, bob, introducer);
|
||||
assertNotEquals(s1, s3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,62 +88,66 @@ public class IntroductionCryptoImplTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testDeriveMasterKey() throws Exception {
|
||||
SecretKey aliceMasterKey = crypto.deriveMasterKey(alice.getPublicKey(),
|
||||
alice.getPrivateKey(), bob.getPublicKey(), true);
|
||||
SecretKey bobMasterKey = crypto.deriveMasterKey(bob.getPublicKey(),
|
||||
bob.getPrivateKey(), alice.getPublicKey(), false);
|
||||
SecretKey aliceMasterKey =
|
||||
crypto.deriveMasterKey(aliceEphemeral.getPublic().getEncoded(),
|
||||
aliceEphemeral.getPrivate().getEncoded(),
|
||||
bobEphemeral.getPublic().getEncoded(), true);
|
||||
SecretKey bobMasterKey =
|
||||
crypto.deriveMasterKey(bobEphemeral.getPublic().getEncoded(),
|
||||
bobEphemeral.getPrivate().getEncoded(),
|
||||
aliceEphemeral.getPublic().getEncoded(), false);
|
||||
assertArrayEquals(aliceMasterKey.getBytes(), bobMasterKey.getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliceAuthMac() throws Exception {
|
||||
SecretKey aliceMacKey = crypto.deriveMacKey(masterKey, true);
|
||||
Local local = new Local(true, null, -1,
|
||||
aliceEphemeral.getPublic().getEncoded(),
|
||||
aliceEphemeral.getPrivate().getEncoded(), aliceTransport,
|
||||
aliceAcceptTimestamp, aliceMacKey.getBytes());
|
||||
Remote remote = new Remote(false, bob, null,
|
||||
bobEphemeral.getPublic().getEncoded(), bobTransport,
|
||||
bobAcceptTimestamp, null);
|
||||
byte[] aliceMac =
|
||||
crypto.authMac(aliceMacKey, introducer.getId(), alice.getId(),
|
||||
bob.getId(), aliceAcceptTimestamp, bobAcceptTimestamp,
|
||||
aliceEphemeral.getPublic().getEncoded(),
|
||||
bobEphemeral.getPublic().getEncoded(), aliceTransport,
|
||||
bobTransport, true);
|
||||
local, remote);
|
||||
|
||||
// verify from Bob's perspective
|
||||
crypto.verifyAuthMac(aliceMac, aliceMacKey, introducer.getId(),
|
||||
bob.getId(), alice.getId(), bobAcceptTimestamp,
|
||||
aliceAcceptTimestamp, bobEphemeral.getPublic().getEncoded(),
|
||||
aliceEphemeral.getPublic().getEncoded(), bobTransport,
|
||||
aliceTransport, true);
|
||||
bob.getId(), remote, alice.getId(), local);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBobAuthMac() throws Exception {
|
||||
SecretKey bobMacKey = crypto.deriveMacKey(masterKey, false);
|
||||
Local local = new Local(false, null, -1,
|
||||
bobEphemeral.getPublic().getEncoded(),
|
||||
bobEphemeral.getPrivate().getEncoded(), bobTransport,
|
||||
bobAcceptTimestamp, bobMacKey.getBytes());
|
||||
Remote remote = new Remote(true, alice, null,
|
||||
aliceEphemeral.getPublic().getEncoded(), aliceTransport,
|
||||
aliceAcceptTimestamp, null);
|
||||
byte[] bobMac =
|
||||
crypto.authMac(bobMacKey, introducer.getId(), bob.getId(),
|
||||
alice.getId(), bobAcceptTimestamp, aliceAcceptTimestamp,
|
||||
bobEphemeral.getPublic().getEncoded(),
|
||||
aliceEphemeral.getPublic().getEncoded(), bobTransport,
|
||||
aliceTransport, false);
|
||||
local, remote);
|
||||
|
||||
// verify from Alice's perspective
|
||||
crypto.verifyAuthMac(bobMac, bobMacKey, introducer.getId(),
|
||||
alice.getId(), bob.getId(), aliceAcceptTimestamp,
|
||||
bobAcceptTimestamp, aliceEphemeral.getPublic().getEncoded(),
|
||||
bobEphemeral.getPublic().getEncoded(), aliceTransport,
|
||||
bobTransport, false);
|
||||
alice.getId(), remote, bob.getId(), local);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSign() throws Exception {
|
||||
KeyPair keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||
SecretKey macKey = crypto.deriveMacKey(masterKey, true);
|
||||
byte[] signature =
|
||||
crypto.sign(macKey, keyPair.getPrivate().getEncoded());
|
||||
crypto.verifySignature(macKey, keyPair.getPublic().getEncoded(),
|
||||
signature);
|
||||
byte[] signature = crypto.sign(macKey, alice.getPrivateKey());
|
||||
crypto.verifySignature(macKey, alice.getPublicKey(), signature);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliceActivateMac() throws Exception {
|
||||
SecretKey aliceMacKey = crypto.deriveMacKey(masterKey, true);
|
||||
byte[] aliceMac = crypto.activateMac(aliceMacKey);
|
||||
|
||||
crypto.verifyActivateMac(aliceMac, aliceMacKey);
|
||||
}
|
||||
|
||||
@@ -151,7 +155,6 @@ public class IntroductionCryptoImplTest extends BrambleTestCase {
|
||||
public void testBobActivateMac() throws Exception {
|
||||
SecretKey bobMacKey = crypto.deriveMacKey(masterKey, false);
|
||||
byte[] bobMac = crypto.activateMac(bobMacKey);
|
||||
|
||||
crypto.verifyActivateMac(bobMac, bobMacKey);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.briar.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
@@ -10,7 +9,7 @@ import org.jmock.Expectations;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.briarproject.bramble.test.TestUtils.getAuthor;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.LABEL_SESSION_ID;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -25,7 +24,7 @@ public class IntroductionCryptoTest extends BrambleMockTestCase {
|
||||
|
||||
private final Author introducer = getAuthor();
|
||||
private final Author alice = getAuthor(), bob = getAuthor();
|
||||
private final byte[] hash = getRandomBytes(UniqueId.LENGTH);
|
||||
private final byte[] hash = getRandomId();
|
||||
|
||||
@Test
|
||||
public void testGetSessionId() {
|
||||
|
||||
@@ -634,7 +634,7 @@ public class IntroductionIntegrationTest
|
||||
|
||||
// fake a second ACCEPT message from introducee1
|
||||
Message msg = c1.getMessageEncoder()
|
||||
.encodeAcceptMessage(m.getGroupId(), clock.currentTimeMillis(),
|
||||
.encodeAcceptMessage(m.getGroupId(), m.getTimestamp() + 1,
|
||||
m.getMessageId(), m.getSessionId(),
|
||||
m.getEphemeralPublicKey(), m.getAcceptTimestamp(),
|
||||
m.getTransportProperties());
|
||||
@@ -671,7 +671,7 @@ public class IntroductionIntegrationTest
|
||||
|
||||
// fake a second DECLINE message also from introducee1
|
||||
Message msg = c1.getMessageEncoder()
|
||||
.encodeDeclineMessage(m.getGroupId(), clock.currentTimeMillis(),
|
||||
.encodeDeclineMessage(m.getGroupId(), m.getTimestamp() + 1,
|
||||
m.getMessageId(), m.getSessionId());
|
||||
c1.getClientHelper().addLocalMessage(msg, new BdfDictionary(), true);
|
||||
|
||||
@@ -715,7 +715,7 @@ public class IntroductionIntegrationTest
|
||||
|
||||
// fake a second AUTH message also from introducee1
|
||||
Message msg = c1.getMessageEncoder()
|
||||
.encodeAuthMessage(m.getGroupId(), clock.currentTimeMillis(),
|
||||
.encodeAuthMessage(m.getGroupId(), m.getTimestamp() + 1,
|
||||
m.getMessageId(), m.getSessionId(), m.getMac(),
|
||||
m.getSignature());
|
||||
c1.getClientHelper().addLocalMessage(msg, new BdfDictionary(), true);
|
||||
|
||||
@@ -59,6 +59,10 @@ interface IntroductionIntegrationTestComponent
|
||||
|
||||
void inject(IntroductionIntegrationTest init);
|
||||
|
||||
void inject(MessageEncoderParserIntegrationTest init);
|
||||
void inject(SessionEncoderParserIntegrationTest init);
|
||||
void inject(IntroductionCryptoIntegrationTest init);
|
||||
|
||||
MessageEncoder getMessageEncoder();
|
||||
MessageParser getMessageParser();
|
||||
SessionParser getSessionParser();
|
||||
|
||||
@@ -126,8 +126,8 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
previousMsgId.getBytes(), getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
acceptTimestamp, transportProperties);
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).parseAndValidateTransportProperties(
|
||||
transportProperties.getDictionary("transportId"));
|
||||
oneOf(clientHelper).parseAndValidateTransportPropertiesMap(
|
||||
transportProperties);
|
||||
}});
|
||||
expectEncodeMetadata(ACCEPT);
|
||||
BdfMessageContext messageContext =
|
||||
@@ -178,6 +178,14 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsNegativeTimestampForAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(), getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
-1, transportProperties);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsEmptyTransportPropertiesForAccept()
|
||||
throws Exception {
|
||||
@@ -405,9 +413,7 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
|
||||
private void expectEncodeRequestMetadata() {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder)
|
||||
.encodeRequestMetadata(message.getTimestamp(), false, false,
|
||||
false);
|
||||
oneOf(messageEncoder).encodeRequestMetadata(message.getTimestamp());
|
||||
will(returnValue(meta));
|
||||
}});
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.api.system.Clock;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||
import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -72,8 +70,8 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
private final byte[] signature = getRandomBytes(MAX_SIGNATURE_BYTES);
|
||||
|
||||
public MessageEncoderParserIntegrationTest() {
|
||||
BriarIntegrationTestComponent component =
|
||||
DaggerBriarIntegrationTestComponent.builder().build();
|
||||
IntroductionIntegrationTestComponent component =
|
||||
DaggerIntroductionIntegrationTestComponent.builder().build();
|
||||
component.inject(this);
|
||||
|
||||
messageEncoder = new MessageEncoderImpl(clientHelper, messageFactory);
|
||||
@@ -86,13 +84,13 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
@Test
|
||||
public void testRequestMessageMetadata() throws FormatException {
|
||||
BdfDictionary d = messageEncoder
|
||||
.encodeRequestMetadata(timestamp, true, false, false);
|
||||
.encodeRequestMetadata(timestamp);
|
||||
MessageMetadata meta = messageParser.parseMetadata(d);
|
||||
|
||||
assertEquals(REQUEST, meta.getMessageType());
|
||||
assertNull(meta.getSessionId());
|
||||
assertEquals(timestamp, meta.getTimestamp());
|
||||
assertTrue(meta.isLocal());
|
||||
assertFalse(meta.isLocal());
|
||||
assertFalse(meta.isRead());
|
||||
assertFalse(meta.isVisibleInConversation());
|
||||
assertFalse(meta.isAvailableToAnswer());
|
||||
|
||||
@@ -7,13 +7,12 @@ import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.Message;
|
||||
import org.briarproject.bramble.api.sync.MessageFactory;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.bramble.test.BrambleMockTestCase;
|
||||
import org.jmock.Expectations;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.briarproject.bramble.test.TestUtils.getAuthor;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getMessage;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
import static org.briarproject.briar.api.introduction.IntroductionConstants.MAX_REQUEST_MESSAGE_LENGTH;
|
||||
@@ -28,11 +27,9 @@ public class MessageEncoderTest extends BrambleMockTestCase {
|
||||
new MessageEncoderImpl(clientHelper, messageFactory);
|
||||
|
||||
private final GroupId groupId = new GroupId(getRandomId());
|
||||
private final long timestamp = 42L;
|
||||
private final Message message =
|
||||
new Message(new MessageId(getRandomId()), groupId, timestamp,
|
||||
getRandomBytes(48));
|
||||
private final byte[] body = getRandomBytes(42);
|
||||
private final Message message = getMessage(groupId);
|
||||
private final long timestamp = message.getTimestamp();
|
||||
private final byte[] body = message.getRaw();
|
||||
private final Author author = getAuthor();
|
||||
private final BdfList authorList = new BdfList();
|
||||
private final String text = getRandomString(MAX_REQUEST_MESSAGE_LENGTH);
|
||||
|
||||
@@ -14,8 +14,6 @@ import org.briarproject.bramble.api.transport.KeySetId;
|
||||
import org.briarproject.bramble.test.BrambleTestCase;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
import org.briarproject.briar.introduction.IntroducerSession.Introducee;
|
||||
import org.briarproject.briar.test.BriarIntegrationTestComponent;
|
||||
import org.briarproject.briar.test.DaggerBriarIntegrationTestComponent;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -82,8 +80,8 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
private final byte[] remoteMacKey = getRandomBytes(SecretKey.LENGTH);
|
||||
|
||||
public SessionEncoderParserIntegrationTest() {
|
||||
BriarIntegrationTestComponent component =
|
||||
DaggerBriarIntegrationTestComponent.builder().build();
|
||||
IntroductionIntegrationTestComponent component =
|
||||
DaggerIntroductionIntegrationTestComponent.builder().build();
|
||||
component.inject(this);
|
||||
|
||||
sessionEncoder = new SessionEncoderImpl(clientHelper);
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.briarproject.bramble.api.identity.IdentityManager;
|
||||
import org.briarproject.bramble.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.bramble.api.properties.TransportPropertyManager;
|
||||
import org.briarproject.bramble.api.sync.SyncSessionFactory;
|
||||
import org.briarproject.bramble.api.transport.KeyManager;
|
||||
import org.briarproject.bramble.client.ClientModule;
|
||||
import org.briarproject.bramble.contact.ContactModule;
|
||||
import org.briarproject.bramble.crypto.CryptoModule;
|
||||
@@ -37,8 +36,8 @@ import org.briarproject.briar.api.privategroup.invitation.GroupInvitationManager
|
||||
import org.briarproject.briar.blog.BlogModule;
|
||||
import org.briarproject.briar.client.BriarClientModule;
|
||||
import org.briarproject.briar.forum.ForumModule;
|
||||
import org.briarproject.briar.introduction.IntroductionCryptoIntegrationTest;
|
||||
import org.briarproject.briar.introduction.IntroductionModule;
|
||||
import org.briarproject.briar.introduction.IntroductionCryptoImplTest;
|
||||
import org.briarproject.briar.introduction.MessageEncoderParserIntegrationTest;
|
||||
import org.briarproject.briar.introduction.SessionEncoderParserIntegrationTest;
|
||||
import org.briarproject.briar.messaging.MessagingModule;
|
||||
@@ -80,10 +79,6 @@ public interface BriarIntegrationTestComponent {
|
||||
|
||||
void inject(BriarIntegrationTest<BriarIntegrationTestComponent> init);
|
||||
|
||||
void inject(MessageEncoderParserIntegrationTest init);
|
||||
void inject(SessionEncoderParserIntegrationTest init);
|
||||
void inject(IntroductionCryptoImplTest init);
|
||||
|
||||
void inject(BlogModule.EagerSingletons init);
|
||||
|
||||
void inject(ContactModule.EagerSingletons init);
|
||||
@@ -146,8 +141,6 @@ public interface BriarIntegrationTestComponent {
|
||||
|
||||
TransportPropertyManager getTransportPropertyManager();
|
||||
|
||||
KeyManager getKeyManager();
|
||||
|
||||
AuthorFactory getAuthorFactory();
|
||||
|
||||
BlogFactory getBlogFactory();
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.briarproject.briar.test;
|
||||
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.KeyPair;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
import org.briarproject.bramble.api.identity.AuthorFactory;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
@@ -35,4 +38,12 @@ public class BriarTestUtils {
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH));
|
||||
}
|
||||
|
||||
public static LocalAuthor getRealLocalAuthor(
|
||||
CryptoComponent cryptoComponent, AuthorFactory authorFactory) {
|
||||
KeyPair keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||
return authorFactory.createLocalAuthor(getRandomString(5),
|
||||
keyPair.getPublic().getEncoded(),
|
||||
keyPair.getPrivate().getEncoded());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user