UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

58 lines (57 loc) 2.24 kB
/// <reference types="node" /> import { OctKey } from '../../jwk/algorithms/oct/oct.key'; import { JsonWebSignatureAlgorithm } from './jsonwebsignature.algorithm'; import { SupportedJsonWebSignatureAlgorithm } from './types/supported-jsonwebsignature-algorithm'; /** * Implementation of the JSON Web Signature HMAC Algorithm. */ declare class HmacAlgorithm extends JsonWebSignatureAlgorithm { /** * 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 the Messages. * * @param hash Hash Algorithm used to Sign and Verify the Messages. * @param algorithm Name of the JSON Web Signature Algorithm. * @param keySize Size of the Secret accepted by the JSON Web Signature HMAC Algorithm. */ constructor(hash: string, algorithm: SupportedJsonWebSignatureAlgorithm, 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: OctKey): 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: OctKey): 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: OctKey): 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 {};