Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RSAPublicKey

PKCS#1 RSA Public 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

algo

algo: string

exponent

exponent: number

modulus

modulus: string

oid

oid: string

Accessors

keyRaw

  • get keyRaw(): Buffer

Methods

Protected __computed

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

getFingerprint

  • getFingerprint(hashAlgorithm: string, type?: string): Buffer
  • Returns the digest of the PublicKey with given hash algorithm.

    certificate.publicKey.getFingerprint('sha1', 'PublicKey') // => Buffer

    Parameters

    • hashAlgorithm: string

      hash algorithm, such as 'sha256', 'sha1'

    • Default value type: string = "PublicKey"

      'PublicKey' or 'PublicKeyInfo'

    Returns Buffer

toASN1

  • toASN1(): ASN1

toDER

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

    Returns Buffer

toJSON

  • toJSON(): any

toPEM

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

    Returns string

toPublicKeyPEM

  • toPublicKeyPEM(): string
  • Returns an PKCS#8 PEM formatted string of this RSAPublicKey

    Returns string

verify

  • verify(data: Buffer, signature: Buffer, hashAlgorithm: string): boolean
  • Returns true if the provided data and the given signature matched.

    certificate.publicKey.verify(data, signature, 'sha256') // => true or false

    Parameters

    • data: Buffer

      data to verify

    • signature: Buffer

      signature that signed by private key

    • hashAlgorithm: string

      hash algorithm, such as 'sha256', 'sha1'

    Returns boolean

Static addVerifier

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

    PublicKey.addVerifier(getOID('Ed25519'), function (this: PublicKey, data: Buffer, signature: Buffer): boolean {
      return ed25519.detached.verify(data, signature, this.keyRaw)
    })

    Parameters

    • oid: string

      algorithm object identifier

    • fn: Verifier

      Verifier function

    Returns void

Static fromPEM

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

    Parameters

    • pem: Buffer

      PEM formatted buffer

    Returns PublicKey

Static fromPublicKey

Generated using TypeDoc