Options
All
  • Public
  • Public/Protected
  • All
Menu

Class GCM

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.

Hierarchy

  • GCM

Implements

  • AEAD

Index

Constructors

Properties

Methods

Constructors

constructor

  • new GCM(cipher: BlockCipher): GCM
  • Creates a new GCM instance with the given block cipher.

    Block size of cipher must be equal to 16.

    Parameters

    • cipher: BlockCipher

    Returns GCM

Properties

nonceLength

nonceLength: 12 = NONCE_LENGTH

tagLength

tagLength: 16 = TAG_LENGTH

Methods

clean

  • clean(): this

open

  • open(nonce: Uint8Array, sealed: Uint8Array, associatedData?: Uint8Array, dst?: Uint8Array): Uint8Array | null
  • 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
    • Optional associatedData: Uint8Array
    • Optional dst: Uint8Array

    Returns Uint8Array | null

seal

  • seal(nonce: Uint8Array, plaintext: Uint8Array, associatedData?: Uint8Array, dst?: Uint8Array): 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
    • Optional associatedData: Uint8Array
    • Optional dst: Uint8Array

    Returns Uint8Array

Generated using TypeDoc