@unvision/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
59 lines (58 loc) • 2.05 kB
TypeScript
/// <reference types="node" />
import { JsonWebKey } from '../../jwk/jsonwebkey';
import { JsonWebSignatureAlgorithm } from './jsonwebsignature.algorithm';
/**
* Implementation of the JSON Web Signature HMAC Algorithm.
*/
declare class HmacAlgorithm extends JsonWebSignatureAlgorithm {
/**
* Hash Algorithm used to Sign and Verify Messages.
*/
protected readonly hash: string;
/**
* Size of the Secret accepted by the JSON Web Signature HMAC Algorithm.
*/
protected readonly keySize: number;
/**
* Instantiates a new JSON Web Signature HMAC Algorithm to Sign and Verify Messages.
*
* @param keySize Size of the Secret accepted by the JSON Web Signature HMAC Algorithm.
*/
constructor(keySize: number);
/**
* Signs a Message with the provided JSON Web Key.
*
* @param message Message to be Signed.
* @param key JSON Web Key used to Sign the provided Message.
* @returns Resulting Signature of the provided Message.
*/
sign(message: Buffer, key: JsonWebKey): Promise<Buffer>;
/**
* Checks if the provided Signature matches the provided Message based on the provide JSON Web Key.
*
* @param signature Signature to be matched against the provided Message.
* @param message Message to be matched against the provided Signature.
* @param key JSON Web Key used to verify the Signature and Message.
*/
verify(signature: Buffer, message: Buffer, key: JsonWebKey): Promise<void>;
/**
* Checks if the provided JSON Web Key can be used by the JSON Web Signature HMAC Algorithm.
*
* @param key JSON Web Key to be checked.
* @throws {InvalidJsonWebKeyException} The provided JSON Web Key is invalid.
*/
protected validateJsonWebKey(key: JsonWebKey): void;
}
/**
* HMAC using SHA-256.
*/
export declare const HS256: HmacAlgorithm;
/**
* HMAC using SHA-384.
*/
export declare const HS384: HmacAlgorithm;
/**
* HMAC using SHA-512.
*/
export declare const HS512: HmacAlgorithm;
export {};