X Tutup
{ "type": "module", "source": "doc/api/webcrypto.md", "modules": [ { "textRaw": "Web Crypto API", "name": "web_crypto_api", "introduced_in": "v15.0.0", "type": "module", "meta": { "changes": [ { "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." } ] }, "stability": 2, "stabilityText": "Stable", "desc": "

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

\n

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

\n
const { subtle } = globalThis.crypto;\n\n(async function() {\n\n  const key = await subtle.generateKey({\n    name: 'HMAC',\n    hash: 'SHA-256',\n    length: 256,\n  }, true, ['sign', 'verify']);\n\n  const enc = new TextEncoder();\n  const message = enc.encode('I love cupcakes');\n\n  const digest = await subtle.sign({\n    name: 'HMAC',\n  }, key, message);\n\n})();\n
", "modules": [ { "textRaw": "Modern Algorithms in the Web Cryptography API", "name": "modern_algorithms_in_the_web_cryptography_api", "type": "module", "stability": 1.1, "stabilityText": "Active development", "desc": "

Node.js provides an implementation of the following features from the\nModern Algorithms in the Web Cryptography API\nWICG proposal:

\n

Algorithms:

\n\n

Key Formats:

\n\n

Methods:

\n", "displayName": "Modern Algorithms in the Web Cryptography API" }, { "textRaw": "Secure Curves in the Web Cryptography API", "name": "secure_curves_in_the_web_cryptography_api", "type": "module", "stability": 1.1, "stabilityText": "Active development", "desc": "

Node.js provides an implementation of the following features from the\nSecure Curves in the Web Cryptography API\nWICG proposal:

\n

Algorithms:

\n", "displayName": "Secure Curves in the Web Cryptography API" }, { "textRaw": "Examples", "name": "examples", "type": "module", "modules": [ { "textRaw": "Generating keys", "name": "generating_keys", "type": "module", "desc": "

The <SubtleCrypto> class can be used to generate symmetric (secret) keys\nor asymmetric key pairs (public key and private key).

", "modules": [ { "textRaw": "AES keys", "name": "aes_keys", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateAesKey(length = 256) {\n  const key = await subtle.generateKey({\n    name: 'AES-CBC',\n    length,\n  }, true, ['encrypt', 'decrypt']);\n\n  return key;\n}\n
", "displayName": "AES keys" }, { "textRaw": "ECDSA key pairs", "name": "ecdsa_key_pairs", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateEcKey(namedCurve = 'P-521') {\n  const {\n    publicKey,\n    privateKey,\n  } = await subtle.generateKey({\n    name: 'ECDSA',\n    namedCurve,\n  }, true, ['sign', 'verify']);\n\n  return { publicKey, privateKey };\n}\n
", "displayName": "ECDSA key pairs" }, { "textRaw": "Ed25519/X25519 key pairs", "name": "ed25519/x25519_key_pairs", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateEd25519Key() {\n  return subtle.generateKey({\n    name: 'Ed25519',\n  }, true, ['sign', 'verify']);\n}\n\nasync function generateX25519Key() {\n  return subtle.generateKey({\n    name: 'X25519',\n  }, true, ['deriveKey']);\n}\n
", "displayName": "Ed25519/X25519 key pairs" }, { "textRaw": "HMAC keys", "name": "hmac_keys", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateHmacKey(hash = 'SHA-256') {\n  const key = await subtle.generateKey({\n    name: 'HMAC',\n    hash,\n  }, true, ['sign', 'verify']);\n\n  return key;\n}\n
", "displayName": "HMAC keys" }, { "textRaw": "RSA key pairs", "name": "rsa_key_pairs", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\nconst publicExponent = new Uint8Array([1, 0, 1]);\n\nasync function generateRsaKey(modulusLength = 2048, hash = 'SHA-256') {\n  const {\n    publicKey,\n    privateKey,\n  } = await subtle.generateKey({\n    name: 'RSASSA-PKCS1-v1_5',\n    modulusLength,\n    publicExponent,\n    hash,\n  }, true, ['sign', 'verify']);\n\n  return { publicKey, privateKey };\n}\n
", "displayName": "RSA key pairs" } ], "displayName": "Generating keys" }, { "textRaw": "Encryption and decryption", "name": "encryption_and_decryption", "type": "module", "desc": "
const crypto = globalThis.crypto;\n\nasync function aesEncrypt(plaintext) {\n  const ec = new TextEncoder();\n  const key = await generateAesKey();\n  const iv = crypto.getRandomValues(new Uint8Array(16));\n\n  const ciphertext = await crypto.subtle.encrypt({\n    name: 'AES-CBC',\n    iv,\n  }, key, ec.encode(plaintext));\n\n  return {\n    key,\n    iv,\n    ciphertext,\n  };\n}\n\nasync function aesDecrypt(ciphertext, key, iv) {\n  const dec = new TextDecoder();\n  const plaintext = await crypto.subtle.decrypt({\n    name: 'AES-CBC',\n    iv,\n  }, key, ciphertext);\n\n  return dec.decode(plaintext);\n}\n
", "displayName": "Encryption and decryption" }, { "textRaw": "Exporting and importing keys", "name": "exporting_and_importing_keys", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateAndExportHmacKey(format = 'jwk', hash = 'SHA-512') {\n  const key = await subtle.generateKey({\n    name: 'HMAC',\n    hash,\n  }, true, ['sign', 'verify']);\n\n  return subtle.exportKey(format, key);\n}\n\nasync function importHmacKey(keyData, format = 'jwk', hash = 'SHA-512') {\n  const key = await subtle.importKey(format, keyData, {\n    name: 'HMAC',\n    hash,\n  }, true, ['sign', 'verify']);\n\n  return key;\n}\n
", "displayName": "Exporting and importing keys" }, { "textRaw": "Wrapping and unwrapping keys", "name": "wrapping_and_unwrapping_keys", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function generateAndWrapHmacKey(format = 'jwk', hash = 'SHA-512') {\n  const [\n    key,\n    wrappingKey,\n  ] = await Promise.all([\n    subtle.generateKey({\n      name: 'HMAC', hash,\n    }, true, ['sign', 'verify']),\n    subtle.generateKey({\n      name: 'AES-KW',\n      length: 256,\n    }, true, ['wrapKey', 'unwrapKey']),\n  ]);\n\n  const wrappedKey = await subtle.wrapKey(format, key, wrappingKey, 'AES-KW');\n\n  return { wrappedKey, wrappingKey };\n}\n\nasync function unwrapHmacKey(\n  wrappedKey,\n  wrappingKey,\n  format = 'jwk',\n  hash = 'SHA-512') {\n\n  const key = await subtle.unwrapKey(\n    format,\n    wrappedKey,\n    wrappingKey,\n    'AES-KW',\n    { name: 'HMAC', hash },\n    true,\n    ['sign', 'verify']);\n\n  return key;\n}\n
", "displayName": "Wrapping and unwrapping keys" }, { "textRaw": "Sign and verify", "name": "sign_and_verify", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function sign(key, data) {\n  const ec = new TextEncoder();\n  const signature =\n    await subtle.sign('RSASSA-PKCS1-v1_5', key, ec.encode(data));\n  return signature;\n}\n\nasync function verify(key, signature, data) {\n  const ec = new TextEncoder();\n  const verified =\n    await subtle.verify(\n      'RSASSA-PKCS1-v1_5',\n      key,\n      signature,\n      ec.encode(data));\n  return verified;\n}\n
", "displayName": "Sign and verify" }, { "textRaw": "Deriving bits and keys", "name": "deriving_bits_and_keys", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function pbkdf2(pass, salt, iterations = 1000, length = 256) {\n  const ec = new TextEncoder();\n  const key = await subtle.importKey(\n    'raw',\n    ec.encode(pass),\n    'PBKDF2',\n    false,\n    ['deriveBits']);\n  const bits = await subtle.deriveBits({\n    name: 'PBKDF2',\n    hash: 'SHA-512',\n    salt: ec.encode(salt),\n    iterations,\n  }, key, length);\n  return bits;\n}\n\nasync function pbkdf2Key(pass, salt, iterations = 1000, length = 256) {\n  const ec = new TextEncoder();\n  const keyMaterial = await subtle.importKey(\n    'raw',\n    ec.encode(pass),\n    'PBKDF2',\n    false,\n    ['deriveKey']);\n  const key = await subtle.deriveKey({\n    name: 'PBKDF2',\n    hash: 'SHA-512',\n    salt: ec.encode(salt),\n    iterations,\n  }, keyMaterial, {\n    name: 'AES-GCM',\n    length,\n  }, true, ['encrypt', 'decrypt']);\n  return key;\n}\n
", "displayName": "Deriving bits and keys" }, { "textRaw": "Digest", "name": "digest", "type": "module", "desc": "
const { subtle } = globalThis.crypto;\n\nasync function digest(data, algorithm = 'SHA-512') {\n  const ec = new TextEncoder();\n  const digest = await subtle.digest(algorithm, ec.encode(data));\n  return digest;\n}\n
", "displayName": "Digest" }, { "textRaw": "Checking for runtime algorithm support", "name": "checking_for_runtime_algorithm_support", "type": "module", "desc": "

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

\n

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

\n
const { SubtleCrypto, crypto } = globalThis;\n\nconst password = 'correct horse battery staple';\nconst derivationAlg =\n  SubtleCrypto.supports?.('importKey', 'Argon2id') ?\n    'Argon2id' :\n    'PBKDF2';\nconst encryptionAlg =\n  SubtleCrypto.supports?.('importKey', 'AES-OCB') ?\n    'AES-OCB' :\n    'AES-GCM';\nconst passwordKey = await crypto.subtle.importKey(\n  derivationAlg === 'Argon2id' ? 'raw-secret' : 'raw',\n  new TextEncoder().encode(password),\n  derivationAlg,\n  false,\n  ['deriveKey'],\n);\nconst nonce = crypto.getRandomValues(new Uint8Array(16));\nconst derivationParams =\n  derivationAlg === 'Argon2id' ?\n    {\n      nonce,\n      parallelism: 4,\n      memory: 2 ** 21,\n      passes: 1,\n    } :\n    {\n      salt: nonce,\n      iterations: 100_000,\n      hash: 'SHA-256',\n    };\nconst key = await crypto.subtle.deriveKey(\n  {\n    name: derivationAlg,\n    ...derivationParams,\n  },\n  passwordKey,\n  {\n    name: encryptionAlg,\n    length: 256,\n  },\n  false,\n  ['encrypt', 'decrypt'],\n);\nconst plaintext = 'Hello, world!';\nconst iv = crypto.getRandomValues(new Uint8Array(16));\nconst encrypted = await crypto.subtle.encrypt(\n  { name: encryptionAlg, iv },\n  key,\n  new TextEncoder().encode(plaintext),\n);\nconst decrypted = new TextDecoder().decode(await crypto.subtle.decrypt(\n  { name: encryptionAlg, iv },\n  key,\n  encrypted,\n));\n
", "displayName": "Checking for runtime algorithm support" } ], "displayName": "Examples" }, { "textRaw": "Algorithm matrix", "name": "algorithm_matrix", "type": "module", "desc": "

The tables details the algorithms supported by the Node.js Web Crypto API\nimplementation and the APIs supported for each:

", "modules": [ { "textRaw": "Key Management APIs", "name": "key_management_apis", "type": "module", "desc": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Algorithmsubtle.generateKey()subtle.exportKey()subtle.importKey()subtle.getPublicKey()
'AES-CBC'
'AES-CTR'
'AES-GCM'
'AES-KW'
'AES-OCB'
'Argon2d'
'Argon2i'
'Argon2id'
'ChaCha20-Poly1305'1
'ECDH'
'ECDSA'
'Ed25519'
'Ed448'2
'HKDF'
'HMAC'
'KMAC128'1
'KMAC256'1
'ML-DSA-44'1
'ML-DSA-65'1
'ML-DSA-87'1
'ML-KEM-512'1
'ML-KEM-768'1
'ML-KEM-1024'1
'PBKDF2'
'RSA-OAEP'
'RSA-PSS'
'RSASSA-PKCS1-v1_5'
'X25519'
'X448'2
", "displayName": "Key Management APIs" }, { "textRaw": "Crypto Operation APIs", "name": "crypto_operation_apis", "type": "module", "desc": "

Column Legend:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AlgorithmEncryptionSignatures and MACKey or Bits DerivationKey WrappingKey EncapsulationDigest
'AES-CBC'
'AES-CTR'
'AES-GCM'
'AES-KW'
'AES-OCB'
'Argon2d'
'Argon2i'
'Argon2id'
'ChaCha20-Poly1305'1
'cSHAKE128'1
'cSHAKE256'1
'ECDH'
'ECDSA'
'Ed25519'
'Ed448'2
'HKDF'
'HMAC'
'KMAC128'1
'KMAC256'1
'ML-DSA-44'1
'ML-DSA-65'1
'ML-DSA-87'1
'ML-KEM-512'1
'ML-KEM-768'1
'ML-KEM-1024'1
'PBKDF2'
'RSA-OAEP'
'RSA-PSS'
'RSASSA-PKCS1-v1_5'
'SHA-1'
'SHA-256'
'SHA-384'
'SHA-512'
'SHA3-256'1
'SHA3-384'1
'SHA3-512'1
'X25519'
'X448'2
", "displayName": "Crypto Operation APIs" } ], "displayName": "Algorithm matrix" }, { "textRaw": "Algorithm parameters", "name": "algorithm_parameters", "type": "module", "desc": "

The algorithm parameter objects define the methods and parameters used by\nthe various <SubtleCrypto> methods. While described here as \"classes\", they\nare simple JavaScript dictionary objects.

", "classes": [ { "textRaw": "Class: `Algorithm`", "name": "Algorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ] }, { "textRaw": "Class: `AeadParams`", "name": "AeadParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}", "name": "additionalData", "type": "ArrayBuffer|TypedArray|DataView|Buffer|undefined", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

Extra input that is not encrypted but is included in the authentication\nof the data. The use of additionalData is optional.

" }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "iv", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The initialization vector must be unique for every encryption operation using a\ngiven key.

" }, { "textRaw": "Type: {string} Must be `'AES-GCM'`, `'AES-OCB'`, or `'ChaCha20-Poly1305'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'AES-GCM'`, `'AES-OCB'`, or `'ChaCha20-Poly1305'`." }, { "textRaw": "Type: {number} The size in bits of the generated authentication tag.", "name": "tagLength", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "The size in bits of the generated authentication tag." } ] }, { "textRaw": "Class: `AesDerivedKeyParams`", "name": "AesDerivedKeyParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be one of `'AES-CBC'`, `'AES-CTR'`, `'AES-GCM'`, `'AES-OCB'`, or `'AES-KW'`", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'AES-CBC'`, `'AES-CTR'`, `'AES-GCM'`, `'AES-OCB'`, or `'AES-KW'`" }, { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length of the AES key to be derived. This must be either 128, 192,\nor 256.

" } ] }, { "textRaw": "Class: `AesCbcParams`", "name": "AesCbcParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "iv", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

Provides the initialization vector. It must be exactly 16-bytes in length\nand should be unpredictable and cryptographically random.

" }, { "textRaw": "Type: {string} Must be `'AES-CBC'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'AES-CBC'`." } ] }, { "textRaw": "Class: `AesCtrParams`", "name": "AesCtrParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "counter", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The initial value of the counter block. This must be exactly 16 bytes long.

\n

The AES-CTR method uses the rightmost length bits of the block as the\ncounter and the remaining bits as the nonce.

" }, { "textRaw": "Type: {number} The number of bits in the `aesCtrParams.counter` that are to be used as the counter.", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "The number of bits in the `aesCtrParams.counter` that are to be used as the counter." }, { "textRaw": "Type: {string} Must be `'AES-CTR'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'AES-CTR'`." } ] }, { "textRaw": "Class: `AesKeyAlgorithm`", "name": "AesKeyAlgorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length of the AES key in bits.

" }, { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ] }, { "textRaw": "Class: `AesKeyGenParams`", "name": "AesKeyGenParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length of the AES key to be generated. This must be either 128, 192,\nor 256.

" }, { "textRaw": "Type: {string} Must be one of `'AES-CBC'`, `'AES-CTR'`, `'AES-GCM'`, or `'AES-KW'`", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'AES-CBC'`, `'AES-CTR'`, `'AES-GCM'`, or `'AES-KW'`" } ] }, { "textRaw": "Class: `Argon2Params`", "name": "Argon2Params", "type": "class", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "associatedData", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the optional associated data.

" }, { "textRaw": "Type: {number}", "name": "memory", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the memory size in kibibytes. It must be at least 8 times the degree of parallelism.

" }, { "textRaw": "Type: {string} Must be one of `'Argon2d'`, `'Argon2i'`, or `'Argon2id'`.", "name": "name", "type": "string", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "Must be one of `'Argon2d'`, `'Argon2i'`, or `'Argon2id'`." }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "nonce", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the nonce, which is a salt for password hashing applications.

" }, { "textRaw": "Type: {number}", "name": "parallelism", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the degree of parallelism.

" }, { "textRaw": "Type: {number}", "name": "passes", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the number of passes.

" }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "secretValue", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the optional secret value.

" }, { "textRaw": "Type: {number}", "name": "version", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

Represents the Argon2 version number. The default and currently only defined version is 19 (0x13).

" } ] }, { "textRaw": "Class: `ContextParams`", "name": "ContextParams", "type": "class", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be `Ed448`, `'ML-DSA-44'`, `'ML-DSA-65'`, or `'ML-DSA-87'`.", "name": "name", "type": "string", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "Must be `Ed448`, `'ML-DSA-44'`, `'ML-DSA-65'`, or `'ML-DSA-87'`." }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}", "name": "context", "type": "ArrayBuffer|TypedArray|DataView|Buffer|undefined", "meta": { "added": [ "v24.7.0" ], "changes": [ { "version": "v24.8.0", "pr-url": "https://github.com/nodejs/node/pull/59570", "description": "Non-empty context is now supported." } ] }, "desc": "

The context member represents the optional context data to associate with\nthe message.

" } ] }, { "textRaw": "Class: `CShakeParams`", "name": "CShakeParams", "type": "class", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}", "name": "customization", "type": "ArrayBuffer|TypedArray|DataView|Buffer|undefined", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "

The customization member represents the customization string.\nThe Node.js Web Crypto API implementation only supports zero-length customization\nwhich is equivalent to not providing customization at all.

" }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}", "name": "functionName", "type": "ArrayBuffer|TypedArray|DataView|Buffer|undefined", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "

The functionName member represents represents the function name, used by NIST to define\nfunctions based on cSHAKE.\nThe Node.js Web Crypto API implementation only supports zero-length functionName\nwhich is equivalent to not providing functionName at all.

" }, { "textRaw": "Type: {number} represents the requested output length in bits.", "name": "length", "type": "number", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "represents the requested output length in bits." }, { "textRaw": "Type: {string} Must be `'cSHAKE128'` or `'cSHAKE256'`", "name": "name", "type": "string", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "Must be `'cSHAKE128'` or `'cSHAKE256'`" } ] }, { "textRaw": "Class: `EcdhKeyDeriveParams`", "name": "EcdhKeyDeriveParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be `'ECDH'`, `'X25519'`, or `'X448'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'ECDH'`, `'X25519'`, or `'X448'`." }, { "textRaw": "Type: {CryptoKey}", "name": "public", "type": "CryptoKey", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

ECDH key derivation operates by taking as input one parties private key and\nanother parties public key -- using both to generate a common shared secret.\nThe ecdhKeyDeriveParams.public property is set to the other parties public\nkey.

" } ] }, { "textRaw": "Class: `EcdsaParams`", "name": "EcdsaParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {string} Must be `'ECDSA'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'ECDSA'`." } ] }, { "textRaw": "Class: `EcKeyAlgorithm`", "name": "EcKeyAlgorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } }, { "textRaw": "Type: {string}", "name": "namedCurve", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ] }, { "textRaw": "Class: `EcKeyGenParams`", "name": "EcKeyGenParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be one of `'ECDSA'` or `'ECDH'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'ECDSA'` or `'ECDH'`." }, { "textRaw": "Type: {string} Must be one of `'P-256'`, `'P-384'`, `'P-521'`.", "name": "namedCurve", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'P-256'`, `'P-384'`, `'P-521'`." } ] }, { "textRaw": "Class: `EcKeyImportParams`", "name": "EcKeyImportParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be one of `'ECDSA'` or `'ECDH'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'ECDSA'` or `'ECDH'`." }, { "textRaw": "Type: {string} Must be one of `'P-256'`, `'P-384'`, `'P-521'`.", "name": "namedCurve", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'P-256'`, `'P-384'`, `'P-521'`." } ] }, { "textRaw": "Class: `EncapsulatedBits`", "name": "EncapsulatedBits", "type": "class", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "

A temporary symmetric secret key (represented as <ArrayBuffer>) for message encryption\nand the ciphertext (that can be transmitted to the message recipient along with the\nmessage) encrypted by this shared key. The recipient uses their private key to determine\nwhat the shared key is which then allows them to decrypt the message.

", "properties": [ { "textRaw": "Type: {ArrayBuffer}", "name": "ciphertext", "type": "ArrayBuffer", "meta": { "added": [ "v24.7.0" ], "changes": [] } }, { "textRaw": "Type: {ArrayBuffer}", "name": "sharedKey", "type": "ArrayBuffer", "meta": { "added": [ "v24.7.0" ], "changes": [] } } ] }, { "textRaw": "Class: `EncapsulatedKey`", "name": "EncapsulatedKey", "type": "class", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "desc": "

A temporary symmetric secret key (represented as <CryptoKey>) for message encryption\nand the ciphertext (that can be transmitted to the message recipient along with the\nmessage) encrypted by this shared key. The recipient uses their private key to determine\nwhat the shared key is which then allows them to decrypt the message.

", "properties": [ { "textRaw": "Type: {ArrayBuffer}", "name": "ciphertext", "type": "ArrayBuffer", "meta": { "added": [ "v24.7.0" ], "changes": [] } }, { "textRaw": "Type: {CryptoKey}", "name": "sharedKey", "type": "CryptoKey", "meta": { "added": [ "v24.7.0" ], "changes": [] } } ] }, { "textRaw": "Class: `HkdfParams`", "name": "HkdfParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "info", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

Provides application-specific contextual input to the HKDF algorithm.\nThis can be zero-length but must be provided.

" }, { "textRaw": "Type: {string} Must be `'HKDF'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'HKDF'`." }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "salt", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The salt value significantly improves the strength of the HKDF algorithm.\nIt should be random or pseudorandom and should be the same length as the\noutput of the digest function (for instance, if using 'SHA-256' as the\ndigest, the salt should be 256-bits of random data).

" } ] }, { "textRaw": "Class: `HmacImportParams`", "name": "HmacImportParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The optional number of bits in the HMAC key. This is optional and should\nbe omitted for most cases.

" }, { "textRaw": "Type: {string} Must be `'HMAC'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'HMAC'`." } ] }, { "textRaw": "Class: `HmacKeyAlgorithm`", "name": "HmacKeyAlgorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {Algorithm}", "name": "hash", "type": "Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [] } }, { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length of the HMAC key in bits.

" }, { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ] }, { "textRaw": "Class: `HmacKeyGenParams`", "name": "HmacKeyGenParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The number of bits to generate for the HMAC key. If omitted,\nthe length will be determined by the hash algorithm used.\nThis is optional and should be omitted for most cases.

" }, { "textRaw": "Type: {string} Must be `'HMAC'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'HMAC'`." } ] }, { "textRaw": "Class: `KeyAlgorithm`", "name": "KeyAlgorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } } ] }, { "textRaw": "Class: `KmacImportParams`", "name": "KmacImportParams", "type": "class", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

The optional number of bits in the KMAC key. This is optional and should\nbe omitted for most cases.

" }, { "textRaw": "Type: {string} Must be `'KMAC128'` or `'KMAC256'`.", "name": "name", "type": "string", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "Must be `'KMAC128'` or `'KMAC256'`." } ] }, { "textRaw": "Class: `KmacKeyAlgorithm`", "name": "KmacKeyAlgorithm", "type": "class", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

The length of the KMAC key in bits.

" }, { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v24.8.0" ], "changes": [] } } ] }, { "textRaw": "Class: `KmacKeyGenParams`", "name": "KmacKeyGenParams", "type": "class", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

The number of bits to generate for the KMAC key. If omitted,\nthe length will be determined by the KMAC algorithm used.\nThis is optional and should be omitted for most cases.

" }, { "textRaw": "Type: {string} Must be `'KMAC128'` or `'KMAC256'`.", "name": "name", "type": "string", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "Must be `'KMAC128'` or `'KMAC256'`." } ] }, { "textRaw": "Class: `KmacParams`", "name": "KmacParams", "type": "class", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be `'KMAC128'` or `'KMAC256'`.", "name": "algorithm", "type": "string", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "Must be `'KMAC128'` or `'KMAC256'`." }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}", "name": "customization", "type": "ArrayBuffer|TypedArray|DataView|Buffer|undefined", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

The customization member represents the optional customization string.

" }, { "textRaw": "Type: {number}", "name": "length", "type": "number", "meta": { "added": [ "v24.8.0" ], "changes": [] }, "desc": "

The length of the output in bytes. This must be a positive integer.

" } ] }, { "textRaw": "Class: `Pbkdf2Params`", "name": "Pbkdf2Params", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {number}", "name": "iterations", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The number of iterations the PBKDF2 algorithm should make when deriving bits.

" }, { "textRaw": "Type: {string} Must be `'PBKDF2'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'PBKDF2'`." }, { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "salt", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

Should be at least 16 random or pseudorandom bytes.

" } ] }, { "textRaw": "Class: `RsaHashedImportParams`", "name": "RsaHashedImportParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {string} Must be one of `'RSASSA-PKCS1-v1_5'`, `'RSA-PSS'`, or `'RSA-OAEP'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'RSASSA-PKCS1-v1_5'`, `'RSA-PSS'`, or `'RSA-OAEP'`." } ] }, { "textRaw": "Class: `RsaHashedKeyAlgorithm`", "name": "RsaHashedKeyAlgorithm", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {Algorithm}", "name": "hash", "type": "Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [] } }, { "textRaw": "Type: {number}", "name": "modulusLength", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length in bits of the RSA modulus.

" }, { "textRaw": "Type: {string}", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] } }, { "textRaw": "Type: {Uint8Array}", "name": "publicExponent", "type": "Uint8Array", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The RSA public exponent.

" } ] }, { "textRaw": "Class: `RsaHashedKeyGenParams`", "name": "RsaHashedKeyGenParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string|Algorithm}", "name": "hash", "type": "string|Algorithm", "meta": { "added": [ "v15.0.0" ], "changes": [ { "version": "v24.7.0", "pr-url": "https://github.com/nodejs/node/pull/59365", "description": "SHA-3 algorithms are now supported." } ] }, "desc": "

If represented as a <string>, the value must be one of:

\n\n

If represented as an <Algorithm>, the object's name property\nmust be one of the above listed values.

" }, { "textRaw": "Type: {number}", "name": "modulusLength", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length in bits of the RSA modulus. As a best practice, this should be\nat least 2048.

" }, { "textRaw": "Type: {string} Must be one of `'RSASSA-PKCS1-v1_5'`, `'RSA-PSS'`, or `'RSA-OAEP'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be one of `'RSASSA-PKCS1-v1_5'`, `'RSA-PSS'`, or `'RSA-OAEP'`." }, { "textRaw": "Type: {Uint8Array}", "name": "publicExponent", "type": "Uint8Array", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The RSA public exponent. This must be a <Uint8Array> containing a big-endian,\nunsigned integer that must fit within 32-bits. The <Uint8Array> may contain an\narbitrary number of leading zero-bits. The value must be a prime number. Unless\nthere is reason to use a different value, use new Uint8Array([1, 0, 1])\n(65537) as the public exponent.

" } ] }, { "textRaw": "Class: `RsaOaepParams`", "name": "RsaOaepParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "label", "type": "ArrayBuffer|TypedArray|DataView|Buffer", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

An additional collection of bytes that will not be encrypted, but will be bound\nto the generated ciphertext.

\n

The rsaOaepParams.label parameter is optional.

" }, { "textRaw": "Type: {string} must be `'RSA-OAEP'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "must be `'RSA-OAEP'`." } ] }, { "textRaw": "Class: `RsaPssParams`", "name": "RsaPssParams", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {string} Must be `'RSA-PSS'`.", "name": "name", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "Must be `'RSA-PSS'`." }, { "textRaw": "Type: {number}", "name": "saltLength", "type": "number", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

The length (in bytes) of the random salt to use.

" } ] } ], "displayName": "Algorithm parameters" } ], "classes": [ { "textRaw": "Class: `Crypto`", "name": "Crypto", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

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

", "properties": [ { "textRaw": "Type: {SubtleCrypto}", "name": "subtle", "type": "SubtleCrypto", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

Provides access to the SubtleCrypto API.

" } ], "methods": [ { "textRaw": "`crypto.getRandomValues(typedArray)`", "name": "getRandomValues", "type": "method", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`typedArray` {Buffer|TypedArray}", "name": "typedArray", "type": "Buffer|TypedArray" } ], "return": { "textRaw": "Returns: {Buffer|TypedArray}", "name": "return", "type": "Buffer|TypedArray" } } ], "desc": "

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

\n

The given typedArray must be an integer-based instance of <TypedArray>,\ni.e. Float32Array and Float64Array are not accepted.

\n

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

" }, { "textRaw": "`crypto.randomUUID()`", "name": "randomUUID", "type": "method", "meta": { "added": [ "v16.7.0" ], "changes": [] }, "signatures": [ { "params": [], "return": { "textRaw": "Returns: {string}", "name": "return", "type": "string" } } ], "desc": "

Generates a random RFC 4122 version 4 UUID. The UUID is generated using a\ncryptographic pseudorandom number generator.

" } ] }, { "textRaw": "Class: `CryptoKey`", "name": "CryptoKey", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "properties": [ { "textRaw": "Type: {KeyAlgorithm|RsaHashedKeyAlgorithm|EcKeyAlgorithm|AesKeyAlgorithm|HmacKeyAlgorithm}", "name": "algorithm", "type": "KeyAlgorithm|RsaHashedKeyAlgorithm|EcKeyAlgorithm|AesKeyAlgorithm|HmacKeyAlgorithm", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

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

\n

Read-only.

" }, { "textRaw": "Type: {boolean}", "name": "extractable", "type": "boolean", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

When true, the <CryptoKey> can be extracted using either subtle.exportKey() or subtle.wrapKey().

\n

Read-only.

" }, { "textRaw": "Type: {string} One of `'secret'`, `'private'`, or `'public'`.", "name": "type", "type": "string", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

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

", "shortDesc": "One of `'secret'`, `'private'`, or `'public'`." }, { "textRaw": "Type: {string[]}", "name": "usages", "type": "string[]", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

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

\n

The possible usages are:

\n\n

Valid key usages depend on the key algorithm (identified by\ncryptokey.algorithm.name).

\n

Column Legend:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Supported Key AlgorithmEncryptionSignatures and MACKey or Bits DerivationKey WrappingKey Encapsulation
'AES-CBC'
'AES-CTR'
'AES-GCM'
'AES-KW'
'AES-OCB'
'Argon2d'
'Argon2i'
'Argon2id'
'ChaCha20-Poly1305'1
'ECDH'
'ECDSA'
'Ed25519'
'Ed448'2
'HDKF'
'HMAC'
'KMAC128'1
'KMAC256'1
'ML-DSA-44'1
'ML-DSA-65'1
'ML-DSA-87'1
'ML-KEM-512'1
'ML-KEM-768'1
'ML-KEM-1024'1
'PBKDF2'
'RSA-OAEP'
'RSA-PSS'
'RSASSA-PKCS1-v1_5'
'X25519'
'X448'2
" } ] }, { "textRaw": "Class: `CryptoKeyPair`", "name": "CryptoKeyPair", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "

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

", "properties": [ { "textRaw": "Type: {CryptoKey} A {CryptoKey} whose `type` will be `'private'`.", "name": "privateKey", "type": "CryptoKey", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "A {CryptoKey} whose `type` will be `'private'`." }, { "textRaw": "Type: {CryptoKey} A {CryptoKey} whose `type` will be `'public'`.", "name": "publicKey", "type": "CryptoKey", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "desc": "A {CryptoKey} whose `type` will be `'public'`." } ] }, { "textRaw": "Class: `SubtleCrypto`", "name": "SubtleCrypto", "type": "class", "meta": { "added": [ "v15.0.0" ], "changes": [] }, "classMethods": [ { "textRaw": "Static method: `SubtleCrypto.supports(operation, algorithm[, lengthOrAdditionalAlgorithm])`", "name": "supports", "type": "classMethod", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`operation` {string} \"encrypt\", \"decrypt\", \"sign\", \"verify\", \"digest\", \"generateKey\", \"deriveKey\", \"deriveBits\", \"importKey\", \"exportKey\", \"getPublicKey\", \"wrapKey\", \"unwrapKey\", \"encapsulateBits\", \"encapsulateKey\", \"decapsulateBits\", or \"decapsulateKey\"", "name": "operation", "type": "string", "desc": "\"encrypt\", \"decrypt\", \"sign\", \"verify\", \"digest\", \"generateKey\", \"deriveKey\", \"deriveBits\", \"importKey\", \"exportKey\", \"getPublicKey\", \"wrapKey\", \"unwrapKey\", \"encapsulateBits\", \"encapsulateKey\", \"decapsulateBits\", or \"decapsulateKey\"" }, { "textRaw": "`algorithm` {string|Algorithm}", "name": "algorithm", "type": "string|Algorithm" }, { "textRaw": "`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.", "name": "lengthOrAdditionalAlgorithm", "type": "null|number|string|Algorithm|undefined", "default": "`null` when operation is \"deriveBits\", `undefined` otherwise", "desc": "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\".", "optional": true } ], "return": { "textRaw": "Returns: {boolean} Indicating whether the implementation supports the given operation", "name": "return", "type": "boolean", "desc": "Indicating whether the implementation supports the given operation" } } ], "desc": "

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

\n

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

" } ], "methods": [ { "textRaw": "`subtle.decapsulateBits(decapsulationAlgorithm, decapsulationKey, ciphertext)`", "name": "decapsulateBits", "type": "method", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`decapsulationAlgorithm` {string|Algorithm}", "name": "decapsulationAlgorithm", "type": "string|Algorithm" }, { "textRaw": "`decapsulationKey` {CryptoKey}", "name": "decapsulationKey", "type": "CryptoKey" }, { "textRaw": "`ciphertext` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "ciphertext", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with {ArrayBuffer} upon success." } } ], "desc": "

A message recipient uses their asymmetric private key to decrypt an\n\"encapsulated key\" (ciphertext), thereby recovering a temporary symmetric\nkey (represented as <ArrayBuffer>) which is then used to decrypt a message.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.decapsulateKey(decapsulationAlgorithm, decapsulationKey, ciphertext, sharedKeyAlgorithm, extractable, usages)`", "name": "decapsulateKey", "type": "method", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`decapsulationAlgorithm` {string|Algorithm}", "name": "decapsulationAlgorithm", "type": "string|Algorithm" }, { "textRaw": "`decapsulationKey` {CryptoKey}", "name": "decapsulationKey", "type": "CryptoKey" }, { "textRaw": "`ciphertext` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "ciphertext", "type": "ArrayBuffer|TypedArray|DataView|Buffer" }, { "textRaw": "`sharedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams}", "name": "sharedKeyAlgorithm", "type": "string|Algorithm|HmacImportParams|AesDerivedKeyParams" }, { "textRaw": "`extractable` {boolean}", "name": "extractable", "type": "boolean" }, { "textRaw": "`usages` {string[]} See Key usages.", "name": "usages", "type": "string[]", "desc": "See Key usages." } ], "return": { "textRaw": "Returns: {Promise} Fulfills with {CryptoKey} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with {CryptoKey} upon success." } } ], "desc": "

A message recipient uses their asymmetric private key to decrypt an\n\"encapsulated key\" (ciphertext), thereby recovering a temporary symmetric\nkey (represented as <CryptoKey>) which is then used to decrypt a message.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.decrypt(algorithm, key, data)`", "name": "decrypt", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams}", "name": "algorithm", "type": "RsaOaepParams|AesCtrParams|AesCbcParams" }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" }, { "textRaw": "`data` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "data", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

Using the method and parameters specified in algorithm and the keying\nmaterial provided by key, this method attempts to decipher the\nprovided data. If successful, the returned promise will be resolved with\nan <ArrayBuffer> containing the plaintext result.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.deriveBits(algorithm, baseKey[, length])`", "name": "deriveBits", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params}", "name": "algorithm", "type": "EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params" }, { "textRaw": "`baseKey` {CryptoKey}", "name": "baseKey", "type": "CryptoKey" }, { "textRaw": "`length` {number|null} **Default:** `null`", "name": "length", "type": "number|null", "default": "`null`", "optional": true } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

Using the method and parameters specified in algorithm and the keying\nmaterial provided by baseKey, this method attempts to generate\nlength bits.

\n

When length is not provided or null the maximum number of bits for a given\nalgorithm is generated. This is allowed for the 'ECDH', 'X25519', and 'X448'1\nalgorithms, for other algorithms length is required to be a number.

\n

If successful, the returned promise will be resolved with an <ArrayBuffer>\ncontaining the generated data.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)`", "name": "deriveKey", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params}", "name": "algorithm", "type": "EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params" }, { "textRaw": "`baseKey` {CryptoKey}", "name": "baseKey", "type": "CryptoKey" }, { "textRaw": "`derivedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams}", "name": "derivedKeyAlgorithm", "type": "string|Algorithm|HmacImportParams|AesDerivedKeyParams" }, { "textRaw": "`extractable` {boolean}", "name": "extractable", "type": "boolean" }, { "textRaw": "`keyUsages` {string[]} See Key usages.", "name": "keyUsages", "type": "string[]", "desc": "See Key usages." } ], "return": { "textRaw": "Returns: {Promise} Fulfills with a {CryptoKey} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with a {CryptoKey} upon success." } } ], "desc": "

Using the method and parameters specified in algorithm, and the keying\nmaterial provided by baseKey, this method attempts to generate\na new <CryptoKey> based on the method and parameters in derivedKeyAlgorithm.

\n

Calling this method is equivalent to calling subtle.deriveBits() to\ngenerate raw keying material, then passing the result into the\nsubtle.importKey() method using the deriveKeyAlgorithm, extractable, and\nkeyUsages parameters as input.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.digest(algorithm, data)`", "name": "digest", "type": "method", "meta": { "added": [ "v15.0.0" ], "changes": [ { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {string|Algorithm}", "name": "algorithm", "type": "string|Algorithm" }, { "textRaw": "`data` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "data", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

Using the method identified by algorithm, this method attempts to\ngenerate a digest of data. If successful, the returned promise is resolved\nwith an <ArrayBuffer> containing the computed digest.

\n

If algorithm is provided as a <string>, it must be one of:

\n\n

If algorithm is provided as an <Object>, it must have a name property\nwhose value is one of the above.

" }, { "textRaw": "`subtle.encapsulateBits(encapsulationAlgorithm, encapsulationKey)`", "name": "encapsulateBits", "type": "method", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`encapsulationAlgorithm` {string|Algorithm}", "name": "encapsulationAlgorithm", "type": "string|Algorithm" }, { "textRaw": "`encapsulationKey` {CryptoKey}", "name": "encapsulationKey", "type": "CryptoKey" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with {EncapsulatedBits} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with {EncapsulatedBits} upon success." } } ], "desc": "

Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.\nThis encrypted key is the \"encapsulated key\" represented as {EncapsulatedBits}.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.encapsulateKey(encapsulationAlgorithm, encapsulationKey, sharedKeyAlgorithm, extractable, usages)`", "name": "encapsulateKey", "type": "method", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`encapsulationAlgorithm` {string|Algorithm}", "name": "encapsulationAlgorithm", "type": "string|Algorithm" }, { "textRaw": "`encapsulationKey` {CryptoKey}", "name": "encapsulationKey", "type": "CryptoKey" }, { "textRaw": "`sharedKeyAlgorithm` {string|Algorithm|HmacImportParams|AesDerivedKeyParams}", "name": "sharedKeyAlgorithm", "type": "string|Algorithm|HmacImportParams|AesDerivedKeyParams" }, { "textRaw": "`extractable` {boolean}", "name": "extractable", "type": "boolean" }, { "textRaw": "`usages` {string[]} See Key usages.", "name": "usages", "type": "string[]", "desc": "See Key usages." } ], "return": { "textRaw": "Returns: {Promise} Fulfills with {EncapsulatedKey} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with {EncapsulatedKey} upon success." } } ], "desc": "

Uses a message recipient's asymmetric public key to encrypt a temporary symmetric key.\nThis encrypted key is the \"encapsulated key\" represented as {EncapsulatedKey}.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.encrypt(algorithm, key, data)`", "name": "encrypt", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {RsaOaepParams|AesCtrParams|AesCbcParams}", "name": "algorithm", "type": "RsaOaepParams|AesCtrParams|AesCbcParams" }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" }, { "textRaw": "`data` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "data", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

Using the method and parameters specified by algorithm and the keying\nmaterial provided by key, this method attempts to encipher data.\nIf successful, the returned promise is resolved with an <ArrayBuffer>\ncontaining the encrypted result.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.exportKey(format, key)`", "name": "exportKey", "type": "method", "meta": { "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/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." } ] }, "signatures": [ { "params": [ { "textRaw": "`format` {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`.", "name": "format", "type": "string", "desc": "Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`." }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer|Object} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer|Object} upon success." } } ], "desc": "

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

\n

If the <CryptoKey> is not extractable, the returned promise will reject.

\n

When format is either 'pkcs8' or 'spki' and the export is successful,\nthe returned promise will be resolved with an <ArrayBuffer> containing the\nexported key data.

\n

When format is 'jwk' and the export is successful, the returned promise\nwill be resolved with a JavaScript object conforming to the JSON Web Key\nspecification.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Supported Key Algorithm'spki''pkcs8''jwk''raw''raw-secret''raw-public''raw-seed'
'AES-CBC'
'AES-CTR'
'AES-GCM'
'AES-KW'
'AES-OCB'1
'ChaCha20-Poly1305'1
'ECDH'
'ECDSA'
'Ed25519'
'Ed448'2
'HMAC'
'KMAC128'1
'KMAC256'1
'ML-DSA-44'1
'ML-DSA-65'1
'ML-DSA-87'1
'ML-KEM-512'1
'ML-KEM-768'1
'ML-KEM-1024'1
'RSA-OAEP'
'RSA-PSS'
'RSASSA-PKCS1-v1_5'
" }, { "textRaw": "`subtle.getPublicKey(key, keyUsages)`", "name": "getPublicKey", "type": "method", "meta": { "added": [ "v24.7.0" ], "changes": [] }, "stability": 1.1, "stabilityText": "Active development", "signatures": [ { "params": [ { "textRaw": "`key` {CryptoKey} A private key from which to derive the corresponding public key.", "name": "key", "type": "CryptoKey", "desc": "A private key from which to derive the corresponding public key." }, { "textRaw": "`keyUsages` {string[]} See Key usages.", "name": "keyUsages", "type": "string[]", "desc": "See Key usages." } ], "return": { "textRaw": "Returns: {Promise} Fulfills with a {CryptoKey} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with a {CryptoKey} upon success." } } ], "desc": "

Derives the public key from a given private key.

" }, { "textRaw": "`subtle.generateKey(algorithm, extractable, keyUsages)`", "name": "generateKey", "type": "method", "meta": { "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/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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {string|Algorithm|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams}", "name": "algorithm", "type": "string|Algorithm|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams" }, { "name": "extractable" }, { "name": "keyUsages" } ] } ], "desc": "\n

Using the parameters provided in algorithm, this method\nattempts to generate new keying material. Depending on the algorithm used\neither a single <CryptoKey> or a <CryptoKeyPair> is generated.

\n

The <CryptoKeyPair> (public and private key) generating algorithms supported\ninclude:

\n\n

The <CryptoKey> (secret key) generating algorithms supported include:

\n" }, { "textRaw": "`subtle.importKey(format, keyData, algorithm, extractable, keyUsages)`", "name": "importKey", "type": "method", "meta": { "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/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." } ] }, "signatures": [ { "params": [ { "textRaw": "`format` {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`.", "name": "format", "type": "string", "desc": "Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`." }, { "textRaw": "`keyData` {ArrayBuffer|TypedArray|DataView|Buffer|Object}", "name": "keyData", "type": "ArrayBuffer|TypedArray|DataView|Buffer|Object" }, { "name": "algorithm" }, { "name": "extractable" }, { "name": "keyUsages" } ] } ], "desc": "\n\n

This method attempts to interpret the provided keyData\nas the given format to create a <CryptoKey> instance using the provided algorithm, extractable, and keyUsages arguments. If the import is\nsuccessful, the returned promise will be resolved with a <CryptoKey>\nrepresentation of the key material.

\n

If importing KDF algorithm keys, extractable must be false.

\n

The algorithms currently supported include:

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Supported Key Algorithm'spki''pkcs8''jwk''raw''raw-secret''raw-public''raw-seed'
'AES-CBC'
'AES-CTR'
'AES-GCM'
'AES-KW'
'AES-OCB'1
'Argon2d'1
'Argon2i'1
'Argon2id'1
'ChaCha20-Poly1305'1
'ECDH'
'ECDSA'
'Ed25519'
'Ed448'2
'HDKF'
'HMAC'
'KMAC128'1
'KMAC256'1
'ML-DSA-44'1
'ML-DSA-65'1
'ML-DSA-87'1
'ML-KEM-512'1
'ML-KEM-768'1
'ML-KEM-1024'1
'PBKDF2'
'RSA-OAEP'
'RSA-PSS'
'RSASSA-PKCS1-v1_5'
'X25519'
'X448'2
" }, { "textRaw": "`subtle.sign(algorithm, key, data)`", "name": "sign", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {string|Algorithm|RsaPssParams|EcdsaParams}", "name": "algorithm", "type": "string|Algorithm|RsaPssParams|EcdsaParams" }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" }, { "textRaw": "`data` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "data", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

Using the method and parameters given by algorithm and the keying material\nprovided by key, this method attempts to generate a cryptographic\nsignature of data. If successful, the returned promise is resolved with\nan <ArrayBuffer> containing the generated signature.

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)`", "name": "unwrapKey", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`format` {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`.", "name": "format", "type": "string", "desc": "Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`." }, { "textRaw": "`wrappedKey` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "wrappedKey", "type": "ArrayBuffer|TypedArray|DataView|Buffer" }, { "textRaw": "`unwrappingKey` {CryptoKey}", "name": "unwrappingKey", "type": "CryptoKey" }, { "name": "unwrapAlgo" }, { "name": "unwrappedKeyAlgo" }, { "name": "extractable" }, { "name": "keyUsages" } ] } ], "desc": "\n\n

In cryptography, \"wrapping a key\" refers to exporting and then encrypting the\nkeying material. This method attempts to decrypt a wrapped\nkey and create a <CryptoKey> instance. It is equivalent to calling subtle.decrypt() first on the encrypted key data (using the wrappedKey,\nunwrapAlgo, and unwrappingKey arguments as input) then passing the results\nto the subtle.importKey() method using the unwrappedKeyAlgo,\nextractable, and keyUsages arguments as inputs. If successful, the returned\npromise is resolved with a <CryptoKey> object.

\n

The wrapping algorithms currently supported include:

\n\n

The unwrapped key algorithms supported include:

\n" }, { "textRaw": "`subtle.verify(algorithm, key, signature, data)`", "name": "verify", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`algorithm` {string|Algorithm|RsaPssParams|EcdsaParams}", "name": "algorithm", "type": "string|Algorithm|RsaPssParams|EcdsaParams" }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" }, { "textRaw": "`signature` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "signature", "type": "ArrayBuffer|TypedArray|DataView|Buffer" }, { "textRaw": "`data` {ArrayBuffer|TypedArray|DataView|Buffer}", "name": "data", "type": "ArrayBuffer|TypedArray|DataView|Buffer" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with a {boolean} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with a {boolean} upon success." } } ], "desc": "

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

\n

The algorithms currently supported include:

\n" }, { "textRaw": "`subtle.wrapKey(format, key, wrappingKey, wrapAlgo)`", "name": "wrapKey", "type": "method", "meta": { "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." } ] }, "signatures": [ { "params": [ { "textRaw": "`format` {string} Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`.", "name": "format", "type": "string", "desc": "Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`, `'raw-public'`, or `'raw-seed'`." }, { "textRaw": "`key` {CryptoKey}", "name": "key", "type": "CryptoKey" }, { "textRaw": "`wrappingKey` {CryptoKey}", "name": "wrappingKey", "type": "CryptoKey" }, { "textRaw": "`wrapAlgo` {string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams}", "name": "wrapAlgo", "type": "string|Algorithm|RsaOaepParams|AesCtrParams|AesCbcParams" } ], "return": { "textRaw": "Returns: {Promise} Fulfills with an {ArrayBuffer} upon success.", "name": "return", "type": "Promise", "desc": "Fulfills with an {ArrayBuffer} upon success." } } ], "desc": "

In cryptography, \"wrapping a key\" refers to exporting and then encrypting the\nkeying material. This method exports the keying material into\nthe format identified by format, then encrypts it using the method and\nparameters specified by wrapAlgo and the keying material provided by\nwrappingKey. It is the equivalent to calling subtle.exportKey() using\nformat and key as the arguments, then passing the result to the\nsubtle.encrypt() method using wrappingKey and wrapAlgo as inputs. If\nsuccessful, the returned promise will be resolved with an <ArrayBuffer>\ncontaining the encrypted key data.

\n

The wrapping algorithms currently supported include:

\n" } ] } ], "displayName": "Web Crypto API" } ] }
X Tutup