/** * rsa.js */ import { HashTypes, JsonWebKeyPair, ModulusLength, RSASignAlgorithm } from './typedef'; /** * Generate RSA public/private key pair. * @param {Number} [modulusLength=2048] - Modulus length in bits, i.e., n. * @param {Uint8Array} [publicExponent=new Uint8Array([0x01, 0x00, 0x01])] - Public exponent, i.e, e. * @return {Promise<{publicKey: JsonWebKey, privateKey: JsonWebKey}>} * @throws {Error} - Throws if UnsupportedEnvironment. */ export declare const generateKey: (modulusLength?: ModulusLength, publicExponent?: Uint8Array) => Promise; /** * RSA signing via RSA-PSS or RSASSA-PKCS1-v1_5. * @param {Uint8Array} msg - Byte array of message to be signed. * @param {JsonWebKey} privateJwk - Private key for signing in JWK format. * @param {String} [hash='SHA-256'] - Name of hash algorithm like 'SHA-256'. * @param {RSASignAlgorithm} [algorithm={name: 'RSA-PSS', saltLength: params.hashes[hash].hashSize}] - Object to specify algorithm parameters. * @return {Promise} - Byte array of raw signature. * @throws {Error} - Throws if UnsupportedEnvironment. */ export declare const sign: (msg: Uint8Array, privateJwk: JsonWebKey, hash?: HashTypes, algorithm?: RSASignAlgorithm) => Promise; /** * Verification of RSA signature via RSA-PSS or RSASSA-PKCS1-v1_5. * @param {Uint8Array} msg - Byte array of message signed. * @param {Uint8Array} signature - Byte array of raw signature. * @param {JsonWebKey} publicJwk - public key for signing in JWK format. * @param {String} [hash='SHA-256'] - Name of hash algorithm like 'SHA-256'. * @param {RSASignAlgorithm} [algorithm={name: 'RSA-PSS', saltLength: params.hashes[hash].hashSize}] - Object to specify algorithm parameters. * @return {Promise} - Result of verification. * @throws {Error} - Throws if InvalidSignatureFormat, or UnsupportedEnvironment. */ export declare const verify: (msg: Uint8Array, signature: Uint8Array, publicJwk: JsonWebKey, hash?: HashTypes, algorithm?: RSASignAlgorithm) => Promise; /** * RSA-OAEP Encryption * @param {Uint8Array} msg - Byte array of message to be encrypted. * @param {JsonWebKey} publicJwk - Public/Private key in JWK format. * @param {String} [hash='SHA-256'] - Name of hash algorithm like 'SHA-256' * @param {Uint8Array} [label=new Uint8Array([])] - RSA-OAEP label. * @return {Promise} - Encrypted message. * @throws {Error} - Throws if UnsupportedEnvironment. */ export declare const encrypt: (msg: Uint8Array, publicJwk: JsonWebKey, hash?: HashTypes, label?: Uint8Array) => Promise; /** * RSA-OAEP Decryption. * @param {Uint8Array} data - Byte array of encrypted message to be decrypted. * @param {JsonWebKey} privateJwk - Private key in JWK format. * @param {String} [hash='SHA-256'] - Name of hash algorithm like 'SHA-256' * @param {Uint8Array} [label=new Uint8Array([])] - RSA-OAEP label. * @return {Promise} - Decrypted message. * @throws {Error} - Throws if UnsupportedEnvironment. */ export declare const decrypt: (data: Uint8Array, privateJwk: JsonWebKey, hash?: HashTypes, label?: Uint8Array) => Promise;