@unvision/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
74 lines (73 loc) • 3.02 kB
TypeScript
/// <reference types="node" />
/// <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-GCM Key Wrap Algorithm.
*
* @see https://www.rfc-editor.org/rfc/rfc7518.html#section-4.7
*/
declare class GcmAlgorithm extends JsonWebEncryptionKeyWrapAlgorithm {
/**
* Size of the Initialization Vector in bits.
*/
private readonly ivSize;
/**
* Size of the Authentication Tag in bytes.
*/
private readonly authTagLength;
/**
* 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-GCM 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 Wrapped Content Encryption Key and optional additional JSON Web Encryption Header Parameters.
*/
wrap(enc: JsonWebEncryptionContentEncryptionAlgorithm, key: JsonWebKey): Promise<[Buffer, Buffer, NodeJS.Dict<any>]>;
/**
* Unwraps the provided Encrypted Key using the provided JSON Web Key.
*
* @param enc JSON Web Encryption Content Encryption Algorithm.
* @param key JSON Web Key used to Unwrap the Wrapped Content Encryption Key.
* @param ek Wrapped Content Encryption Key.
* @param header JSON Web Encryption Header containing the additional Parameters.
* @returns Unwrapped Content Encryption Key.
*/
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 AES-GCM 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;
}
/**
* Key wrapping with AES GCM using 128-bit key.
*/
export declare const A128GCMKW: GcmAlgorithm;
/**
* Key wrapping with AES GCM using 192-bit key.
*/
export declare const A192GCMKW: GcmAlgorithm;
/**
* Key wrapping with AES GCM using 256-bit key.
*/
export declare const A256GCMKW: GcmAlgorithm;
export {};