@unvision/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
57 lines (56 loc) • 3.06 kB
TypeScript
/// <reference types="node" />
/// <reference types="node" />
import { SupportedJsonWebKeyAlgorithm } from '../../../jwk/algorithms/types/supported-jsonwebkey-algorithm';
import { JsonWebKey } from '../../../jwk/jsonwebkey';
import { SupportedJsonWebEncryptionKeyWrapAlgorithm } from './types/supported-jsonwebencryption-keywrap-algorithm';
import { JsonWebEncryptionContentEncryptionAlgorithm } from '../enc/jsonwebencryption-content-encryption.algorithm';
/**
* Abstract Base Class for the JSON Web Encryption Key Wrap Algorithm.
*
* All JSON Web Encryption Key Wrap Algorithms **MUST** extend this base class and implement its abstract methods.
*
* @see https://www.rfc-editor.org/rfc/rfc7518.html#section-4
*/
export declare abstract class JsonWebEncryptionKeyWrapAlgorithm {
/**
* Name of the JSON Web Encryption Key Wrap Algorithm.
*/
protected readonly algorithm: SupportedJsonWebEncryptionKeyWrapAlgorithm;
/**
* Type of JSON Web Key supported by this JSON Web Encryption Key Wrap Algorithm.
*/
protected readonly keyType: SupportedJsonWebKeyAlgorithm;
/**
* Instantiates a new JSON Web Encryption Key Wrap Algorithm to Wrap and Unwrap Content Encryption Keys.
*
* @param algorithm Name of the JSON Web Encryption Key Wrap Algorithm.
* @param keyType Type of JSON Web Key supported by this JSON Web Encryption Key Wrap Algorithm.
*/
constructor(algorithm: SupportedJsonWebEncryptionKeyWrapAlgorithm, keyType: SupportedJsonWebKeyAlgorithm);
/**
* 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.
* @param header Optional JSON Web Encryption Header containing the additional Parameters.
* @returns Generated Content Encryption Key, Wrapped Content Encryption Key and optional JSON Web Encryption Header.
*/
abstract wrap(enc: JsonWebEncryptionContentEncryptionAlgorithm, key: JsonWebKey, header?: NodeJS.Dict<any>): Promise<[Buffer, Buffer, NodeJS.Dict<any>?]>;
/**
* 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.
* @param header Optional JSON Web Encryption Header containing the additional Parameters.
* @returns Unwrapped Content Encryption Key.
*/
abstract unwrap(enc: JsonWebEncryptionContentEncryptionAlgorithm, key: JsonWebKey, ek: Buffer, header?: NodeJS.Dict<any>): Promise<Buffer>;
/**
* Checks if the provided JSON Web Key can be used by the requesting JSON Web Encryption 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;
}