mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Changed to fixed-length frames (mostly untested).
This commit is contained in:
29
api/net/sf/briar/api/crypto/AuthenticatedCipher.java
Normal file
29
api/net/sf/briar/api/crypto/AuthenticatedCipher.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package net.sf.briar.api.crypto;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
/**
|
||||
* A wrapper for a provider-dependent cipher class, since javax.crypto.Cipher
|
||||
* doesn't support additional authenticated data until Java 7.
|
||||
*/
|
||||
public interface AuthenticatedCipher {
|
||||
|
||||
/**
|
||||
* Initializes this cipher with a key, an initialisation vector (IV) and
|
||||
* additional authenticated data (AAD).
|
||||
*/
|
||||
void init(int opmode, Key key, byte[] iv, byte[] aad)
|
||||
throws InvalidKeyException;
|
||||
|
||||
/** Encrypts or decrypts data in a single-part operation. */
|
||||
int doFinal(byte[] input, int inputOff, int len, byte[] output,
|
||||
int outputOff) throws IllegalBlockSizeException,
|
||||
BadPaddingException;
|
||||
|
||||
/** Returns the length of the message authenticated code (MAC) in bytes. */
|
||||
int getMacLength();
|
||||
}
|
||||
@@ -36,13 +36,7 @@ public interface CryptoComponent {
|
||||
|
||||
Cipher getTagCipher();
|
||||
|
||||
Cipher getFrameCipher();
|
||||
|
||||
Cipher getFramePeekingCipher();
|
||||
|
||||
IvEncoder getFrameIvEncoder();
|
||||
|
||||
IvEncoder getFramePeekingIvEncoder();
|
||||
AuthenticatedCipher getFrameCipher();
|
||||
|
||||
Signature getSignature();
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package net.sf.briar.api.crypto;
|
||||
|
||||
public interface IvEncoder {
|
||||
|
||||
byte[] encodeIv(long frameNumber);
|
||||
|
||||
void updateIv(byte[] iv, long frameNumber);
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package net.sf.briar.api.plugins;
|
||||
|
||||
public interface InvitationConstants {
|
||||
|
||||
static final long INVITATION_TIMEOUT = 60 * 1000; // 1 minute
|
||||
long INVITATION_TIMEOUT = 60 * 1000; // 1 minute
|
||||
|
||||
static final int CODE_BITS = 19; // Codes must fit into six decimal digits
|
||||
int CODE_BITS = 19; // Codes must fit into six decimal digits
|
||||
|
||||
static final int MAX_CODE = 1 << CODE_BITS - 1;
|
||||
int MAX_CODE = 1 << CODE_BITS - 1;
|
||||
|
||||
static final int HASH_LENGTH = 48;
|
||||
int HASH_LENGTH = 48;
|
||||
|
||||
static final int MAX_PUBLIC_KEY_LENGTH = 120;
|
||||
int MAX_PUBLIC_KEY_LENGTH = 120;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,18 @@ public interface TransportConstants {
|
||||
static final int TAG_LENGTH = 16;
|
||||
|
||||
/** The maximum length of a frame in bytes, including the header and MAC. */
|
||||
static final int MAX_FRAME_LENGTH = 65536; // 2^16, 64 KiB
|
||||
static final int MAX_FRAME_LENGTH = 32768; // 2^15, 32 KiB
|
||||
|
||||
/** The length of the initalisation vector (IV) in bytes. */
|
||||
static final int IV_LENGTH = 12;
|
||||
|
||||
/** The length of the additional authenticated data (AAD) in bytes. */
|
||||
static final int AAD_LENGTH = 6;
|
||||
|
||||
/** The length of the frame header in bytes. */
|
||||
static final int HEADER_LENGTH = 9;
|
||||
static final int HEADER_LENGTH = 2;
|
||||
|
||||
/** The length of the MAC in bytes. */
|
||||
/** The length of the message authentication code (MAC) in bytes. */
|
||||
static final int MAC_LENGTH = 16;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user