Skip to main content

PublicKey

Representation of Subject Public Key Info

Extends​

Constructors​

Constructor​

new PublicKey(asn, options?): PublicKey

Creates a new instance from ASN.1

Parameters​

asn​

SubjectPublicKeyInfo

ASN.1 object

options?​

any

Optional ASN.1 parse options (e.g. asn1js.fromBER resource limits)

Returns​

PublicKey

Overrides​

PemData.constructor

Constructor​

new PublicKey(raw, options?): PublicKey

Creates a new instance

Parameters​

raw​

AsnEncodedType

Encoded buffer (DER, PEM, HEX, Base64, Base64Url)

options?​

any

Optional ASN.1 parse options (e.g. asn1js.fromBER resource limits)

Returns​

PublicKey

Overrides​

PemData.constructor

Properties​

algorithm​

algorithm: Algorithm

Gets a key algorithm


asn​

protected readonly asn: SubjectPublicKeyInfo

ASN.1 object

Inherited from​

PemData.asn


tag​

protected readonly tag: string

PEM tag

Overrides​

PemData.tag


NAME​

static NAME: string = "ASN"

Inherited from​

PemData.NAME

Accessors​

parseOptions​

Get Signature​

get protected parseOptions(): any

Gets the ASN.1 parse options the instance was created with

Returns​

any

Inherited from​

PemData.parseOptions


rawData​

Get Signature​

get rawData(): ArrayBuffer

Gets a DER encoded buffer

Returns​

ArrayBuffer

Inherited from​

PemData.rawData

Methods​

equal()​

equal(data): data is PublicKey

Returns true if ASN.1 data is equal to another ASN.1 data, otherwise false

Parameters​

data​

any

Any data

Returns​

data is PublicKey

Inherited from​

PemData.equal


export()​

Call Signature​

export(crypto?): Promise<CryptoKey>

Returns a public CryptoKey

Parameters​
crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<CryptoKey>

Call Signature​

export(algorithm, keyUsages, crypto?): Promise<CryptoKey>

Returns a public CryptoKey with specified parameters

Parameters​
algorithm​

Algorithm

Algorithm | EcKeyImportParams | RsaHashedImportParams

keyUsages​

KeyUsage[]

A list of key usages

crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<CryptoKey>


getKeyIdentifier()​

Call Signature​

getKeyIdentifier(crypto?): Promise<ArrayBuffer>

Returns Subject Key Identifier as specified in RFC5280

Parameters​
crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<ArrayBuffer>

Call Signature​

getKeyIdentifier(algorithm, crypto?): Promise<ArrayBuffer>

Returns Subject Key Identifier for specified algorithm

Parameters​
algorithm​

AlgorithmIdentifier

Hash algorithm

crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<ArrayBuffer>


getTextName()​

protected getTextName(): string

Returns​

string

Inherited from​

PemData.getTextName


getThumbprint()​

Call Signature​

getThumbprint(crypto?): Promise<ArrayBuffer>

Returns a SHA-1 public key thumbprint

Parameters​
crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<ArrayBuffer>

Call Signature​

getThumbprint(algorithm, crypto?): Promise<ArrayBuffer>

Returns a public key thumbprint for specified mechanism

Parameters​
algorithm​

AlgorithmIdentifier

Hash algorithm

crypto?​

Crypto

Crypto provider. Default is from CryptoProvider

Returns​

Promise<ArrayBuffer>


onInit()​

protected onInit(asn): void

Occurs on instance initialization

Parameters​

asn​

SubjectPublicKeyInfo

ASN.1 object

Returns​

void

Overrides​

PemData.onInit


toString()​

Call Signature​

toString(): string

Returns encoded object in PEM format

Returns​

string

Inherited from​

PemData.toString

Call Signature​

toString(format): string

Returns encoded object in selected format

Parameters​
format​

AsnExportType

hex, base64, base64url, pem, asn, text

Returns​

string

Inherited from​

PemData.toString


toTextObject()​

toTextObject(): TextObject

Returns the object in textual representation

Returns​

TextObject

Overrides​

PemData.toTextObject


toTextObjectEmpty()​

protected toTextObjectEmpty(value?): TextObject

Parameters​

value?​

string

Returns​

TextObject

Inherited from​

PemData.toTextObjectEmpty


create()​

static create(data, crypto): Promise<PublicKey>

Creates a new instance from a public key data

Parameters​

data​

PublicKeyType

Public key data

crypto​

Crypto = ...

Crypto provider. Default is from CryptoProvider

Returns​

Promise<PublicKey>


isAsnEncoded()​

static isAsnEncoded(data): data is AsnEncodedType

Parameters​

data​

any

Returns​

data is AsnEncodedType

Inherited from​

PemData.isAsnEncoded


toArrayBuffer()​

static toArrayBuffer(raw): ArrayBuffer

Converts encoded raw to ArrayBuffer. Supported formats are HEX, DER, Base64, Base64Url, PEM

Parameters​

raw​

Encoded data

string | BufferSource

Returns​

ArrayBuffer

Inherited from​

PemData.toArrayBuffer