AsymmetricKeyBuilder
A builder class for creating and importing asymmetric keys. This class provides methods to configure key properties and generate or import both public and private keys.
Extends
BaseCryptoClass
Extended by
Accessors
algorithm
Set Signature
set algorithm(
algorithm
):void
Set the algorithm to be used for the asymmetric key.
Throws
InvalidArgumentError If the algorithm is not supported.
Parameters
algorithm
The asymmetric algorithm to use.
Returns
void
exportable
Set Signature
set exportable(
exportable
):void
Set whether the key is exportable.
Remarks
A key is NOT exportable unless explicitly set so.
Parameters
exportable
boolean
A boolean value indicating whether the key is exportable.
Returns
void
purposes
Set Signature
set purposes(
purposes
):void
Set the purposes for which the key can be used.
Throws
InvalidArgumentError If any argument is not a valid purpose.
Parameters
purposes
An array of key purposes.
Returns
void
Methods
buildGenerated()
buildGenerated():
Promise
<PrivateKey
>
Build a new private key based on the configured properties.
Returns
Promise
<PrivateKey
>
A promise that resolves to the generated private key.
Throws
InvalidArgumentError If the chosen key size or the key itself is invalid.
buildPrivateFromDer()
buildPrivateFromDer(
der
):Promise
<PrivateKey
>
Import a private key from a DER-encoded blob.
Parameters
der
ArrayBuffer
The DER-encoded private key in PKCS#8 format.
Returns
Promise
<PrivateKey
>
A promise that resolves to the imported private key.
Remarks
The imported key will inherit the properties (algorithm, purposes, exportability) set on this builder.
Throws
InvalidArgumentError If the provided key is invalid.
buildPublicFromDer()
buildPublicFromDer(
der
):Promise
<PublicKey
>
Import a public key from a DER-encoded blob.
Parameters
der
ArrayBuffer
The DER-encoded public key in SubjectPublicKeyInfo format.
Returns
Promise
<PublicKey
>
A promise that resolves to the imported public key.
Remarks
The imported key will inherit the properties (algorithm, purposes) set on this builder.
Throws
InvalidArgumentError If the provided key is invalid.
Last updated: Sep 30, 2025