UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

72 lines (71 loc) 2.85 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-CBC JSON Web Encryption Content Encryption Algorithm. */ declare class CBCHS2ContentEncryptionAlgorithm extends JsonWebEncryptionContentEncryptionAlgorithm { /** * Size of the Encryption Key and the MAC Key in bits. */ private readonly keySize; /** * Name of the Hash Algorithm. */ private readonly hashAlgorithm; /** * Name of the Cipher Algorithm. */ private readonly cipherAlgorithm; /** * 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 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>; /** * 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: CBCHS2ContentEncryptionAlgorithm; /** * AES_192_CBC_HMAC_SHA_384 authenticated encryption algorithm. */ export declare const A192CBC_HS384: CBCHS2ContentEncryptionAlgorithm; /** * AES_256_CBC_HMAC_SHA_512 authenticated encryption algorithm. */ export declare const A256CBC_HS512: CBCHS2ContentEncryptionAlgorithm; export {};