Class PrivateHeader
- java.lang.Object
-
- org.drasyl.handler.remote.protocol.PrivateHeader
-
public abstract class PrivateHeader extends Object
This class models the private header of a drasyl protocol message. If thePublicHeader.getArmed()
flag is set, this header is fully encrypted. The header is structured as follows:- Type: The 1 byte type value. Indicates the message type.
- ArmedLength: The 2 bytes armed length value. Indicates, the length of the encrypted portion of the message without AEAD tag.
- AuthenticationHeader: If ArmedLength value is greater than 0, a 16 bytes long authentication header is used. Otherwise this field is not present (0 bytes long).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PrivateHeader.MessageType
-
Field Summary
Fields Modifier and Type Field Description static int
ARMED_LENGTH
static int
LENGTH
-
Constructor Summary
Constructors Constructor Description PrivateHeader()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract UnsignedShort
getArmedLength()
static UnsignedShort
getArmedLength(io.netty.buffer.ByteBuf byteBuf)
abstract PrivateHeader.MessageType
getType()
static PrivateHeader
of(io.netty.buffer.ByteBuf byteBuf)
static PrivateHeader
of(PrivateHeader.MessageType type, UnsignedShort armedLength)
void
writeTo(io.netty.buffer.ByteBuf byteBuf)
Writes this header to the bufferbyteBuf
.
-
-
-
Field Detail
-
LENGTH
public static final int LENGTH
- See Also:
- Constant Field Values
-
ARMED_LENGTH
public static final int ARMED_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
getType
public abstract PrivateHeader.MessageType getType()
- Returns:
- the message type
-
getArmedLength
public abstract UnsignedShort getArmedLength()
- Returns:
- the armed length
-
writeTo
public void writeTo(io.netty.buffer.ByteBuf byteBuf)
Writes this header to the bufferbyteBuf
.- Parameters:
byteBuf
- writes this header to the given buffer
-
getArmedLength
public static UnsignedShort getArmedLength(io.netty.buffer.ByteBuf byteBuf)
-
of
public static PrivateHeader of(io.netty.buffer.ByteBuf byteBuf) throws InvalidMessageFormatException
- Throws:
InvalidMessageFormatException
-
of
public static PrivateHeader of(PrivateHeader.MessageType type, UnsignedShort armedLength)
-
-