Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
The SubtleCrypto interface of the Web Crypto API provides a number of low-level cryptographic functions.
The interface name includes the term “subtle” to indicate that many of its algorithms have subtle usage requirements, and hence that it must be used carefully in order to provide suitable security guarantees.

Properties

decrypt()

decrypt: (algorithm, key, data) => Promise<ArrayBuffer> The decrypt() method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as “ciphertext”). It returns a Promise which will be fulfilled with the decrypted data (also known as “plaintext”).

Parameters

algorithm
EncryptionAlgorithm An object specifying the algorithm to be used, and any extra parameters as required. The values given for the extra parameters must match those passed into the corresponding encrypt call.
key
CryptoKey A CryptoKey containing the key to be used for decryption. If using RSA-OAEP, this is the privateKey property of the CryptoKeyPair object.
data
BufferSource An ArrayBuffer, a TypedArray, or a DataView containing the data to be decrypted (also known as ciphertext).

Returns

Promise<ArrayBuffer> A Promise that fulfills with an ArrayBuffer containing the plaintext.

Throws

InvalidArgumentError If the algorithm parameters are invalid or missing required fields

Throws

NotSupportedError If the algorithm is not supported or parameters have unsupported values

deriveBits()

deriveBits: (algorithm, baseKey, length) => Promise<ArrayBuffer> The deriveBits() method of the SubtleCrypto interface can be used to derive an array of bits from a base key. It takes as its arguments the base key, the derivation algorithm to use, and the length of the bits to derive. It returns a Promise which will be fulfilled with an ArrayBuffer containing the derived bits.

Parameters

algorithm
DerivationAlgorithm An object defining the derivation algorithm to use.
baseKey
CryptoKey A CryptoKey representing the input to the derivation algorithm. If algorithm is ECDH, this will be the ECDH private key. Otherwise it will be the initial key material for the derivation function: for example, for PBKDF2 it might be a password, imported as a CryptoKey using SubtleCrypto.importKey.
length
number A number representing the number of bits to derive. This number should be a multiple of 8.

Returns

Promise<ArrayBuffer> A Promise that fulfills with an ArrayBuffer containing the derived bits.

Throws

NotSupportedError If the specified derivation algorithm is not supported.

Throws

InvalidArgumentError If the algorithm parameters are invalid.
Last modified on October 2, 2025