mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Generate handshake keys when creating local author.
This commit is contained in:
@@ -21,9 +21,7 @@ import java.util.Iterator;
|
||||
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.api.identity.AuthorInfo.Status.NONE;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
import static org.briarproject.briar.api.blog.MessageType.COMMENT;
|
||||
import static org.briarproject.briar.api.blog.MessageType.POST;
|
||||
@@ -51,9 +49,7 @@ public class BlogManagerIntegrationTest
|
||||
author0 = identityManager0.getLocalAuthor();
|
||||
author1 = identityManager1.getLocalAuthor();
|
||||
rssAuthor = c0.getAuthorFactory().createLocalAuthor(
|
||||
getRandomString(MAX_AUTHOR_NAME_LENGTH),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH),
|
||||
getRandomBytes(123));
|
||||
getRandomString(MAX_AUTHOR_NAME_LENGTH), false);
|
||||
|
||||
blogManager0 = c0.getBlogManager();
|
||||
blogManager1 = c1.getBlogManager();
|
||||
|
||||
@@ -58,10 +58,8 @@ public class IntroductionCryptoIntegrationTest extends BrambleTestCase {
|
||||
crypto = new IntroductionCryptoImpl(cryptoComponent, clientHelper);
|
||||
|
||||
introducer = getRealAuthor(authorFactory);
|
||||
LocalAuthor introducee1 =
|
||||
getRealLocalAuthor(cryptoComponent, authorFactory);
|
||||
LocalAuthor introducee2 =
|
||||
getRealLocalAuthor(cryptoComponent, authorFactory);
|
||||
LocalAuthor introducee1 = getRealLocalAuthor(authorFactory);
|
||||
LocalAuthor introducee2 = getRealLocalAuthor(authorFactory);
|
||||
boolean isAlice =
|
||||
crypto.isAlice(introducee1.getId(), introducee2.getId());
|
||||
alice = isAlice ? introducee1 : introducee2;
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.briarproject.briar.messaging;
|
||||
|
||||
import org.briarproject.bramble.api.UniqueId;
|
||||
import org.briarproject.bramble.api.crypto.CryptoComponent;
|
||||
import org.briarproject.bramble.api.crypto.PrivateKey;
|
||||
import org.briarproject.bramble.api.identity.AuthorFactory;
|
||||
import org.briarproject.bramble.api.identity.LocalAuthor;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
@@ -70,12 +69,8 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testForumPostFitsIntoRecord() throws Exception {
|
||||
// Create a maximum-length author
|
||||
int formatVersion = Integer.MAX_VALUE;
|
||||
String authorName = getRandomString(MAX_AUTHOR_NAME_LENGTH);
|
||||
byte[] authorPublic = new byte[MAX_PUBLIC_KEY_LENGTH];
|
||||
PrivateKey privateKey = crypto.generateSignatureKeyPair().getPrivate();
|
||||
LocalAuthor author = authorFactory.createLocalAuthor(formatVersion,
|
||||
authorName, authorPublic, privateKey.getEncoded());
|
||||
LocalAuthor author = authorFactory.createLocalAuthor(authorName, false);
|
||||
// Create a maximum-length forum post
|
||||
GroupId groupId = new GroupId(getRandomId());
|
||||
long timestamp = Long.MAX_VALUE;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -10,6 +8,7 @@ import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.bramble.test.TestUtils.getRandomBytes;
|
||||
import static org.briarproject.bramble.util.StringUtils.getRandomString;
|
||||
@@ -27,23 +26,21 @@ public class BriarTestUtils {
|
||||
}
|
||||
|
||||
public static void assertGroupCount(MessageTracker tracker, GroupId g,
|
||||
long msgCount, long unreadCount) throws DbException {
|
||||
long msgCount, long unreadCount) throws DbException {
|
||||
GroupCount c1 = tracker.getGroupCount(g);
|
||||
assertEquals(msgCount, c1.getMsgCount());
|
||||
assertEquals(unreadCount, c1.getUnreadCount());
|
||||
}
|
||||
|
||||
public static Author getRealAuthor(AuthorFactory authorFactory) {
|
||||
return authorFactory.createAuthor(getRandomString(5),
|
||||
getRandomBytes(MAX_PUBLIC_KEY_LENGTH));
|
||||
String name = getRandomString(MAX_AUTHOR_NAME_LENGTH);
|
||||
byte[] publicKey = getRandomBytes(MAX_PUBLIC_KEY_LENGTH);
|
||||
return authorFactory.createAuthor(name, publicKey);
|
||||
}
|
||||
|
||||
public static LocalAuthor getRealLocalAuthor(
|
||||
CryptoComponent cryptoComponent, AuthorFactory authorFactory) {
|
||||
KeyPair keyPair = cryptoComponent.generateSignatureKeyPair();
|
||||
return authorFactory.createLocalAuthor(getRandomString(5),
|
||||
keyPair.getPublic().getEncoded(),
|
||||
keyPair.getPrivate().getEncoded());
|
||||
public static LocalAuthor getRealLocalAuthor(AuthorFactory authorFactory) {
|
||||
String name = getRandomString(MAX_AUTHOR_NAME_LENGTH);
|
||||
return authorFactory.createLocalAuthor(name, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user