@unvision/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
64 lines (63 loc) • 2.7 kB
TypeScript
/// <reference types="node" />
import { JsonWebKey } from '../../../jwk/jsonwebkey';
import { SupportedJsonWebEncryptionKeyWrapAlgorithm } from './types/supported-jsonwebencryption-keywrap-algorithm';
import { JsonWebEncryptionContentEncryptionAlgorithm } from '../enc/jsonwebencryption-content-encryption.algorithm';
import { JsonWebEncryptionKeyWrapAlgorithm } from './jsonwebencryption-key-wrap.algorithm';
/**
* Implementation of the JSON Web Encryption AES Key Wrap Algorithm.
*
* @see https://www.rfc-editor.org/rfc/rfc7518.html#section-4.4
*/
declare class AesAlgorithm extends JsonWebEncryptionKeyWrapAlgorithm {
/**
* Size of the Content Encryption Key in bits.
*/
private readonly keySize;
/**
* Name of the Cipher Algorithm.
*/
private readonly cipher;
/**
* Instantiates a new JSON Web Encryption AES Key Wrap Algorithm to Wrap and Unwrap Content Encryption Keys.
*
* @param algorithm Name of the JSON Web Encryption Key Wrap Algorithm.
*/
constructor(algorithm: SupportedJsonWebEncryptionKeyWrapAlgorithm);
/**
* Wraps the provided Content Encryption Key using the provide JSON Web Key.
*
* @param enc JSON Web Encryption Content Encryption Algorithm.
* @param key JSON Web Key used to Wrap the provided Content Encryption Key.
* @returns Generated Content Encryption Key, Wrapped Content Encryption Key and optional JSON Web Encryption Header.
*/
wrap(enc: JsonWebEncryptionContentEncryptionAlgorithm, key: JsonWebKey): Promise<[Buffer, Buffer]>;
/**
* Unwraps the provided Encrypted Key using the provided JSON Web Key.
*
* @param enc JSON Web Encrytpion Content Encryption Algorithm.
* @param key JSON Web Key used to Unwrap the Wrapped Content Encryption Key.
* @param ek Wrapped Content Encryption Key.
* @returns Unwrapped Content Encryption Key.
*/
unwrap(enc: JsonWebEncryptionContentEncryptionAlgorithm, key: JsonWebKey, ek: Buffer): Promise<Buffer>;
/**
* Checks if the provided JSON Web Key can be used by the requesting JSON Web Encryption AES Key Wrap Algorithm.
*
* @param key JSON Web Key to be checked.
* @throws {InvalidJsonWebKeyException} The provided JSON Web Key is invalid.
*/
protected validateJsonWebKey(key: JsonWebKey): void;
}
/**
* AES Key Wrap with default initial value using 128-bit key.
*/
export declare const A128KW: AesAlgorithm;
/**
* AES Key Wrap with default initial value using 192-bit key.
*/
export declare const A192KW: AesAlgorithm;
/**
* AES Key Wrap with default initial value using 256-bit key.
*/
export declare const A256KW: AesAlgorithm;
export {};