Skip to content
Snippets Groups Projects
Commit e8b89f25 authored by akwizgran's avatar akwizgran
Browse files

Distinguish between max length of invitation keys and identity keys.

parent a8782937
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,6 @@ package net.sf.briar.invitation; ...@@ -3,7 +3,6 @@ package net.sf.briar.invitation;
import static java.util.logging.Level.INFO; import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING; import static java.util.logging.Level.WARNING;
import static net.sf.briar.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH; import static net.sf.briar.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
import static net.sf.briar.api.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static net.sf.briar.api.AuthorConstants.MAX_SIGNATURE_LENGTH; import static net.sf.briar.api.AuthorConstants.MAX_SIGNATURE_LENGTH;
import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT; import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTY_LENGTH; import static net.sf.briar.api.TransportPropertyConstants.MAX_PROPERTY_LENGTH;
...@@ -23,6 +22,7 @@ import java.util.Map.Entry; ...@@ -23,6 +22,7 @@ import java.util.Map.Entry;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.sf.briar.api.Author; import net.sf.briar.api.Author;
import net.sf.briar.api.AuthorConstants;
import net.sf.briar.api.AuthorFactory; import net.sf.briar.api.AuthorFactory;
import net.sf.briar.api.ContactId; import net.sf.briar.api.ContactId;
import net.sf.briar.api.FormatException; import net.sf.briar.api.FormatException;
...@@ -41,6 +41,7 @@ import net.sf.briar.api.crypto.Signature; ...@@ -41,6 +41,7 @@ import net.sf.briar.api.crypto.Signature;
import net.sf.briar.api.db.DatabaseComponent; import net.sf.briar.api.db.DatabaseComponent;
import net.sf.briar.api.db.DbException; import net.sf.briar.api.db.DbException;
import net.sf.briar.api.db.NoSuchTransportException; import net.sf.briar.api.db.NoSuchTransportException;
import net.sf.briar.api.invitation.InvitationConstants;
import net.sf.briar.api.messaging.Group; import net.sf.briar.api.messaging.Group;
import net.sf.briar.api.messaging.GroupFactory; import net.sf.briar.api.messaging.GroupFactory;
import net.sf.briar.api.plugins.duplex.DuplexPlugin; import net.sf.briar.api.plugins.duplex.DuplexPlugin;
...@@ -136,14 +137,15 @@ abstract class Connector extends Thread { ...@@ -136,14 +137,15 @@ abstract class Connector extends Thread {
} }
protected void sendPublicKey(Writer w) throws IOException { protected void sendPublicKey(Writer w) throws IOException {
w.writeBytes(keyPair.getPublic().getEncoded()); byte[] key = keyPair.getPublic().getEncoded();
w.writeBytes(key);
w.flush(); w.flush();
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " sent key"); if(LOG.isLoggable(INFO)) LOG.info(pluginName + " sent key");
} }
protected byte[] receivePublicKey(Reader r) throws GeneralSecurityException, protected byte[] receivePublicKey(Reader r) throws GeneralSecurityException,
IOException { IOException {
byte[] b = r.readBytes(MAX_PUBLIC_KEY_LENGTH); byte[] b = r.readBytes(InvitationConstants.MAX_PUBLIC_KEY_LENGTH);
keyParser.parsePublicKey(b); keyParser.parsePublicKey(b);
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received key"); if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received key");
return b; return b;
...@@ -199,7 +201,7 @@ abstract class Connector extends Thread { ...@@ -199,7 +201,7 @@ abstract class Connector extends Thread {
throws GeneralSecurityException, IOException { throws GeneralSecurityException, IOException {
// Read the name, public key and signature // Read the name, public key and signature
String name = r.readString(MAX_AUTHOR_NAME_LENGTH); String name = r.readString(MAX_AUTHOR_NAME_LENGTH);
byte[] publicKey = r.readBytes(MAX_PUBLIC_KEY_LENGTH); byte[] publicKey = r.readBytes(AuthorConstants.MAX_PUBLIC_KEY_LENGTH);
byte[] sig = r.readBytes(MAX_SIGNATURE_LENGTH); byte[] sig = r.readBytes(MAX_SIGNATURE_LENGTH);
if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received pseudonym"); if(LOG.isLoggable(INFO)) LOG.info(pluginName + " received pseudonym");
// Verify the signature // Verify the signature
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment