Implement stream header for BTPv2. #111

This commit is contained in:
akwizgran
2015-12-14 13:29:28 +00:00
parent 766179ac97
commit f2efe7f2ea
9 changed files with 591 additions and 233 deletions

View File

@@ -1,25 +1,35 @@
package org.briarproject.api.transport;
import org.briarproject.api.crypto.SecretKey;
public interface TransportConstants {
/** The length of the pseudo-random tag in bytes. */
int TAG_LENGTH = 16;
/** The maximum length of a frame in bytes, including the header and MAC. */
int MAX_FRAME_LENGTH = 1024;
/** The length of the stream header IV in bytes. */
int STREAM_HEADER_IV_LENGTH = 12;
/** The length of the message authentication code (MAC) in bytes. */
int MAC_LENGTH = 16;
/** The length of the stream header in bytes. */
int STREAM_HEADER_LENGTH = STREAM_HEADER_IV_LENGTH + SecretKey.LENGTH
+ MAC_LENGTH;
/** The length of the frame initalisation vector (IV) in bytes. */
int FRAME_IV_LENGTH = 12;
/** The length of the frame header in bytes. */
int HEADER_LENGTH = 4 + MAC_LENGTH;
int FRAME_HEADER_LENGTH = 4 + MAC_LENGTH;
/** The maximum length of a frame in bytes, including the header and MAC. */
int MAX_FRAME_LENGTH = 1024;
/** The maximum total length of the frame payload and padding in bytes. */
int MAX_PAYLOAD_LENGTH = MAX_FRAME_LENGTH - HEADER_LENGTH - MAC_LENGTH;
/** The length of the initalisation vector (IV) in bytes. */
int IV_LENGTH = 12;
int MAX_PAYLOAD_LENGTH = MAX_FRAME_LENGTH - FRAME_HEADER_LENGTH
- MAC_LENGTH;
/**
* The minimum stream length in bytes that all transport plugins must