mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Use PublicKey and PrivateKey everywhere.
This commit is contained in:
@@ -3,6 +3,7 @@ package org.briarproject.briar.forum;
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.api.client.BdfMessageContext;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
@@ -37,9 +38,9 @@ public class ForumPostValidatorTest extends ValidatorTestCase {
|
||||
private final byte[] signature = getRandomBytes(MAX_SIGNATURE_LENGTH);
|
||||
private final Author author = getAuthor();
|
||||
private final String authorName = author.getName();
|
||||
private final byte[] authorPublicKey = author.getPublicKey();
|
||||
private final PublicKey authorPublicKey = author.getPublicKey();
|
||||
private final BdfList authorList = BdfList.of(author.getFormatVersion(),
|
||||
authorName, authorPublicKey);
|
||||
authorName, authorPublicKey.getEncoded());
|
||||
private final BdfList signedWithParent = BdfList.of(groupId, timestamp,
|
||||
parentId.getBytes(), authorList, text);
|
||||
private final BdfList signedWithoutParent = BdfList.of(groupId, timestamp,
|
||||
|
||||
@@ -64,8 +64,8 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
|
||||
crypto.isAlice(introducee1.getId(), introducee2.getId());
|
||||
alice = isAlice ? introducee1 : introducee2;
|
||||
bob = isAlice ? introducee2 : introducee1;
|
||||
aliceEphemeral = crypto.generateKeyPair();
|
||||
bobEphemeral = crypto.generateKeyPair();
|
||||
aliceEphemeral = crypto.generateAgreementKeyPair();
|
||||
bobEphemeral = crypto.generateAgreementKeyPair();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,30 +86,25 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
|
||||
|
||||
@Test
|
||||
public void testDeriveMasterKey() throws Exception {
|
||||
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);
|
||||
SecretKey aliceMasterKey = crypto.deriveMasterKey(
|
||||
aliceEphemeral.getPublic(), aliceEphemeral.getPrivate(),
|
||||
bobEphemeral.getPublic(), true);
|
||||
SecretKey bobMasterKey = crypto.deriveMasterKey(
|
||||
bobEphemeral.getPublic(), bobEphemeral.getPrivate(),
|
||||
aliceEphemeral.getPublic(), 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,
|
||||
Local local = new Local(true, null, -1, aliceEphemeral.getPublic(),
|
||||
aliceEphemeral.getPrivate(), 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(),
|
||||
local, remote);
|
||||
Remote remote = new Remote(false, bob, null, bobEphemeral.getPublic(),
|
||||
bobTransport, bobAcceptTimestamp, null);
|
||||
byte[] aliceMac = crypto.authMac(aliceMacKey, introducer.getId(),
|
||||
alice.getId(), local, remote);
|
||||
|
||||
// verify from Bob's perspective
|
||||
crypto.verifyAuthMac(aliceMac, aliceMacKey, introducer.getId(),
|
||||
@@ -119,16 +114,14 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
|
||||
@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,
|
||||
Local local = new Local(false, null, -1, bobEphemeral.getPublic(),
|
||||
bobEphemeral.getPrivate(), bobTransport,
|
||||
bobAcceptTimestamp, bobMacKey.getBytes());
|
||||
Remote remote = new Remote(true, alice, null,
|
||||
aliceEphemeral.getPublic().getEncoded(), aliceTransport,
|
||||
aliceEphemeral.getPublic(), aliceTransport,
|
||||
aliceAcceptTimestamp, null);
|
||||
byte[] bobMac =
|
||||
crypto.authMac(bobMacKey, introducer.getId(), bob.getId(),
|
||||
local, remote);
|
||||
byte[] bobMac = crypto.authMac(bobMacKey, introducer.getId(),
|
||||
bob.getId(), local, remote);
|
||||
|
||||
// verify from Alice's perspective
|
||||
crypto.verifyAuthMac(bobMac, bobMacKey, introducer.getId(),
|
||||
|
||||
@@ -42,9 +42,8 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestPluginConfigModule.TRANSPORT_ID;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getSecretKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTransportProperties;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTransportPropertiesMap;
|
||||
@@ -1149,8 +1148,7 @@ public class IntroductionIntegrationTest
|
||||
testModifiedResponse(
|
||||
m -> new AcceptMessage(m.getMessageId(), m.getGroupId(),
|
||||
m.getTimestamp(), m.getPreviousMessageId(),
|
||||
m.getSessionId(),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
m.getSessionId(), getAgreementPublicKey(),
|
||||
m.getAcceptTimestamp(), m.getTransportProperties())
|
||||
);
|
||||
}
|
||||
@@ -1216,8 +1214,8 @@ public class IntroductionIntegrationTest
|
||||
@ParametersNotNullByDefault
|
||||
private abstract class IntroductionListener implements EventListener {
|
||||
|
||||
protected volatile boolean aborted = false;
|
||||
protected volatile Event latestEvent;
|
||||
volatile boolean aborted = false;
|
||||
volatile Event latestEvent;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
IntroductionResponse getResponse() {
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.briar.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.BdfMessageContext;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.BdfEntry;
|
||||
import org.briarproject.bramble.api.data.BdfList;
|
||||
@@ -14,8 +15,9 @@ import org.junit.Test;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAC_BYTES;
|
||||
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAX_AGREEMENT_PUBLIC_KEY_BYTES;
|
||||
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAX_SIGNATURE_BYTES;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
@@ -40,6 +42,7 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
private final MessageId previousMsgId = new MessageId(getRandomId());
|
||||
private final String text = getRandomString(MAX_INTRODUCTION_TEXT_LENGTH);
|
||||
private final BdfDictionary meta = new BdfDictionary();
|
||||
private final PublicKey ephemeralPublicKey = getAgreementPublicKey();
|
||||
private final long acceptTimestamp = 42;
|
||||
private final BdfDictionary transportProperties = BdfDictionary.of(
|
||||
new BdfEntry("transportId", new BdfDictionary())
|
||||
@@ -123,8 +126,9 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
@Test
|
||||
public void testAcceptsAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(), getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
acceptTimestamp, transportProperties);
|
||||
expectParsePublicKey();
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).parseAndValidateTransportPropertiesMap(
|
||||
transportProperties);
|
||||
@@ -139,32 +143,31 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsTooShortBodyForAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH), acceptTimestamp);
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
acceptTimestamp);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsTooLongBodyForAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(), getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
acceptTimestamp, transportProperties, null);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsInvalidSessionIdForAccept() throws Exception {
|
||||
BdfList body =
|
||||
BdfList.of(ACCEPT.getValue(), null, previousMsgId.getBytes(),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH), acceptTimestamp,
|
||||
transportProperties);
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), null,
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
acceptTimestamp, transportProperties);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsInvalidPreviousMsgIdForAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(), 1,
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH), acceptTimestamp,
|
||||
ephemeralPublicKey.getEncoded(), acceptTimestamp,
|
||||
transportProperties);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
@@ -173,16 +176,17 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
public void testRejectsTooLongPublicKeyForAccept() throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH + 1), acceptTimestamp,
|
||||
transportProperties);
|
||||
getRandomBytes(MAX_AGREEMENT_PUBLIC_KEY_BYTES + 1),
|
||||
acceptTimestamp, transportProperties);
|
||||
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),
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
-1, transportProperties);
|
||||
expectParsePublicKey();
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -190,9 +194,9 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
public void testRejectsEmptyTransportPropertiesForAccept()
|
||||
throws Exception {
|
||||
BdfList body = BdfList.of(ACCEPT.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH + 1), acceptTimestamp,
|
||||
new BdfDictionary());
|
||||
previousMsgId.getBytes(), ephemeralPublicKey.getEncoded(),
|
||||
acceptTimestamp, new BdfDictionary());
|
||||
expectParsePublicKey();
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -271,8 +275,7 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsInvalidPreviousMsgIdForAuth() throws Exception {
|
||||
BdfList body = BdfList.of(AUTH.getValue(), sessionId.getBytes(),
|
||||
1, getRandomBytes(MAC_BYTES),
|
||||
signature);
|
||||
1, getRandomBytes(MAC_BYTES), signature);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -294,8 +297,8 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsTooLongMacForAuth() throws Exception {
|
||||
BdfList body = BdfList.of(AUTH.getValue(), sessionId.getBytes(),
|
||||
previousMsgId.getBytes(),
|
||||
getRandomBytes(MAC_BYTES + 1), signature);
|
||||
previousMsgId.getBytes(), getRandomBytes(MAC_BYTES + 1),
|
||||
signature);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -360,9 +363,8 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsInvalidSessionIdForActivate() throws Exception {
|
||||
BdfList body =
|
||||
BdfList.of(ACTIVATE.getValue(), null, previousMsgId.getBytes(),
|
||||
mac);
|
||||
BdfList body = BdfList.of(ACTIVATE.getValue(), null,
|
||||
previousMsgId.getBytes(), mac);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -375,9 +377,8 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
|
||||
@Test(expected = FormatException.class)
|
||||
public void testRejectsPreviousMsgIdNullForActivate() throws Exception {
|
||||
BdfList body =
|
||||
BdfList.of(ACTIVATE.getValue(), sessionId.getBytes(), null,
|
||||
mac);
|
||||
BdfList body = BdfList.of(ACTIVATE.getValue(), sessionId.getBytes(),
|
||||
null, mac);
|
||||
validator.validateMessage(message, group, body);
|
||||
}
|
||||
|
||||
@@ -434,6 +435,13 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
// Introduction Helper Methods
|
||||
//
|
||||
|
||||
private void expectParsePublicKey() throws Exception {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(clientHelper).parseAndValidateAgreementPublicKey(
|
||||
ephemeralPublicKey.getEncoded());
|
||||
will(returnValue(ephemeralPublicKey));
|
||||
}});
|
||||
}
|
||||
private void expectEncodeRequestMetadata() {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder).encodeRequestMetadata(message.getTimestamp());
|
||||
@@ -443,9 +451,8 @@ public class IntroductionValidatorTest extends ValidatorTestCase {
|
||||
|
||||
private void expectEncodeMetadata(MessageType type) {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(messageEncoder)
|
||||
.encodeMetadata(type, sessionId, message.getTimestamp(),
|
||||
false, false, false);
|
||||
oneOf(messageEncoder).encodeMetadata(type, sessionId,
|
||||
message.getTimestamp(), false, false, false);
|
||||
will(returnValue(meta));
|
||||
}});
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.briar.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.data.MetadataEncoder;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
@@ -24,7 +25,7 @@ import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAC_BYTES;
|
||||
import static org.briarproject.bramble.api.crypto.CryptoConstants.MAX_SIGNATURE_BYTES;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getGroup;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
@@ -66,8 +67,7 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
private final MessageId previousMsgId = new MessageId(getRandomId());
|
||||
private final Author author;
|
||||
private final String text = getRandomString(MAX_INTRODUCTION_TEXT_LENGTH);
|
||||
private final byte[] ephemeralPublicKey =
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
private final PublicKey ephemeralPublicKey = getAgreementPublicKey();
|
||||
private final byte[] mac = getRandomBytes(MAC_BYTES);
|
||||
private final byte[] signature = getRandomBytes(MAX_SIGNATURE_BYTES);
|
||||
|
||||
@@ -173,7 +173,8 @@ public class MessageEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
assertEquals(m.getTimestamp(), am.getTimestamp());
|
||||
assertEquals(previousMsgId, am.getPreviousMessageId());
|
||||
assertEquals(sessionId, am.getSessionId());
|
||||
assertArrayEquals(ephemeralPublicKey, am.getEphemeralPublicKey());
|
||||
assertArrayEquals(ephemeralPublicKey.getEncoded(),
|
||||
am.getEphemeralPublicKey().getEncoded());
|
||||
assertEquals(acceptTimestamp, am.getAcceptTimestamp());
|
||||
assertEquals(transportProperties, am.getTransportProperties());
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.briarproject.briar.introduction;
|
||||
|
||||
import org.briarproject.bramble.api.FormatException;
|
||||
import org.briarproject.bramble.api.client.ClientHelper;
|
||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
||||
import org.briarproject.bramble.api.crypto.PublicKey;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
import org.briarproject.bramble.api.data.BdfDictionary;
|
||||
import org.briarproject.bramble.api.identity.Author;
|
||||
@@ -21,7 +23,8 @@ import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPrivateKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getAgreementPublicKey;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomId;
|
||||
import static org.briarproject.bramble.test.TestUtils.getTransportId;
|
||||
@@ -37,6 +40,7 @@ import static org.briarproject.briar.test.BriarTestUtils.getRealAuthor;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -64,13 +68,10 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
private final MessageId lastRemoteMessageId2 = new MessageId(getRandomId());
|
||||
private final Author author1;
|
||||
private final Author author2;
|
||||
private final byte[] ephemeralPublicKey =
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
private final byte[] ephemeralPrivateKey =
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
private final PublicKey ephemeralPublicKey = getAgreementPublicKey();
|
||||
private final PrivateKey ephemeralPrivateKey = getAgreementPrivateKey();
|
||||
private final byte[] masterKey = getRandomBytes(SecretKey.LENGTH);
|
||||
private final byte[] remoteEphemeralPublicKey =
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
private final PublicKey remoteEphemeralPublicKey = getAgreementPublicKey();
|
||||
private final Map<TransportId, TransportProperties> transportProperties =
|
||||
getTransportPropertiesMap(3);
|
||||
private final Map<TransportId, TransportProperties>
|
||||
@@ -193,13 +194,22 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
assertEquals(localTimestamp, s1.getLocal().lastMessageTimestamp);
|
||||
assertEquals(s1.getLocal().lastMessageTimestamp,
|
||||
s2.getLocal().lastMessageTimestamp);
|
||||
assertArrayEquals(ephemeralPublicKey, s1.getLocal().ephemeralPublicKey);
|
||||
assertArrayEquals(s1.getLocal().ephemeralPublicKey,
|
||||
s2.getLocal().ephemeralPublicKey);
|
||||
assertArrayEquals(ephemeralPrivateKey,
|
||||
s1.getLocal().ephemeralPrivateKey);
|
||||
assertArrayEquals(s1.getLocal().ephemeralPrivateKey,
|
||||
s2.getLocal().ephemeralPrivateKey);
|
||||
PublicKey s1LocalEphemeralPub = s1.getLocal().ephemeralPublicKey;
|
||||
PublicKey s2LocalEphemeralPub = s2.getLocal().ephemeralPublicKey;
|
||||
assertNotNull(s1LocalEphemeralPub);
|
||||
assertNotNull(s2LocalEphemeralPub);
|
||||
assertArrayEquals(ephemeralPublicKey.getEncoded(),
|
||||
s1LocalEphemeralPub.getEncoded());
|
||||
assertArrayEquals(s1LocalEphemeralPub.getEncoded(),
|
||||
s2LocalEphemeralPub.getEncoded());
|
||||
PrivateKey s1LocalEphemeralPriv = s1.getLocal().ephemeralPrivateKey;
|
||||
PrivateKey s2LocalEphemeralPriv = s2.getLocal().ephemeralPrivateKey;
|
||||
assertNotNull(s1LocalEphemeralPriv);
|
||||
assertNotNull(s2LocalEphemeralPriv);
|
||||
assertArrayEquals(ephemeralPrivateKey.getEncoded(),
|
||||
s1LocalEphemeralPriv.getEncoded());
|
||||
assertArrayEquals(s1LocalEphemeralPriv.getEncoded(),
|
||||
s2LocalEphemeralPriv.getEncoded());
|
||||
assertEquals(transportProperties, s1.getLocal().transportProperties);
|
||||
assertEquals(s1.getLocal().transportProperties,
|
||||
s2.getLocal().transportProperties);
|
||||
@@ -217,10 +227,14 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
assertEquals(lastRemoteMessageId, s1.getRemote().lastMessageId);
|
||||
assertEquals(s1.getRemote().lastMessageId,
|
||||
s2.getRemote().lastMessageId);
|
||||
assertArrayEquals(remoteEphemeralPublicKey,
|
||||
s1.getRemote().ephemeralPublicKey);
|
||||
assertArrayEquals(s1.getRemote().ephemeralPublicKey,
|
||||
s2.getRemote().ephemeralPublicKey);
|
||||
PublicKey s1RemoteEphemeralPub = s1.getRemote().ephemeralPublicKey;
|
||||
PublicKey s2RemoteEphemeralPub = s2.getRemote().ephemeralPublicKey;
|
||||
assertNotNull(s1RemoteEphemeralPub);
|
||||
assertNotNull(s2RemoteEphemeralPub);
|
||||
assertArrayEquals(remoteEphemeralPublicKey.getEncoded(),
|
||||
s1RemoteEphemeralPub.getEncoded());
|
||||
assertArrayEquals(s1RemoteEphemeralPub.getEncoded(),
|
||||
s2RemoteEphemeralPub.getEncoded());
|
||||
assertEquals(remoteTransportProperties,
|
||||
s1.getRemote().transportProperties);
|
||||
assertEquals(s1.getRemote().transportProperties,
|
||||
@@ -311,7 +325,7 @@ public class SessionEncoderParserIntegrationTest extends BrambleTestCase {
|
||||
ephemeralPublicKey, ephemeralPrivateKey, transportProperties,
|
||||
acceptTimestamp, localMacKey);
|
||||
Remote remote = new Remote(false, author2, lastRemoteMessageId,
|
||||
remoteEphemeralPublicKey, remoteTransportProperties,
|
||||
remoteEphemeralPublicKey, remoteTransportProperties,
|
||||
remoteAcceptTimestamp, remoteMacKey);
|
||||
return new IntroduceeSession(sessionId, LOCAL_ACCEPTED,
|
||||
requestTimestamp, groupId1, author1, local, remote,
|
||||
|
||||
@@ -29,6 +29,7 @@ import static org.briarproject.briar.api.privategroup.Visibility.INVISIBLE;
|
||||
import static org.briarproject.briar.api.privategroup.Visibility.REVEALED_BY_CONTACT;
|
||||
import static org.briarproject.briar.api.privategroup.Visibility.REVEALED_BY_US;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
@@ -164,7 +165,7 @@ public class PrivateGroupIntegrationTest
|
||||
getGroupMember(groupManager2, author1.getId()).getVisibility());
|
||||
|
||||
// 1 reveals the contact relationship to 2
|
||||
assertTrue(contactId2From1 != null);
|
||||
assertNotNull(contactId2From1);
|
||||
groupInvitationManager1.revealRelationship(contactId2From1, groupId0);
|
||||
sync1To2(1, true);
|
||||
sync2To1(1, true);
|
||||
|
||||
@@ -458,8 +458,8 @@ public class GroupInvitationIntegrationTest
|
||||
sync1To0(1, true);
|
||||
}
|
||||
|
||||
private void sendInvitation(long timestamp, @Nullable String text) throws
|
||||
DbException {
|
||||
private void sendInvitation(long timestamp, @Nullable String text)
|
||||
throws DbException {
|
||||
byte[] signature = groupInvitationFactory.signInvitation(contact1From0,
|
||||
privateGroup0.getId(), timestamp, author0.getPrivateKey());
|
||||
groupInvitationManager0
|
||||
|
||||
Reference in New Issue
Block a user