UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

58 lines (57 loc) 2.3 kB
/// <reference types="node" /> import { JsonWebEncryptionContentEncryptionAlgorithm } from './jsonwebencryption-contentencryption.algorithm'; import { AuthenticatedEncryption } from './types/authenticated-encryption'; import { SupportedJsonWebEncryptionContentEncryptionAlgorithm } from './types/supported-jsonwebencryption-contentencryption-algorithm'; /** * Implementation of the AES-GCM JSON Web Encryption Content Encryption Algorithm. */ declare class AESGCMContentEncryptionAlgorithm extends JsonWebEncryptionContentEncryptionAlgorithm { /** * Size of the Authentication Tag in bytes. */ private readonly authTagLength; /** * Name of the Cipher Algorithm. */ private readonly cipherAlgorithm; /** * 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<AuthenticatedEncryption>; /** * 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: AESGCMContentEncryptionAlgorithm; /** * AES GCM using 192-bit key. */ export declare const A192GCM: AESGCMContentEncryptionAlgorithm; /** * AES GCM using 256-bit key. */ export declare const A256GCM: AESGCMContentEncryptionAlgorithm; export {};