UNPKG

@unvision/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

59 lines (58 loc) 2.2 kB
/// <reference types="node" /> import { SupportedJsonWebEncryptionContentEncryptionAlgorithm } from './types/supported-jsonwebencryption-content-encryption-algorithm'; import { JsonWebEncryptionContentEncryptionAlgorithm } from './jsonwebencryption-content-encryption.algorithm'; /** * Implementation of the AES-GCM JSON Web Encryption Content Encryption Algorithm. * * @see https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 */ declare class GcmAlgorithm extends JsonWebEncryptionContentEncryptionAlgorithm { /** * Size of the Authentication Tag in bytes. */ private readonly authTagLength; /** * Name of the Cipher Algorithm. */ private readonly cipher; /** * Instantiates a new AES-GCM JSON Web Encryption Content Encryption to Encrypt and Decrypt a Plaintext. * * @param algorithm Name of the JSON Web Encryption Content Encryption Algorithm. */ constructor(algorithm: SupportedJsonWebEncryptionContentEncryptionAlgorithm); /** * Encrypts the provided Plaintext. * * @param plaintext Plaintext to be Cncrypted. * @param aad Additional Authenticated Data. * @param iv Initialization Vector. * @param key Content Encryption Key used to Encrypt the provided Plaintext. * @returns Resulting Ciphertext and Authentication Tag. */ encrypt(plaintext: Buffer, aad: Buffer, iv: Buffer, key: Buffer): Promise<[Buffer, Buffer]>; /** * Decrypts the provided Ciphertext back to its original Plaintext. * * @param ciphertext Ciphertext to be Decrypted. * @param aad Additional Authenticated Data. * @param iv Initialization Vector. * @param tag Authentication Tag. * @param key Content Encryption Key used to Decrypt the provided Ciphertext. * @returns Resulting Plaintext. */ decrypt(ciphertext: Buffer, aad: Buffer, iv: Buffer, tag: Buffer, key: Buffer): Promise<Buffer>; } /** * AES GCM using 128-bit key. */ export declare const A128GCM: GcmAlgorithm; /** * AES GCM using 192-bit key. */ export declare const A192GCM: GcmAlgorithm; /** * AES GCM using 256-bit key. */ export declare const A256GCM: GcmAlgorithm; export {};