Galois/Counter Mode AEAD

Defined in NIST SP-800-38D.

This implementation only supports 12-byte nonces and 16-byte tags: these parameters are the most secure and most commonly used.

Implements

Constructors

Properties

Methods

Constructors

  • Creates a new GCM instance with the given block cipher.

    Block size of cipher must be equal to 16.

    Parameters

    Returns GCM

Properties

nonceLength: 12 = NONCE_LENGTH

Byte length of nonce that is used with this AEAD.

tagLength: 16 = TAG_LENGTH

Byte length of authentication tag included in the sealed ciphertext. Result of seal() will be longer than plaintext for this number of bytes.

Methods

  • Wipes state from memory. Doesn't wipe the underlying block cipher state.

    Returns this

  • Authenticates sealed ciphertext (which includes authentication tag) and associated data, decrypts ciphertext and returns decrypted plaintext.

    If authentication fails, it returns null.

    If dst is given (it must be of ciphertext length minus tag length), the result will be put into it. Dst and plaintext must not overlap.

    Parameters

    • nonce: Uint8Array
    • sealed: Uint8Array
    • OptionalassociatedData: Uint8Array
    • Optionaldst: Uint8Array

    Returns null | Uint8Array

  • Encrypts and authenticates plaintext, authenticates associated data, and returns sealed ciphertext, which includes authentication tag.

    If dst is given (it must be the size of plaintext + the size of tag length) the result will be put into it. Dst and plaintext must not overlap.

    Parameters

    • nonce: Uint8Array
    • plaintext: Uint8Array
    • OptionalassociatedData: Uint8Array
    • Optionaldst: Uint8Array

    Returns Uint8Array