Message parser and encoder.

This commit is contained in:
akwizgran
2011-07-12 18:41:08 +01:00
parent 2af6f19476
commit 22a67cc0d2
8 changed files with 220 additions and 40 deletions

View File

@@ -0,0 +1,9 @@
package net.sf.briar.api.crypto;
import java.security.GeneralSecurityException;
import java.security.PublicKey;
public interface KeyParser {
PublicKey parsePublicKey(byte[] encodedKey) throws GeneralSecurityException;
}

View File

@@ -4,6 +4,8 @@ import net.sf.briar.api.serial.Raw;
public interface Message extends Raw {
static final int MAX_SIZE = 1024 * 1023; // Not a typo
/** Returns the message's unique identifier. */
MessageId getId();

View File

@@ -0,0 +1,12 @@
package net.sf.briar.api.protocol;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;
public interface MessageEncoder {
Message encodeMessage(MessageId parent, GroupId group, String nick,
KeyPair keyPair, byte[] body) throws IOException,
GeneralSecurityException;
}

View File

@@ -1,10 +1,9 @@
package net.sf.briar.api.protocol;
import java.security.SignatureException;
import net.sf.briar.api.serial.FormatException;
import java.io.IOException;
import java.security.GeneralSecurityException;
public interface MessageParser {
Message parseMessage(byte[] body) throws FormatException, SignatureException;
Message parseMessage(byte[] raw) throws IOException, GeneralSecurityException;
}