Class PrivateHeader
java.lang.Object
org.drasyl.handler.remote.protocol.PrivateHeader
This class models the private header of a drasyl protocol message. If the
PublicHeader.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
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract UnsignedShort
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 Details
-
LENGTH
public static final int LENGTH- See Also:
-
ARMED_LENGTH
public static final int ARMED_LENGTH- See Also:
-
-
Constructor Details
-
PrivateHeader
public PrivateHeader()
-
-
Method Details
-
getType
- Returns:
- the message type
-
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
-
of
public static PrivateHeader of(io.netty.buffer.ByteBuf byteBuf) throws InvalidMessageFormatException - Throws:
InvalidMessageFormatException
-
of
-