Class RetryIntegrity
java.lang.Object
io.github.mahmoudimus.quic.crypto.RetryIntegrity
The Retry Integrity Tag (RFC 9001 section 5.8, RFC 9369 section 3.3.3): AES-128-GCM with a
fixed per-version key and nonce over the Retry pseudo-packet, which is the original Destination
Connection ID (with its length byte) followed by the Retry packet without its tag.
All methods are static and thread-safe; each call makes its own Cipher.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]tag(QuicVersion version, ConnectionId originalDestinationId, byte[] packet, int offset, int length) Computes the tag of a Retry packet held in an array.static byte[]tag(QuicVersion version, ConnectionId originalDestinationId, ByteBuffer retryWithoutTag) Computes the tag of a Retry packet.static booleanverify(QuicVersion version, ConnectionId originalDestinationId, ByteBuffer retryPacket) Checks the tag at the end of a received Retry packet, in constant time.
-
Field Details
-
TAG_LENGTH
public static final int TAG_LENGTHThe tag length in bytes.- See Also:
-
-
Method Details
-
tag
public static byte[] tag(QuicVersion version, ConnectionId originalDestinationId, ByteBuffer retryWithoutTag) Computes the tag of a Retry packet.- Parameters:
version- the version of the Retry packetoriginalDestinationId- the Destination Connection ID of the client's InitialretryWithoutTag- the Retry packet up to its tag, between position and limit; the buffer is not changed- Returns:
- the 16-byte tag
-
tag
public static byte[] tag(QuicVersion version, ConnectionId originalDestinationId, byte[] packet, int offset, int length) Computes the tag of a Retry packet held in an array.- Parameters:
version- the version of the Retry packetoriginalDestinationId- the Destination Connection ID of the client's Initialpacket- the arrayoffset- the first byte of the Retry packetlength- the length of the Retry packet without its tag- Returns:
- the 16-byte tag
-
verify
public static boolean verify(QuicVersion version, ConnectionId originalDestinationId, ByteBuffer retryPacket) Checks the tag at the end of a received Retry packet, in constant time.- Parameters:
version- the version of the Retry packetoriginalDestinationId- the Destination Connection ID the client sent in its InitialretryPacket- the whole Retry packet, tag included, between position and limit; the buffer is not changed- Returns:
- true if the tag is valid
-