Class RetryIntegrity

java.lang.Object
io.github.mahmoudimus.quic.crypto.RetryIntegrity

public final class RetryIntegrity extends Object
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 Details

    • TAG_LENGTH

      public static final int TAG_LENGTH
      The 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 packet
      originalDestinationId - the Destination Connection ID of the client's Initial
      retryWithoutTag - 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 packet
      originalDestinationId - the Destination Connection ID of the client's Initial
      packet - the array
      offset - the first byte of the Retry packet
      length - 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 packet
      originalDestinationId - the Destination Connection ID the client sent in its Initial
      retryPacket - the whole Retry packet, tag included, between position and limit; the buffer is not changed
      Returns:
      true if the tag is valid