@alessiofrittoli/crypto-signature
Version:
Lightweight TypeScript Signatures library
38 lines (35 loc) • 1.58 kB
text/typescript
import { CoerceToUint8ArrayInput } from '@alessiofrittoli/crypto-buffer/coercion';
import { Sign } from './types.mjs';
import 'crypto';
import '@alessiofrittoli/crypto-algorithm/types';
declare class Signature {
private static Algorithm;
private static HashDigest;
/**
* Sincronously create a signature with the given data.
*
* @param data The data to sign.
* @param key The private key used for HMAC or the PEM private key for RSA, ECDSA and RSASSA-PSS signing algorithms.
* @param algorithm ( Optional ) The Jwk Algorithm name to use. Default: `HS256`.
* @returns The signature Buffer. Throws a new Exception on failure.
*/
static sign(data: CoerceToUint8ArrayInput, key: Sign.PrivateKey, algorithm?: Sign.AlgorithmJwkName): Buffer;
/**
* Sincronously verify a signature.
*
* @param signature The signature buffer.
* @param data The signed data.
* @param key The public key used for HMAC, or RSA, ECDSA and RSASSA-PSS signing verifications.
* @param algorithm ( Optional ) The Jwk Algorithm name to use. Default: `HS256`.
* @returns `true` if signature is valid. Throws a new Exception on failure.
*/
static isValid(signature: CoerceToUint8ArrayInput, data: CoerceToUint8ArrayInput, key: Sign.PublicKey, algorithm?: Sign.AlgorithmJwkName): true;
/**
* Get the Algorithm digest hash name.
*
* @param jwkAlg The Algorithm.
* @returns The corresponding Algorithm digest hash name.
*/
private static jwkAlgToHash;
}
export { Signature };