@guarani/jose
Version:
Implementation of the RFCs of the JOSE Working Group.
128 lines (127 loc) • 4.61 kB
TypeScript
/// <reference types="node" />
import { Optional } from '@guarani/types';
import { KeyObject } from 'crypto';
import { JsonWebKey } from '../../jsonwebkey';
import { JsonWebKeyParams } from '../../jsonwebkey.params';
import { RsaKeyParams } from './rsa-key.params';
import { ExportRsaKeyOptions } from './types/export-rsa-key.options';
import { GenerateRsaKeyOptions } from './types/generate-rsa-key.options';
/**
* Implementation of {@link https://www.rfc-editor.org/rfc/rfc7518.html#section-6.3 RFC 7518 Section 6.3}.
*/
export declare class RsaKey extends JsonWebKey implements RsaKeyParams {
/**
* Type of the JSON Web Key.
*/
readonly kty: 'RSA';
/**
* Modulus.
*/
readonly n: string;
/**
* Public Exponent.
*/
readonly e: string;
/**
* Private Exponent.
*/
readonly d?: Optional<string>;
/**
* First Prime Factor.
*/
readonly p?: Optional<string>;
/**
* Second Prime Factor.
*/
readonly q?: Optional<string>;
/**
* First Factor CRT Exponent.
*/
readonly dp?: Optional<string>;
/**
* Second Factor CRT Exponent.
*/
readonly dq?: Optional<string>;
/**
* First Factor CRT Coefficient.
*/
readonly qi?: Optional<string>;
/**
* Instantiates an RSA JSON Web Key based on the provided Parameters.
*
* @param key Parameters of the RSA JSON Web Key.
* @param options Optional JSON Web Key Parameters.
*/
constructor(key: RsaKeyParams, options?: Optional<JsonWebKeyParams>);
/**
* Generates a new RSA JSON Web Key.
*
* @param options Options for the generation of the RSA JSON Web Key.
* @param params Optional JSON Web Key Parameters.
* @returns Generated RSA JSON Web Key.
*/
static generate(options: GenerateRsaKeyOptions, params?: Optional<JsonWebKeyParams>): Promise<RsaKey>;
/**
* Loads the provided JSON Web Key into a NodeJS Crypto Key.
*
* @param params Parameters of the JSON Web Key.
* @returns NodeJS Crypto Key.
*/
protected loadCryptoKey(params: RsaKeyParams): KeyObject;
/**
* Exports the PKCS#1 RSA Private Key DER Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns DER Encoded PKCS#1 RSA Private Key.
*/
export(options: ExportRsaKeyOptions<'der', 'pkcs1', 'private'>): Buffer;
/**
* Exports the PKCS#1 RSA Private Key PEM Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns PEM Encoded PKCS#1 RSA Private Key.
*/
export(options: ExportRsaKeyOptions<'pem', 'pkcs1', 'private'>): string;
/**
* Exports the PKCS#8 RSA Private Key DER Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns DER Encoded PKCS#8 RSA Private Key.
*/
export(options: ExportRsaKeyOptions<'der', 'pkcs8', 'private'>): Buffer;
/**
* Exports the PKCS#8 RSA Private Key PEM Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns PEM Encoded PKCS#8 RSA Private Key.
*/
export(options: ExportRsaKeyOptions<'pem', 'pkcs8', 'private'>): string;
/**
* Exports the PKCS#1 RSA Public Key DER Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns DER Encoded PKCS#1 RSA Public Key.
*/
export(options: ExportRsaKeyOptions<'der', 'pkcs1', 'public'>): Buffer;
/**
* Exports the PKCS#1 RSA Public Key PEM Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns PEM Encoded PKCS#1 RSA Public Key.
*/
export(options: ExportRsaKeyOptions<'pem', 'pkcs1', 'public'>): string;
/**
* Exports the SPKI RSA Public Key DER Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns DER Encoded SPKI RSA Public Key.
*/
export(options: ExportRsaKeyOptions<'der', 'spki', 'public'>): Buffer;
/**
* Exports the SPKI RSA Public Key PEM Encoding of the RSA JSON Web Key.
*
* @param options Options for exporting the data of the RSA JSON Web Key.
* @returns PEM Encoded SPKI RSA Public Key.
*/
export(options: ExportRsaKeyOptions<'pem', 'spki', 'public'>): string;
}