The AesGcmParams interface defines the algorithm-specific parameters that should be passed into the encrypt() and decrypt() methods when using the AES-GCM algorithm.

interface AesGcmParams {
    additionalData?: Uint8Array;
    iv: Uint8Array;
    tagLength?: 96 | 104 | 112 | 120 | 128;
}

Properties

additionalData?: Uint8Array

The additionalData property is used for authentication alongside encrypted data but isn't encrypted itself. It must match in both encryption and decryption; a mismatch will cause decryption to fail. This feature allows for the authentication of data without encrypting it.

The additionalData property is optional and omitting it does not compromise encryption security.

iv: Uint8Array

The initialization vector (IV) must be unique for every encryption operation carried out with a given key. The IV need not be secret, but it must be unpredictable: that is, the IV must not be reused with the same key. The IV must be 12 bytes (96 bits) in length in accordance with the AES-GCM specification recommendedation to promote interoperability and efficiency.

Note: It is OK to transmit the IV in the clear with the encrypted message.

tagLength?: 96 | 104 | 112 | 120 | 128

This property determines the size in bits of the authentication tag generated in the encryption operation and used for authentication in the corresponding decryption. In accordance with the AES-GCM specification, the tag length must be 96, 104, 112, 120 or 128.

The tagLength property is optional and defaults to 128 bits if omitted.