Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RSAPrivateKey

PKCS#1 RSA Private Key

Hierarchy

Index

Constructors

constructor

Properties

Protected _finalKey

_finalKey: Buffer

Protected _finalPEM

_finalPEM: string

Protected _keyRaw

_keyRaw: Buffer

Protected _pkcs1

_pkcs1: ASN1

Protected _pkcs8

_pkcs8: ASN1

Protected _publicKeyRaw

_publicKeyRaw: Buffer | null

algo

algo: string

coefficient

coefficient: string

exponent1

exponent1: string

exponent2

exponent2: string

modulus

modulus: string

oid

oid: string

prime1

prime1: string

prime2

prime2: string

privateExponent

privateExponent: string

publicExponent

publicExponent: number

version

version: number

Accessors

keyRaw

  • get keyRaw(): Buffer

publicKeyRaw

  • get publicKeyRaw(): Buffer | null

Methods

Protected __computed

  • __computed(_depth: any, options: any): string

sign

  • sign(data: Buffer, hashAlgorithm: string): Buffer
  • Returns signature for the given data and hash algorithm.

    Parameters

    • data: Buffer
    • hashAlgorithm: string

    Returns Buffer

toASN1

  • toASN1(): ASN1

toDER

  • toDER(): Buffer
  • Returns an PKCS#1 DER formatted buffer of this RSAPrivateKey

    Returns Buffer

toJSON

  • toJSON(): any

toPEM

  • toPEM(): string
  • Returns an PKCS#1 PEM formatted string of this RSAPrivateKey

    Returns string

toPrivateKeyPEM

  • toPrivateKeyPEM(): string
  • Returns an PKCS#8 PEM formatted string of this RSAPrivateKey

    Returns string

Static addSigner

  • addSigner(oid: string, fn: Signer): void
  • Registers an external Signer with object identifier. Built-in verifiers: Ed25519, RSA, others see https://nodejs.org/api/crypto.html#crypto_class_sign

    PrivateKey.addSigner(getOID('Ed25519'), function (this: PrivateKey, data: Buffer): Buffer {
      const key = this.keyRaw
      if (key.length !== 64) {
        throw new Error('Invalid signing key.')
      }
      return Buffer.from(ed25519.detached(data, key))
    })

    Parameters

    • oid: string

      algorithm object identifier

    • fn: Signer

      Verifier function

    Returns void

Static fromPEM

  • Parse an PrivateKey for X.509 certificate from PKCS#8 PEM formatted buffer or PKCS#1 RSA PEM formatted buffer.

    Parameters

    • pem: Buffer

      PEM formatted buffer

    Returns PrivateKey

Static fromPrivateKey

Generated using TypeDoc