as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

RsaKeyBuilder

A builder class for creating RSA keys. This class extends AsymmetricKeyBuilder to provide specific functionality for RSA key generation.

Extends

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

AsymmetricAlgorithm

The asymmetric algorithm to use.

Returns

void

Inherited from

AsymmetricKeyBuilder.algorithm


bits

Set Signature

set bits(bits): void

Set the size of the RSA key. Defaults to 4096.

Parameters
bits

number

The size of the key in bits. Common values are 2048, 3072, or 4096.

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

Inherited from

AsymmetricKeyBuilder.exportable


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

KeyPurpose[]

An array of key purposes.

Returns

void

Inherited from

AsymmetricKeyBuilder.purposes

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.

Inherited from

AsymmetricKeyBuilder.buildGenerated


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.

Inherited from

AsymmetricKeyBuilder.buildPrivateFromDer


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.

Inherited from

AsymmetricKeyBuilder.buildPublicFromDer


Last updated: Sep 30, 2025