Forgot to update some constants to reflect the new crypto primitives.

This commit is contained in:
akwizgran
2015-01-14 16:38:15 +00:00
parent 73d4f39726
commit 920c81199e
2 changed files with 7 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
package org.briarproject.api.invitation;
public interface InvitationConstants {
long CONNECTION_TIMEOUT = 30 * 1000; // Milliseconds
@@ -7,8 +8,4 @@ public interface InvitationConstants {
long CONFIRMATION_TIMEOUT = 60 * 1000; // Milliseconds
int CODE_BITS = 19; // Codes must fit into six decimal digits
int HASH_LENGTH = 48; // Bytes
int MAX_PUBLIC_KEY_LENGTH = 97; // Bytes
}

View File

@@ -3,12 +3,12 @@ package org.briarproject.invitation;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
import static org.briarproject.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
import static org.briarproject.api.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.api.AuthorConstants.MAX_SIGNATURE_LENGTH;
import static org.briarproject.api.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
import static org.briarproject.api.TransportPropertyConstants.MAX_PROPERTY_LENGTH;
import static org.briarproject.api.TransportPropertyConstants.MAX_TRANSPORT_ID_LENGTH;
import static org.briarproject.api.invitation.InvitationConstants.CONNECTION_TIMEOUT;
import static org.briarproject.api.invitation.InvitationConstants.HASH_LENGTH;
import java.io.IOException;
import java.security.GeneralSecurityException;
@@ -23,13 +23,13 @@ import java.util.Map.Entry;
import java.util.logging.Logger;
import org.briarproject.api.Author;
import org.briarproject.api.AuthorConstants;
import org.briarproject.api.AuthorFactory;
import org.briarproject.api.ContactId;
import org.briarproject.api.FormatException;
import org.briarproject.api.LocalAuthor;
import org.briarproject.api.TransportId;
import org.briarproject.api.TransportProperties;
import org.briarproject.api.UniqueId;
import org.briarproject.api.crypto.CryptoComponent;
import org.briarproject.api.crypto.KeyManager;
import org.briarproject.api.crypto.KeyPair;
@@ -40,7 +40,6 @@ import org.briarproject.api.crypto.Signature;
import org.briarproject.api.db.DatabaseComponent;
import org.briarproject.api.db.DbException;
import org.briarproject.api.db.NoSuchTransportException;
import org.briarproject.api.invitation.InvitationConstants;
import org.briarproject.api.messaging.Group;
import org.briarproject.api.messaging.GroupFactory;
import org.briarproject.api.plugins.ConnectionManager;
@@ -132,8 +131,8 @@ abstract class Connector extends Thread {
}
protected byte[] receivePublicKeyHash(Reader r) throws IOException {
byte[] b = r.readBytes(HASH_LENGTH);
if(b.length < HASH_LENGTH) throw new FormatException();
byte[] b = r.readBytes(UniqueId.LENGTH);
if(b.length < UniqueId.LENGTH) throw new FormatException();
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received hash");
return b;
}
@@ -147,7 +146,7 @@ abstract class Connector extends Thread {
protected byte[] receivePublicKey(Reader r) throws GeneralSecurityException,
IOException {
byte[] b = r.readBytes(InvitationConstants.MAX_PUBLIC_KEY_LENGTH);
byte[] b = r.readBytes(MAX_PUBLIC_KEY_LENGTH);
keyParser.parsePublicKey(b);
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received key");
return b;
@@ -203,7 +202,7 @@ abstract class Connector extends Thread {
throws GeneralSecurityException, IOException {
// Read the name, public key and signature
String name = r.readString(MAX_AUTHOR_NAME_LENGTH);
byte[] publicKey = r.readBytes(AuthorConstants.MAX_PUBLIC_KEY_LENGTH);
byte[] publicKey = r.readBytes(MAX_PUBLIC_KEY_LENGTH);
byte[] sig = r.readBytes(MAX_SIGNATURE_LENGTH);
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received pseudonym");
// Verify the signature