UNPKG

@unvision/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

73 lines (72 loc) 2.73 kB
/// <reference types="node" /> import { SupportedJsonWebEncryptionContentEncryptionAlgorithm } from './types/supported-jsonwebencryption-content-encryption-algorithm'; import { JsonWebEncryptionContentEncryptionAlgorithm } from './jsonwebencryption-content-encryption.algorithm'; /** * Implementation of the AES-CBC JSON Web Encryption Content Encryption Algorithm. * * @see https://www.rfc-editor.org/rfc/rfc7518.html#section-5.2 */ declare class CbcAlgorithm extends JsonWebEncryptionContentEncryptionAlgorithm { /** * Size of the Encryption Key and the MAC Key in bits. */ private readonly keySize; /** * Name of the Hash Algorithm. */ private readonly hash; /** * Name of the Cipher Algorithm. */ private readonly cipher; /** * Instantiates a new AES-CBC 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 Encrypted. * @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>; /** * Generates the Authentication Tag of the provided Ciphertext. * * @param ciphertext Ciphertext to be Decrypted. * @param iv Initialization Vector. * @param aad Additional Authenticated Data. * @param key Content Encryption Key. * @returns Authentication Tag. */ private getAuthTag; } /** * AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm. */ export declare const A128CBC_HS256: CbcAlgorithm; /** * AES_192_CBC_HMAC_SHA_384 authenticated encryption algorithm. */ export declare const A192CBC_HS384: CbcAlgorithm; /** * AES_256_CBC_HMAC_SHA_512 authenticated encryption algorithm. */ export declare const A256CBC_HS512: CbcAlgorithm; export {};