UNPKG

@guarani/jose

Version:

Implementation of the RFCs of the JOSE Working Group.

59 lines (58 loc) 2.38 kB
/// <reference types="node" /> import { EcKey } from '../../jwk/algorithms/ec/ec.key'; import { SupportedEllipticCurve } from '../../jwk/algorithms/ec/types/supported-elliptic-curve'; import { JsonWebSignatureAlgorithm } from './jsonwebsignature.algorithm'; import { SupportedJsonWebSignatureAlgorithm } from './types/supported-jsonwebsignature-algorithm'; /** * Implementation of the JSON Web Signature ECDSA Algorithm. */ declare class EcdsaAlgorithm extends JsonWebSignatureAlgorithm { /** * Elliptic Curve used by the JSON Web Signature ECDSA Algorithm. */ protected readonly curve: SupportedEllipticCurve; /** * Instantiates a new JSON Web Signature ECDSA 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 curve Elliptic Curve used by the JSON Web Signature ECDSA Algorithm. */ constructor(hash: string, algorithm: SupportedJsonWebSignatureAlgorithm, curve: SupportedEllipticCurve); /** * 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: EcKey): 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: EcKey): Promise<void>; /** * Checks if the provided JSON Web Key can be used by the JSON Web Signature ECDSA Algorithm. * * @param key JSON Web Key to be checked. * @throws {InvalidJsonWebKeyException} The provided JSON Web Key is invalid. */ protected validateJsonWebKey(key: EcKey): void; } /** * ECDSA using P-256 and SHA-256. */ export declare const ES256: EcdsaAlgorithm; /** * ECDSA using P-384 and SHA-384. */ export declare const ES384: EcdsaAlgorithm; /** * ECDSA using P-521 and SHA-512. */ export declare const ES512: EcdsaAlgorithm; export {};