Web Crypto API

<!-- YAML changes: - version: v26.10.0 pr-url: https://github.com/nodejs/node/pull/65759 description: Hybrid KEM algorithms are now supported. - version: v25.9.0 pr-url: https://github.com/nodejs/node/pull/62183 description: TurboSHAKE and KangarooTwelve algorithms are now supported. - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59544 description: Argon2 algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59539 description: AES-OCB algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59569 description: ML-KEM algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: SHA-3 algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: SHAKE algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. - version: - v23.5.0 - v22.13.0 - v20.19.3 pr-url: https://github.com/nodejs/node/pull/56142 description: Algorithms Ed25519 and X25519 are now stable. - version: - v20.0.0 - v18.17.0 pr-url: https://github.com/nodejs/node/pull/46067 description: Arguments are now coerced and validated as per their WebIDL definitions like in other Web Crypto API implementations. - version: v19.0.0 pr-url: https://github.com/nodejs/node/pull/44897 description: No longer experimental except for the Ed25519, Ed448, X25519, and X448 algorithms. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/43310 description: Removed proprietary 'node.keyObject' import/export format. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/43310 description: Removed proprietary 'NODE-DSA', 'NODE-DH', and 'NODE-SCRYPT' algorithms. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'Ed25519', 'Ed448', 'X25519', and 'X448' algorithms. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Removed proprietary 'NODE-ED25519' and 'NODE-ED448' algorithms. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Removed proprietary 'NODE-X25519' and 'NODE-X448' named curves from the 'ECDH' algorithm. -->

<!-- introduced_in=v15.0.0 -->

Stability: 2 - Stable

Node.js provides an implementation of the [Web Crypto API][] standard.

Use globalThis.crypto or require('node:crypto').webcrypto to access this module.

const { subtle } = globalThis.crypto;

(async function() {

  const key = await subtle.generateKey({
    name: 'HMAC',
    hash: 'SHA-256',
    length: 256,
  }, true, ['sign', 'verify']);

  const enc = new TextEncoder();
  const message = enc.encode('I love cupcakes');

  const digest = await subtle.sign({
    name: 'HMAC',
  }, key, message);

})();

Modern Algorithms in the Web Cryptography API

Stability: 1.1 - Active development

Node.js provides an implementation of the following features from the Modern Algorithms in the Web Cryptography API WICG proposal:

Algorithms:

  • 'AES-OCB'[^openssl30]
  • 'Argon2d'[^openssl32]
  • 'Argon2i'[^openssl32]
  • 'Argon2id'[^openssl32]
  • 'ChaCha20-Poly1305'
  • 'cSHAKE128'
  • 'cSHAKE256'
  • 'KMAC128'[^openssl30]
  • 'KMAC256'[^openssl30]
  • 'KT128'
  • 'KT256'
  • 'ML-DSA-44'[^openssl35]
  • 'ML-DSA-65'[^openssl35]
  • 'ML-DSA-87'[^openssl35]
  • 'ML-KEM-512'[^openssl35]
  • 'ML-KEM-768'[^openssl35]
  • 'ML-KEM-1024'[^openssl35]
  • 'MLKEM768-P256'[^openssl35]
  • 'MLKEM768-X25519'[^openssl35]
  • 'MLKEM1024-P384'[^openssl35]
  • 'SHA3-256'
  • 'SHA3-384'
  • 'SHA3-512'
  • 'TurboSHAKE128'
  • 'TurboSHAKE256'

Key Formats:

  • 'raw-public'
  • 'raw-secret'
  • 'raw-seed'

Methods:

  • [subtle.decapsulateBits()][]
  • [subtle.decapsulateKey()][]
  • [subtle.encapsulateBits()][]
  • [subtle.encapsulateKey()][]
  • [subtle.getPublicKey()][]
  • [SubtleCrypto.supports()][]

Secure Curves in the Web Cryptography API

Stability: 1.1 - Active development

Node.js provides an implementation of the following features from the Secure Curves in the Web Cryptography API WICG proposal:

Algorithms:

  • 'Ed448'
  • 'X448'

Examples

Generating keys

The {SubtleCrypto} class can be used to generate symmetric (secret) keys or asymmetric key pairs (public key and private key).

AES keys

const { subtle } = globalThis.crypto;

async function generateAesKey(length = 256) {
  const key = await subtle.generateKey({
    name: 'AES-CBC',
    length,
  }, true, ['encrypt', 'decrypt']);

  return key;
}

ECDSA key pairs

const { subtle } = globalThis.crypto;

async function generateEcKey(namedCurve = 'P-521') {
  const {
    publicKey,
    privateKey,
  } = await subtle.generateKey({
    name: 'ECDSA',
    namedCurve,
  }, true, ['sign', 'verify']);

  return { publicKey, privateKey };
}

Ed25519/X25519 key pairs

const { subtle } = globalThis.crypto;

async function generateEd25519Key() {
  return subtle.generateKey({
    name: 'Ed25519',
  }, true, ['sign', 'verify']);
}

async function generateX25519Key() {
  return subtle.generateKey({
    name: 'X25519',
  }, true, ['deriveKey']);
}

HMAC keys

const { subtle } = globalThis.crypto;

async function generateHmacKey(hash = 'SHA-256') {
  const key = await subtle.generateKey({
    name: 'HMAC',
    hash,
  }, true, ['sign', 'verify']);

  return key;
}

RSA key pairs

const { subtle } = globalThis.crypto;
const publicExponent = new Uint8Array([1, 0, 1]);

async function generateRsaKey(modulusLength = 2048, hash = 'SHA-256') {
  const {
    publicKey,
    privateKey,
  } = await subtle.generateKey({
    name: 'RSASSA-PKCS1-v1_5',
    modulusLength,
    publicExponent,
    hash,
  }, true, ['sign', 'verify']);

  return { publicKey, privateKey };
}

Encryption and decryption

const crypto = globalThis.crypto;

async function aesEncrypt(plaintext) {
  const ec = new TextEncoder();
  const key = await generateAesKey();
  const iv = crypto.getRandomValues(new Uint8Array(16));

  const ciphertext = await crypto.subtle.encrypt({
    name: 'AES-CBC',
    iv,
  }, key, ec.encode(plaintext));

  return {
    key,
    iv,
    ciphertext,
  };
}

async function aesDecrypt(ciphertext, key, iv) {
  const dec = new TextDecoder();
  const plaintext = await crypto.subtle.decrypt({
    name: 'AES-CBC',
    iv,
  }, key, ciphertext);

  return dec.decode(plaintext);
}

Exporting and importing keys

const { subtle } = globalThis.crypto;

async function generateAndExportHmacKey(format = 'jwk', hash = 'SHA-512') {
  const key = await subtle.generateKey({
    name: 'HMAC',
    hash,
  }, true, ['sign', 'verify']);

  return subtle.exportKey(format, key);
}

async function importHmacKey(keyData, format = 'jwk', hash = 'SHA-512') {
  const key = await subtle.importKey(format, keyData, {
    name: 'HMAC',
    hash,
  }, true, ['sign', 'verify']);

  return key;
}

Wrapping and unwrapping keys

const { subtle } = globalThis.crypto;

async function generateAndWrapHmacKey(format = 'jwk', hash = 'SHA-512') {
  const [
    key,
    wrappingKey,
  ] = await Promise.all([
    subtle.generateKey({
      name: 'HMAC', hash,
    }, true, ['sign', 'verify']),
    subtle.generateKey({
      name: 'AES-KW',
      length: 256,
    }, true, ['wrapKey', 'unwrapKey']),
  ]);

  const wrappedKey = await subtle.wrapKey(format, key, wrappingKey, 'AES-KW');

  return { wrappedKey, wrappingKey };
}

async function unwrapHmacKey(
  wrappedKey,
  wrappingKey,
  format = 'jwk',
  hash = 'SHA-512') {

  const key = await subtle.unwrapKey(
    format,
    wrappedKey,
    wrappingKey,
    'AES-KW',
    { name: 'HMAC', hash },
    true,
    ['sign', 'verify']);

  return key;
}

Sign and verify

const { subtle } = globalThis.crypto;

async function sign(key, data) {
  const ec = new TextEncoder();
  const signature =
    await subtle.sign('RSASSA-PKCS1-v1_5', key, ec.encode(data));
  return signature;
}

async function verify(key, signature, data) {
  const ec = new TextEncoder();
  const verified =
    await subtle.verify(
      'RSASSA-PKCS1-v1_5',
      key,
      signature,
      ec.encode(data));
  return verified;
}

Deriving bits and keys

const { subtle } = globalThis.crypto;

async function pbkdf2(pass, salt, iterations = 1000, length = 256) {
  const ec = new TextEncoder();
  const key = await subtle.importKey(
    'raw',
    ec.encode(pass),
    'PBKDF2',
    false,
    ['deriveBits']);
  const bits = await subtle.deriveBits({
    name: 'PBKDF2',
    hash: 'SHA-512',
    salt: ec.encode(salt),
    iterations,
  }, key, length);
  return bits;
}

async function pbkdf2Key(pass, salt, iterations = 1000, length = 256) {
  const ec = new TextEncoder();
  const keyMaterial = await subtle.importKey(
    'raw',
    ec.encode(pass),
    'PBKDF2',
    false,
    ['deriveKey']);
  const key = await subtle.deriveKey({
    name: 'PBKDF2',
    hash: 'SHA-512',
    salt: ec.encode(salt),
    iterations,
  }, keyMaterial, {
    name: 'AES-GCM',
    length,
  }, true, ['encrypt', 'decrypt']);
  return key;
}

Digest

const { subtle } = globalThis.crypto;

async function digest(data, algorithm = 'SHA-512') {
  const ec = new TextEncoder();
  const digest = await subtle.digest(algorithm, ec.encode(data));
  return digest;
}

Checking for runtime algorithm support

[SubtleCrypto.supports()][] allows feature detection in Web Crypto API, which can be used to detect whether a given algorithm identifier (including its parameters) is supported for the given operation.

This example derives a key from a password using Argon2, if available, or PBKDF2, otherwise; and then encrypts and decrypts some text with it using AES-OCB, if available, and AES-GCM, otherwise.

const { SubtleCrypto, crypto } = globalThis;

const password = 'correct horse battery staple';
const derivationAlg =
  SubtleCrypto.supports?.('importKey', 'Argon2id') ?
    'Argon2id' :
    'PBKDF2';
const encryptionAlg =
  SubtleCrypto.supports?.('importKey', 'AES-OCB') ?
    'AES-OCB' :
    'AES-GCM';
const passwordKey = await crypto.subtle.importKey(
  derivationAlg === 'Argon2id' ? 'raw-secret' : 'raw',
  new TextEncoder().encode(password),
  derivationAlg,
  false,
  ['deriveKey'],
);
const nonce = crypto.getRandomValues(new Uint8Array(16));
const derivationParams =
  derivationAlg === 'Argon2id' ?
    {
      nonce,
      parallelism: 4,
      memory: 2 ** 21,
      passes: 1,
    } :
    {
      salt: nonce,
      iterations: 100_000,
      hash: 'SHA-256',
    };
const key = await crypto.subtle.deriveKey(
  {
    name: derivationAlg,
    ...derivationParams,
  },
  passwordKey,
  {
    name: encryptionAlg,
    length: 256,
  },
  false,
  ['encrypt', 'decrypt'],
);
const plaintext = 'Hello, world!';
const iv = crypto.getRandomValues(new Uint8Array(12));
const encrypted = await crypto.subtle.encrypt(
  { name: encryptionAlg, iv },
  key,
  new TextEncoder().encode(plaintext),
);
const decrypted = new TextDecoder().decode(await crypto.subtle.decrypt(
  { name: encryptionAlg, iv },
  key,
  encrypted,
));

Algorithm support

The following sections detail the algorithms supported by the Node.js Web Crypto API implementation and the APIs supported for each:

Key Management APIs

  • [subtle.generateKey()][], [subtle.exportKey()][], and [subtle.importKey()][] support 'AES-CBC', 'AES-CTR', 'AES-GCM', 'AES-KW', 'AES-OCB', 'ChaCha20-Poly1305'[^modern-algos], 'HMAC', 'KMAC128'[^modern-algos], and 'KMAC256'[^modern-algos].
  • [subtle.importKey()][] supports 'Argon2d', 'Argon2i', 'Argon2id', 'HKDF', and 'PBKDF2'.
  • [subtle.generateKey()][], [subtle.exportKey()][], [subtle.importKey()][], and [subtle.getPublicKey()][] support 'ECDH', 'ECDSA', 'Ed25519', 'Ed448'[^secure-curves], 'ML-DSA-44'[^modern-algos], 'ML-DSA-65'[^modern-algos], 'ML-DSA-87'[^modern-algos], 'ML-KEM-512'[^modern-algos], 'ML-KEM-768'[^modern-algos], 'ML-KEM-1024'[^modern-algos], 'MLKEM768-P256'[^modern-algos], 'MLKEM768-X25519'[^modern-algos], 'MLKEM1024-P384'[^modern-algos], 'RSA-OAEP', 'RSA-PSS', 'RSASSA-PKCS1-v1_5', 'X25519', and 'X448'[^secure-curves].

Crypto Operation APIs

  • [subtle.encrypt()][] and [subtle.decrypt()][] support 'AES-CBC', 'AES-CTR', 'AES-GCM', 'AES-OCB', 'ChaCha20-Poly1305'[^modern-algos], and 'RSA-OAEP'.
  • [subtle.sign()][] and [subtle.verify()][] support 'ECDSA', 'Ed25519', 'Ed448'[^secure-curves], 'HMAC', 'KMAC128'[^modern-algos], 'KMAC256'[^modern-algos], 'ML-DSA-44'[^modern-algos], 'ML-DSA-65'[^modern-algos], 'ML-DSA-87'[^modern-algos], 'RSA-PSS', and 'RSASSA-PKCS1-v1_5'.
  • [subtle.deriveBits()][] and [subtle.deriveKey()][] support 'Argon2d', 'Argon2i', 'Argon2id', 'ECDH', 'HKDF', 'PBKDF2', 'X25519', and 'X448'[^secure-curves].
  • [subtle.wrapKey()][] and [subtle.unwrapKey()][] support 'AES-CBC', 'AES-CTR', 'AES-GCM', 'AES-KW', 'AES-OCB', 'ChaCha20-Poly1305'[^modern-algos], and 'RSA-OAEP'.
  • [subtle.encapsulateBits()][], [subtle.decapsulateBits()][], [subtle.encapsulateKey()][], and [subtle.decapsulateKey()][] support 'ML-KEM-512'[^modern-algos], 'ML-KEM-768'[^modern-algos], 'ML-KEM-1024'[^modern-algos], 'MLKEM768-P256'[^modern-algos], 'MLKEM768-X25519'[^modern-algos], and 'MLKEM1024-P384'[^modern-algos].
  • [subtle.digest()][] supports 'cSHAKE128'[^modern-algos], 'cSHAKE256'[^modern-algos], 'KT128'[^modern-algos], 'KT256'[^modern-algos], 'SHA-1', 'SHA-256', 'SHA-384', 'SHA-512', 'SHA3-256'[^modern-algos], 'SHA3-384'[^modern-algos], 'SHA3-512'[^modern-algos], 'TurboSHAKE128'[^modern-algos], and 'TurboSHAKE256'[^modern-algos].

Key Formats

The following list describes the formats supported by [subtle.importKey()][] and [subtle.exportKey()][].

  • 'AES-CBC', 'AES-CTR', 'AES-GCM', 'AES-KW', and 'HMAC' can be imported and exported using 'jwk', 'raw', and 'raw-secret'[^modern-algos].
  • 'AES-OCB'[^modern-algos], 'ChaCha20-Poly1305'[^modern-algos], 'KMAC128'[^modern-algos], and 'KMAC256'[^modern-algos] can be imported and exported using 'jwk' and 'raw-secret'[^modern-algos].
  • 'Argon2d'[^modern-algos], 'Argon2i'[^modern-algos], and 'Argon2id'[^modern-algos] can be imported using 'raw-secret'[^modern-algos]; export is not supported.
  • 'ECDH', 'ECDSA', 'Ed25519', 'Ed448'[^secure-curves], 'X25519', and 'X448'[^secure-curves] can be imported and exported using 'spki', 'pkcs8', 'jwk', 'raw', and 'raw-public'[^modern-algos].
  • 'HKDF' and 'PBKDF2' can be imported using 'raw' and 'raw-secret'[^modern-algos]; export is not supported.
  • 'ML-DSA-44'[^modern-algos], 'ML-DSA-65'[^modern-algos], 'ML-DSA-87'[^modern-algos], 'ML-KEM-512'[^modern-algos], 'ML-KEM-768'[^modern-algos], and 'ML-KEM-1024'[^modern-algos] can be imported and exported using 'spki', 'pkcs8', 'jwk', 'raw-public'[^modern-algos], and 'raw-seed'[^modern-algos].
  • 'MLKEM768-P256'[^modern-algos], 'MLKEM768-X25519'[^modern-algos], and 'MLKEM1024-P384'[^modern-algos] can be imported and exported using 'jwk', 'raw-public'[^modern-algos], and 'raw-seed'[^modern-algos].
  • 'RSA-OAEP', 'RSA-PSS', and 'RSASSA-PKCS1-v1_5' can be imported and exported using 'spki', 'pkcs8', and 'jwk'.

Class: Crypto

<!-- YAML added: v15.0.0 -->

globalThis.crypto is an instance of the Crypto class. Crypto is a singleton that provides access to the remainder of the crypto API.

crypto.subtle

<!-- YAML added: v15.0.0 -->

  • Type: {SubtleCrypto}

Provides access to the SubtleCrypto API.

crypto.getRandomValues(typedArray)

<!-- YAML added: v15.0.0 -->

  • typedArray {Buffer|TypedArray}
  • Returns: {Buffer|TypedArray}

Generates cryptographically strong random values. The given typedArray is filled with random values, and a reference to typedArray is returned.

The given typedArray must be an integer-based instance of {TypedArray}, i.e. Float32Array and Float64Array are not accepted.

An error will be thrown if the given typedArray is larger than 65,536 bytes.

crypto.randomUUID()

<!-- YAML added: v16.7.0 -->

  • Returns: {string}

Generates a random [RFC 4122][] version 4 UUID. The UUID is generated using a cryptographic pseudorandom number generator.

Class: CryptoKey

<!-- YAML added: v15.0.0 -->

cryptoKey.algorithm

<!-- YAML added: v15.0.0 -->

<!--lint disable maximum-line-length remark-lint-->

  • Type: {KeyAlgorithm|RsaHashedKeyAlgorithm|EcKeyAlgorithm|AesKeyAlgorithm|HmacKeyAlgorithm|KmacKeyAlgorithm}

<!--lint enable maximum-line-length remark-lint-->

An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.

Read-only.

cryptoKey.extractable

<!-- YAML added: v15.0.0 -->

  • Type: {boolean}

When true, the {CryptoKey} can be extracted using either [subtle.exportKey()][] or [subtle.wrapKey()][].

Read-only.

cryptoKey.type

<!-- YAML added: v15.0.0 -->

  • Type: {string} One of 'secret', 'private', or 'public'.

A string identifying whether the key is a symmetric ('secret') or asymmetric ('private' or 'public') key.

cryptoKey.usages

<!-- YAML added: v15.0.0 -->

  • Type: {string[]}

An array of strings identifying the operations for which the key may be used.

The possible usages are:

  • 'encrypt' - Enable using the key with [subtle.encrypt()][]
  • 'decrypt' - Enable using the key with [subtle.decrypt()][]
  • 'sign' - Enable using the key with [subtle.sign()][]
  • 'verify' - Enable using the key with [subtle.verify()][]
  • 'deriveKey' - Enable using the key with [subtle.deriveKey()][]
  • 'deriveBits' - Enable using the key with [subtle.deriveBits()][]
  • 'encapsulateBits' - Enable using the key with [subtle.encapsulateBits()][]
  • 'decapsulateBits' - Enable using the key with [subtle.decapsulateBits()][]
  • 'encapsulateKey' - Enable using the key with [subtle.encapsulateKey()][]
  • 'decapsulateKey' - Enable using the key with [subtle.decapsulateKey()][]
  • 'wrapKey' - Enable using the key with [subtle.wrapKey()][]
  • 'unwrapKey' - Enable using the key with [subtle.unwrapKey()][]

Valid key usages depend on the key algorithm (identified by cryptokey.algorithm.name). See [Crypto operation APIs][] for the operations supported by each key algorithm.

Class: CryptoKeyPair

<!-- YAML added: v15.0.0 -->

The CryptoKeyPair is a simple dictionary object with publicKey and privateKey properties, representing an asymmetric key pair.

cryptoKeyPair.privateKey

<!-- YAML added: v15.0.0 -->

  • Type: {CryptoKey} A {CryptoKey} whose type will be 'private'.

cryptoKeyPair.publicKey

<!-- YAML added: v15.0.0 -->

  • Type: {CryptoKey} A {CryptoKey} whose type will be 'public'.

Class: SubtleCrypto

<!-- YAML added: v15.0.0 -->

Static method: SubtleCrypto.supports(operation, algorithm[, lengthOrAdditionalAlgorithm])

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

<!--lint disable maximum-line-length remark-lint-->

  • operation {string} “encrypt”, “decrypt”, “sign”, “verify”, “digest”, “generateKey”, “deriveKey”, “deriveBits”, “importKey”, “exportKey”, “getPublicKey”, “wrapKey”, “unwrapKey”, “encapsulateBits”, “encapsulateKey”, “decapsulateBits”, or “decapsulateKey”
  • algorithm {string|Algorithm}
  • lengthOrAdditionalAlgorithm {null|number|string|Algorithm|undefined} Depending on the operation this is either ignored, the value of the length argument when operation is “deriveBits”, the algorithm of key to be derived when operation is “deriveKey”, the algorithm of key to be exported before wrapping when operation is “wrapKey”, the algorithm of key to be imported after unwrapping when operation is “unwrapKey”, or the algorithm of key to be imported after en/decapsulating a key when operation is “encapsulateKey” or “decapsulateKey”. Default: null when operation is “deriveBits”, undefined otherwise.
  • Returns: {boolean} Indicating whether the implementation supports the given operation

<!--lint enable maximum-line-length remark-lint-->

Allows feature detection in Web Crypto API, which can be used to detect whether a given algorithm identifier (including its parameters) is supported for the given operation.

See [Checking for runtime algorithm support][] for an example use of this method.

subtle.decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext)

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

  • decapsulationAlgorithm {string|Algorithm}
  • decapsulationKey {CryptoKey}
  • ciphertext {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with {ArrayBuffer} upon success.

A message recipient uses their asymmetric private key to decrypt an “encapsulated key” (ciphertext), thereby recovering a temporary symmetric key (represented as {ArrayBuffer}) which is then used to decrypt a message.

The algorithms currently supported include:

  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]

subtle.decapsulateKey(decapsulationAlgorithm, decapsulationKey, ciphertext, sharedKeyAlgorithm, extractable, keyUsages)

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

  • decapsulationAlgorithm {string|Algorithm}
  • decapsulationKey {CryptoKey}
  • ciphertext {ArrayBuffer|TypedArray|DataView|Buffer}
  • sharedKeyAlgorithm {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with {CryptoKey} upon success.

A message recipient uses their asymmetric private key to decrypt an “encapsulated key” (ciphertext), thereby recovering a temporary symmetric key (represented as {CryptoKey}) which is then used to decrypt a message.

The algorithms currently supported include:

  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]

subtle.decrypt(algorithm, key, data)

<!-- YAML added: v15.0.0 changes: - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59539 description: AES-OCB algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. -->

  • algorithm {RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
  • key {CryptoKey}
  • data {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

Using the method and parameters specified in algorithm and the keying material provided by key, this method attempts to decipher the provided data. If successful, the returned promise will be resolved with an {ArrayBuffer} containing the plaintext result.

The algorithms currently supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-OCB'[^modern-algos]
  • 'ChaCha20-Poly1305'[^modern-algos]
  • 'RSA-OAEP'

subtle.deriveBits(algorithm, baseKey[, length])

<!-- YAML added: v15.0.0 changes: - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59544 description: Argon2 algorithms are now supported. - version: - v22.5.0 - v20.17.0 - v18.20.5 pr-url: https://github.com/nodejs/node/pull/53601 description: The length parameter is now optional for 'ECDH', 'X25519', and 'X448'. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'X25519', and 'X448' algorithms. -->

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params|Argon2Params}
  • baseKey {CryptoKey}
  • length {number|null} Default: null
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

<!--lint enable maximum-line-length remark-lint-->

Using the method and parameters specified in algorithm and the keying material provided by baseKey, this method attempts to generate length bits.

When length is not provided or null the maximum number of bits for a given algorithm is generated. This is allowed for the 'ECDH', 'X25519', and 'X448'[^secure-curves] algorithms, for other algorithms length is required to be a number.

If successful, the returned promise will be resolved with an {ArrayBuffer} containing the generated data.

The algorithms currently supported include:

  • 'Argon2d'[^modern-algos]
  • 'Argon2i'[^modern-algos]
  • 'Argon2id'[^modern-algos]
  • 'ECDH'
  • 'HKDF'
  • 'PBKDF2'
  • 'X25519'
  • 'X448'[^secure-curves]

subtle.deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)

<!-- YAML added: v15.0.0 changes: - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59544 description: Argon2 algorithms are now supported. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'X25519', and 'X448' algorithms. -->

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params|Argon2Params}
  • baseKey {CryptoKey}
  • derivedKeyType {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with a {CryptoKey} upon success.

<!--lint enable maximum-line-length remark-lint-->

Using the method and parameters specified in algorithm, and the keying material provided by baseKey, this method attempts to generate a new {CryptoKey} based on the method and parameters in derivedKeyType.

Calling this method is equivalent to calling [subtle.deriveBits()][] to generate raw keying material, then passing the result into the [subtle.importKey()][] method using the derivedKeyType, extractable, and keyUsages parameters as input.

The algorithms currently supported include:

  • 'Argon2d'[^modern-algos]
  • 'Argon2i'[^modern-algos]
  • 'Argon2id'[^modern-algos]
  • 'ECDH'
  • 'HKDF'
  • 'PBKDF2'
  • 'X25519'
  • 'X448'[^secure-curves]

subtle.digest(algorithm, data)

<!-- YAML added: v15.0.0 changes: - version: v25.9.0 pr-url: https://github.com/nodejs/node/pull/62183 description: TurboSHAKE and KangarooTwelve algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: SHA-3 algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: SHAKE algorithms are now supported. -->

  • algorithm {string|Algorithm|CShakeParams|TurboShakeParams|KangarooTwelveParams}
  • data {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

Using the method identified by algorithm, this method attempts to generate a digest of data. If successful, the returned promise is resolved with an {ArrayBuffer} containing the computed digest.

If algorithm is provided as a {string}, it must be one of:

  • 'cSHAKE128'[^modern-algos]
  • 'cSHAKE256'[^modern-algos]
  • 'KT128'[^modern-algos]
  • 'KT256'[^modern-algos]
  • 'SHA-1'
  • 'SHA-256'
  • 'SHA-384'
  • 'SHA-512'
  • 'SHA3-256'[^modern-algos]
  • 'SHA3-384'[^modern-algos]
  • 'SHA3-512'[^modern-algos]
  • 'TurboSHAKE128'[^modern-algos]
  • 'TurboSHAKE256'[^modern-algos]

If algorithm is provided as an {Object}, it must have a name property whose value is one of the above.

subtle.encapsulateBits(encapsulationAlgorithm, encapsulationKey)

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

  • encapsulationAlgorithm {string|Algorithm}
  • encapsulationKey {CryptoKey}
  • Returns: {Promise} Fulfills with {EncapsulatedBits} upon success.

Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key. This encrypted key is the “encapsulated key” represented as {EncapsulatedBits}.

The algorithms currently supported include:

  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]

subtle.encapsulateKey(encapsulationAlgorithm, encapsulationKey, sharedKeyAlgorithm, extractable, keyUsages)

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

  • encapsulationAlgorithm {string|Algorithm}
  • encapsulationKey {CryptoKey}
  • sharedKeyAlgorithm {string|Algorithm|HmacImportParams|AesDerivedKeyParams|KmacImportParams}
  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with {EncapsulatedKey} upon success.

Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key. This encrypted key is the “encapsulated key” represented as {EncapsulatedKey}.

The algorithms currently supported include:

  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]

subtle.encrypt(algorithm, key, data)

<!-- YAML added: v15.0.0 changes: - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59539 description: AES-OCB algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. -->

  • algorithm {RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
  • key {CryptoKey}
  • data {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

Using the method and parameters specified by algorithm and the keying material provided by key, this method attempts to encipher data. If successful, the returned promise is resolved with an {ArrayBuffer} containing the encrypted result.

The algorithms currently supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-OCB'[^modern-algos]
  • 'ChaCha20-Poly1305'[^modern-algos]
  • 'RSA-OAEP'

subtle.exportKey(format, key)

<!-- YAML added: v15.0.0 changes: - version: v26.10.0 pr-url: https://github.com/nodejs/node/pull/65759 description: Hybrid KEM algorithms are now supported. - version: v26.1.0 pr-url: https://github.com/nodejs/node/pull/62706 description: Added JWK format support for ML-KEM key types. - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59569 description: ML-KEM algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'Ed25519', 'Ed448', 'X25519', and 'X448' algorithms. - version: v15.9.0 pr-url: https://github.com/nodejs/node/pull/37203 description: Removed 'NODE-DSA' JWK export. -->

  • format {string} Must be one of 'raw', 'pkcs8', 'spki', 'jwk', 'raw-secret'[^modern-algos], 'raw-public'[^modern-algos], or 'raw-seed'[^modern-algos].
  • key {CryptoKey}
  • Returns: {Promise} Fulfills with an {ArrayBuffer|Object} upon success.

Exports the given key into the specified format, if supported.

If the {CryptoKey} is not extractable, the returned promise will reject.

When format is either 'pkcs8' or 'spki' and the export is successful, the returned promise will be resolved with an {ArrayBuffer} containing the exported key data.

When format is 'jwk' and the export is successful, the returned promise will be resolved with a JavaScript object conforming to the [JSON Web Key][] specification.

See [Key formats][] for the formats supported by each algorithm.

subtle.getPublicKey(key, keyUsages)

<!-- YAML added: v24.7.0 -->

Stability: 1.1 - Active development

  • key {CryptoKey} A private key from which to derive the corresponding public key.
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with a {CryptoKey} upon success.

Derives the public key from a given private key.

subtle.generateKey(algorithm, extractable, keyUsages)

<!-- YAML added: v15.0.0 changes: - version: v26.10.0 pr-url: https://github.com/nodejs/node/pull/65759 description: Hybrid KEM algorithms are now supported. - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59569 description: ML-KEM algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. -->

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {string|Algorithm|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams|KmacKeyGenParams}

<!--lint enable maximum-line-length remark-lint-->

  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with a {CryptoKey|CryptoKeyPair} upon success.

Using the parameters provided in algorithm, this method attempts to generate new keying material. Depending on the algorithm used either a single {CryptoKey} or a {CryptoKeyPair} is generated.

The {CryptoKeyPair} (public and private key) generating algorithms supported include:

  • 'ECDH'
  • 'ECDSA'
  • 'Ed25519'
  • 'Ed448'[^secure-curves]
  • 'ML-DSA-44'[^modern-algos]
  • 'ML-DSA-65'[^modern-algos]
  • 'ML-DSA-87'[^modern-algos]
  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]
  • 'RSA-OAEP'
  • 'RSA-PSS'
  • 'RSASSA-PKCS1-v1_5'
  • 'X25519'
  • 'X448'[^secure-curves]

The {CryptoKey} (secret key) generating algorithms supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-KW'
  • 'AES-OCB'[^modern-algos]
  • 'ChaCha20-Poly1305'[^modern-algos]
  • 'HMAC'
  • 'KMAC128'[^modern-algos]
  • 'KMAC256'[^modern-algos]

subtle.importKey(format, keyData, algorithm, extractable, keyUsages)

<!-- YAML added: v15.0.0 changes: - version: v26.10.0 pr-url: https://github.com/nodejs/node/pull/65759 description: Hybrid KEM algorithms are now supported. - version: v26.1.0 pr-url: https://github.com/nodejs/node/pull/62706 description: Added JWK format support for ML-KEM key types. - version: v25.9.0 pr-url: https://github.com/nodejs/node/pull/62218 description: Importing ML-DSA and ML-KEM PKCS#8 keys without a seed is no longer supported. - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59569 description: ML-KEM algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'Ed25519', 'Ed448', 'X25519', and 'X448' algorithms. - version: v15.9.0 pr-url: https://github.com/nodejs/node/pull/37203 description: Removed 'NODE-DSA' JWK import. -->

  • format {string} Must be one of 'raw', 'pkcs8', 'spki', 'jwk', 'raw-secret'[^modern-algos], 'raw-public'[^modern-algos], or 'raw-seed'[^modern-algos].
  • keyData {ArrayBuffer|TypedArray|DataView|Buffer|Object}

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams|KmacImportParams}

<!--lint enable maximum-line-length remark-lint-->

  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with a {CryptoKey} upon success.

This method attempts to interpret the provided keyData as the given format to create a {CryptoKey} instance using the provided algorithm, extractable, and keyUsages arguments. If the import is successful, the returned promise will be resolved with a {CryptoKey} representation of the key material.

If importing KDF algorithm keys, extractable must be false.

See [Key formats][] for the algorithms and formats currently supported.

subtle.sign(algorithm, key, data)

<!-- YAML added: v15.0.0 changes: - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'Ed25519', and 'Ed448' algorithms. -->

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {string|Algorithm|RsaPssParams|EcdsaParams|ContextParams|KmacParams}
  • key {CryptoKey}
  • data {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

<!--lint enable maximum-line-length remark-lint-->

Using the method and parameters given by algorithm and the keying material provided by key, this method attempts to generate a cryptographic signature of data. If successful, the returned promise is resolved with an {ArrayBuffer} containing the generated signature.

The algorithms currently supported include:

  • 'ECDSA'
  • 'Ed25519'
  • 'Ed448'[^secure-curves]
  • 'HMAC'
  • 'KMAC128'[^modern-algos]
  • 'KMAC256'[^modern-algos]
  • 'ML-DSA-44'[^modern-algos]
  • 'ML-DSA-65'[^modern-algos]
  • 'ML-DSA-87'[^modern-algos]
  • 'RSA-PSS'
  • 'RSASSA-PKCS1-v1_5'

subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)

<!-- YAML added: v15.0.0 changes: - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59539 description: AES-OCB algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. -->

  • format {string} Must be one of 'raw', 'pkcs8', 'spki', 'jwk', 'raw-secret'[^modern-algos], 'raw-public'[^modern-algos], or 'raw-seed'[^modern-algos].
  • wrappedKey {ArrayBuffer|TypedArray|DataView|Buffer}
  • unwrappingKey {CryptoKey}

<!--lint disable maximum-line-length remark-lint-->

  • unwrapAlgorithm {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
  • unwrappedKeyAlgorithm {string|Algorithm|RsaHashedImportParams|EcKeyImportParams|HmacImportParams|KmacImportParams}

<!--lint enable maximum-line-length remark-lint-->

  • extractable {boolean}
  • keyUsages {string[]} See [Key usages][].
  • Returns: {Promise} Fulfills with a {CryptoKey} upon success.

In cryptography, “wrapping a key” refers to exporting and then encrypting the keying material. This method attempts to decrypt a wrapped key and create a {CryptoKey} instance. It is equivalent to calling [subtle.decrypt()][] first on the encrypted key data (using the wrappedKey, unwrapAlgorithm, and unwrappingKey arguments as input) then passing the results to the [subtle.importKey()][] method using the unwrappedKeyAlgorithm, extractable, and keyUsages arguments as inputs. If successful, the returned promise is resolved with a {CryptoKey} object.

The wrapping algorithms currently supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-KW'
  • 'AES-OCB'[^modern-algos]
  • 'ChaCha20-Poly1305'[^modern-algos]
  • 'RSA-OAEP'

The unwrapped key algorithms supported include:

  • 'AES-CBC'
  • 'AES-CTR'
  • 'AES-GCM'
  • 'AES-KW'
  • 'AES-OCB'[^modern-algos]
  • 'ChaCha20-Poly1305'[^modern-algos]
  • 'ECDH'
  • 'ECDSA'
  • 'Ed25519'
  • 'Ed448'[^secure-curves]
  • 'HMAC'
  • 'KMAC128'[^modern-algos]
  • 'KMAC256'[^modern-algos]
  • 'ML-DSA-44'[^modern-algos]
  • 'ML-DSA-65'[^modern-algos]
  • 'ML-DSA-87'[^modern-algos]
  • 'ML-KEM-512'[^modern-algos]
  • 'ML-KEM-768'[^modern-algos]
  • 'ML-KEM-1024'[^modern-algos]
  • 'MLKEM768-P256'[^modern-algos]
  • 'MLKEM768-X25519'[^modern-algos]
  • 'MLKEM1024-P384'[^modern-algos]
  • 'RSA-OAEP'
  • 'RSA-PSS'
  • 'RSASSA-PKCS1-v1_5'
  • 'X25519'
  • 'X448'[^secure-curves]

subtle.verify(algorithm, key, signature, data)

<!-- YAML added: v15.0.0 changes: - version: v24.8.0 pr-url: https://github.com/nodejs/node/pull/59647 description: KMAC algorithms are now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ML-DSA algorithms are now supported. - version: - v18.4.0 - v16.17.0 pr-url: https://github.com/nodejs/node/pull/42507 description: Added 'Ed25519', and 'Ed448' algorithms. -->

<!--lint disable maximum-line-length remark-lint-->

  • algorithm {string|Algorithm|RsaPssParams|EcdsaParams|ContextParams|KmacParams}
  • key {CryptoKey}
  • signature {ArrayBuffer|TypedArray|DataView|Buffer}
  • data {ArrayBuffer|TypedArray|DataView|Buffer}
  • Returns: {Promise} Fulfills with a {boolean} upon success.

<!--lint enable maximum-line-length remark-lint-->

Using the method and parameters given in algorithm and the keying material provided by key, this method attempts to verify that signature is a valid cryptographic signature of data. The returned promise is resolved with either true or false.

The algorithms currently supported include:

  • 'ECDSA'
  • 'Ed25519'
  • 'Ed448'[^secure-curves]
  • 'HMAC'
  • 'KMAC128'[^modern-algos]
  • 'KMAC256'[^modern-algos]
  • 'ML-DSA-44'[^modern-algos]
  • 'ML-DSA-65'[^modern-algos]
  • 'ML-DSA-87'[^modern-algos]
  • 'RSA-PSS'
  • 'RSASSA-PKCS1-v1_5'

subtle.wrapKey(format, key, wrappingKey, wrapAlgorithm)

<!-- YAML added: v15.0.0 changes: - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59539 description: AES-OCB algorithm is now supported. - version: v24.7.0 pr-url: https://github.com/nodejs/node/pull/59365 description: ChaCha20-Poly1305 algorithm is now supported. -->

<!--lint disable maximum-line-length remark-lint-->

  • format {string} Must be one of 'raw', 'pkcs8', 'spki', 'jwk', 'raw-secret'[^modern-algos], 'raw-public'[^modern-algos], or 'raw-seed'[^modern-algos].
  • key {CryptoKey}
  • wrappingKey {CryptoKey}
  • wrapAlgorithm {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams|AeadParams}
  • Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.

<!--lint enable maximum-line-length remark-lint-->

In cryptography, “wrapping a key” refers to exporting and then encrypting the keying material. This method exports the keying material into the format identified by format, then encrypts it using the method and parameters specified by wrapAlgorithm and the keying ma

(本文超出站点单文档体积上限,已截断)