%PDF- %PDF-
Direktori : /usr/share/doc/nodejs/api/ |
Current File : //usr/share/doc/nodejs/api/webcrypto.html |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <meta name="nodejs.org:node-version" content="v18.19.1"> <title>Web Crypto API | Node.js v18.19.1 Documentation</title> <link rel="stylesheet" href="assets/style.css"> <link rel="stylesheet" href="assets/hljs.css"> <script async defer src="assets/api.js" type="text/javascript"></script> __JS_FLAVORED_DYNAMIC_CSS__ </head> <body class="alt apidoc" id="api-section-webcrypto"> <div id="content" class="clearfix"> <div id="column2" class="interior"> <div id="intro" class="interior"> <a href="index.html" title="Go back to the home page"> Node.js </a> </div> <ul> <li><a href="documentation.html" class="nav-documentation">About this documentation</a></li> <li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li> </ul> <hr class="line"/> <ul> <li><a href="assert.html" class="nav-assert">Assertion testing</a></li> <li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li> <li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li> <li><a href="buffer.html" class="nav-buffer">Buffer</a></li> <li><a href="addons.html" class="nav-addons">C++ addons</a></li> <li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li> <li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li> <li><a href="child_process.html" class="nav-child_process">Child processes</a></li> <li><a href="cluster.html" class="nav-cluster">Cluster</a></li> <li><a href="cli.html" class="nav-cli">Command-line options</a></li> <li><a href="console.html" class="nav-console">Console</a></li> <li><a href="corepack.html" class="nav-corepack">Corepack</a></li> <li><a href="crypto.html" class="nav-crypto">Crypto</a></li> <li><a href="debugger.html" class="nav-debugger">Debugger</a></li> <li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li> <li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li> <li><a href="dns.html" class="nav-dns">DNS</a></li> <li><a href="domain.html" class="nav-domain">Domain</a></li> <li><a href="errors.html" class="nav-errors">Errors</a></li> <li><a href="events.html" class="nav-events">Events</a></li> <li><a href="fs.html" class="nav-fs">File system</a></li> <li><a href="globals.html" class="nav-globals">Globals</a></li> <li><a href="http.html" class="nav-http">HTTP</a></li> <li><a href="http2.html" class="nav-http2">HTTP/2</a></li> <li><a href="https.html" class="nav-https">HTTPS</a></li> <li><a href="inspector.html" class="nav-inspector">Inspector</a></li> <li><a href="intl.html" class="nav-intl">Internationalization</a></li> <li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li> <li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li> <li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li> <li><a href="packages.html" class="nav-packages">Modules: Packages</a></li> <li><a href="net.html" class="nav-net">Net</a></li> <li><a href="os.html" class="nav-os">OS</a></li> <li><a href="path.html" class="nav-path">Path</a></li> <li><a href="perf_hooks.html" class="nav-perf_hooks">Performance hooks</a></li> <li><a href="permissions.html" class="nav-permissions">Permissions</a></li> <li><a href="process.html" class="nav-process">Process</a></li> <li><a href="punycode.html" class="nav-punycode">Punycode</a></li> <li><a href="querystring.html" class="nav-querystring">Query strings</a></li> <li><a href="readline.html" class="nav-readline">Readline</a></li> <li><a href="repl.html" class="nav-repl">REPL</a></li> <li><a href="report.html" class="nav-report">Report</a></li> <li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li> <li><a href="stream.html" class="nav-stream">Stream</a></li> <li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li> <li><a href="test.html" class="nav-test">Test runner</a></li> <li><a href="timers.html" class="nav-timers">Timers</a></li> <li><a href="tls.html" class="nav-tls">TLS/SSL</a></li> <li><a href="tracing.html" class="nav-tracing">Trace events</a></li> <li><a href="tty.html" class="nav-tty">TTY</a></li> <li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li> <li><a href="url.html" class="nav-url">URL</a></li> <li><a href="util.html" class="nav-util">Utilities</a></li> <li><a href="v8.html" class="nav-v8">V8</a></li> <li><a href="vm.html" class="nav-vm">VM</a></li> <li><a href="wasi.html" class="nav-wasi">WASI</a></li> <li><a href="webcrypto.html" class="nav-webcrypto active">Web Crypto API</a></li> <li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li> <li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li> <li><a href="zlib.html" class="nav-zlib">Zlib</a></li> </ul> <hr class="line"/> <ul> <li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li> </ul> </div> <div id="column1" data-id="webcrypto" class="interior"> <header class="header"> <div class="header-container"> <h1>Node.js v18.19.1 documentation</h1> <button class="theme-toggle-btn" id="theme-toggle-btn" title="Toggle dark mode/light mode" aria-label="Toggle dark mode/light mode" hidden> <svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" height="24" width="24"> <path fill="none" d="M0 0h24v24H0z" /> <path d="M11.1 12.08c-2.33-4.51-.5-8.48.53-10.07C6.27 2.2 1.98 6.59 1.98 12c0 .14.02.28.02.42.62-.27 1.29-.42 2-.42 1.66 0 3.18.83 4.1 2.15A4.01 4.01 0 0111 18c0 1.52-.87 2.83-2.12 3.51.98.32 2.03.5 3.11.5 3.5 0 6.58-1.8 8.37-4.52-2.36.23-6.98-.97-9.26-5.41z"/> <path d="M7 16h-.18C6.4 14.84 5.3 14 4 14c-1.66 0-3 1.34-3 3s1.34 3 3 3h3c1.1 0 2-.9 2-2s-.9-2-2-2z"/> </svg> <svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" height="24" width="24"> <path d="M0 0h24v24H0z" fill="none" /> <path d="M6.76 4.84l-1.8-1.79-1.41 1.41 1.79 1.79 1.42-1.41zM4 10.5H1v2h3v-2zm9-9.95h-2V3.5h2V.55zm7.45 3.91l-1.41-1.41-1.79 1.79 1.41 1.41 1.79-1.79zm-3.21 13.7l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4zM20 10.5v2h3v-2h-3zm-8-5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm-1 16.95h2V19.5h-2v2.95zm-7.45-3.91l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8z"/> </svg> </button> </div> <div id="gtoc"> <ul> <li class="pinned-header">Node.js v18.19.1</li> <li class="picker-header"> <a href="#"> <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> Table of contents </a> <div class="picker"><div class="toc"><ul> <li><a href="#web-crypto-api">Web Crypto API</a><ul> <li><a href="#examples">Examples</a><ul> <li><a href="#generating-keys">Generating keys</a><ul> <li><a href="#aes-keys">AES keys</a></li> <li><a href="#ecdsa-key-pairs">ECDSA key pairs</a></li> <li><a href="#ed25519ed448x25519x448-key-pairs">Ed25519/Ed448/X25519/X448 key pairs</a></li> <li><a href="#hmac-keys">HMAC keys</a></li> <li><a href="#rsa-key-pairs">RSA key pairs</a></li> </ul> </li> <li><a href="#encryption-and-decryption">Encryption and decryption</a></li> <li><a href="#exporting-and-importing-keys">Exporting and importing keys</a></li> <li><a href="#wrapping-and-unwrapping-keys">Wrapping and unwrapping keys</a></li> <li><a href="#sign-and-verify">Sign and verify</a></li> <li><a href="#deriving-bits-and-keys">Deriving bits and keys</a></li> <li><a href="#digest">Digest</a></li> </ul> </li> <li><a href="#algorithm-matrix">Algorithm matrix</a></li> <li><a href="#class-crypto">Class: <code>Crypto</code></a><ul> <li><a href="#cryptosubtle"><code>crypto.subtle</code></a></li> <li><a href="#cryptogetrandomvaluestypedarray"><code>crypto.getRandomValues(typedArray)</code></a></li> <li><a href="#cryptorandomuuid"><code>crypto.randomUUID()</code></a></li> </ul> </li> <li><a href="#class-cryptokey">Class: <code>CryptoKey</code></a><ul> <li><a href="#cryptokeyalgorithm"><code>cryptoKey.algorithm</code></a></li> <li><a href="#cryptokeyextractable"><code>cryptoKey.extractable</code></a></li> <li><a href="#cryptokeytype"><code>cryptoKey.type</code></a></li> <li><a href="#cryptokeyusages"><code>cryptoKey.usages</code></a></li> </ul> </li> <li><a href="#class-cryptokeypair">Class: <code>CryptoKeyPair</code></a><ul> <li><a href="#cryptokeypairprivatekey"><code>cryptoKeyPair.privateKey</code></a></li> <li><a href="#cryptokeypairpublickey"><code>cryptoKeyPair.publicKey</code></a></li> </ul> </li> <li><a href="#class-subtlecrypto">Class: <code>SubtleCrypto</code></a><ul> <li><a href="#subtledecryptalgorithm-key-data"><code>subtle.decrypt(algorithm, key, data)</code></a></li> <li><a href="#subtlederivebitsalgorithm-basekey-length"><code>subtle.deriveBits(algorithm, baseKey, length)</code></a></li> <li><a href="#subtlederivekeyalgorithm-basekey-derivedkeyalgorithm-extractable-keyusages"><code>subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtledigestalgorithm-data"><code>subtle.digest(algorithm, data)</code></a></li> <li><a href="#subtleencryptalgorithm-key-data"><code>subtle.encrypt(algorithm, key, data)</code></a></li> <li><a href="#subtleexportkeyformat-key"><code>subtle.exportKey(format, key)</code></a></li> <li><a href="#subtlegeneratekeyalgorithm-extractable-keyusages"><code>subtle.generateKey(algorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtleimportkeyformat-keydata-algorithm-extractable-keyusages"><code>subtle.importKey(format, keyData, algorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtlesignalgorithm-key-data"><code>subtle.sign(algorithm, key, data)</code></a></li> <li><a href="#subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgo-unwrappedkeyalgo-extractable-keyusages"><code>subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)</code></a></li> <li><a href="#subtleverifyalgorithm-key-signature-data"><code>subtle.verify(algorithm, key, signature, data)</code></a></li> <li><a href="#subtlewrapkeyformat-key-wrappingkey-wrapalgo"><code>subtle.wrapKey(format, key, wrappingKey, wrapAlgo)</code></a></li> </ul> </li> <li><a href="#algorithm-parameters">Algorithm parameters</a><ul> <li><a href="#class-algorithmidentifier">Class: <code>AlgorithmIdentifier</code></a><ul> <li><a href="#algorithmidentifiername"><code>algorithmIdentifier.name</code></a></li> </ul> </li> <li><a href="#class-aescbcparams">Class: <code>AesCbcParams</code></a><ul> <li><a href="#aescbcparamsiv"><code>aesCbcParams.iv</code></a></li> <li><a href="#aescbcparamsname"><code>aesCbcParams.name</code></a></li> </ul> </li> <li><a href="#class-aesctrparams">Class: <code>AesCtrParams</code></a><ul> <li><a href="#aesctrparamscounter"><code>aesCtrParams.counter</code></a></li> <li><a href="#aesctrparamslength"><code>aesCtrParams.length</code></a></li> <li><a href="#aesctrparamsname"><code>aesCtrParams.name</code></a></li> </ul> </li> <li><a href="#class-aesgcmparams">Class: <code>AesGcmParams</code></a><ul> <li><a href="#aesgcmparamsadditionaldata"><code>aesGcmParams.additionalData</code></a></li> <li><a href="#aesgcmparamsiv"><code>aesGcmParams.iv</code></a></li> <li><a href="#aesgcmparamsname"><code>aesGcmParams.name</code></a></li> <li><a href="#aesgcmparamstaglength"><code>aesGcmParams.tagLength</code></a></li> </ul> </li> <li><a href="#class-aeskeygenparams">Class: <code>AesKeyGenParams</code></a><ul> <li><a href="#aeskeygenparamslength"><code>aesKeyGenParams.length</code></a></li> <li><a href="#aeskeygenparamsname"><code>aesKeyGenParams.name</code></a></li> </ul> </li> <li><a href="#class-ecdhkeyderiveparams">Class: <code>EcdhKeyDeriveParams</code></a><ul> <li><a href="#ecdhkeyderiveparamsname"><code>ecdhKeyDeriveParams.name</code></a></li> <li><a href="#ecdhkeyderiveparamspublic"><code>ecdhKeyDeriveParams.public</code></a></li> </ul> </li> <li><a href="#class-ecdsaparams">Class: <code>EcdsaParams</code></a><ul> <li><a href="#ecdsaparamshash"><code>ecdsaParams.hash</code></a></li> <li><a href="#ecdsaparamsname"><code>ecdsaParams.name</code></a></li> </ul> </li> <li><a href="#class-eckeygenparams">Class: <code>EcKeyGenParams</code></a><ul> <li><a href="#eckeygenparamsname"><code>ecKeyGenParams.name</code></a></li> <li><a href="#eckeygenparamsnamedcurve"><code>ecKeyGenParams.namedCurve</code></a></li> </ul> </li> <li><a href="#class-eckeyimportparams">Class: <code>EcKeyImportParams</code></a><ul> <li><a href="#eckeyimportparamsname"><code>ecKeyImportParams.name</code></a></li> <li><a href="#eckeyimportparamsnamedcurve"><code>ecKeyImportParams.namedCurve</code></a></li> </ul> </li> <li><a href="#class-ed448params">Class: <code>Ed448Params</code></a><ul> <li><a href="#ed448paramsname"><code>ed448Params.name</code></a></li> <li><a href="#ed448paramscontext"><code>ed448Params.context</code></a></li> </ul> </li> <li><a href="#class-hkdfparams">Class: <code>HkdfParams</code></a><ul> <li><a href="#hkdfparamshash"><code>hkdfParams.hash</code></a></li> <li><a href="#hkdfparamsinfo"><code>hkdfParams.info</code></a></li> <li><a href="#hkdfparamsname"><code>hkdfParams.name</code></a></li> <li><a href="#hkdfparamssalt"><code>hkdfParams.salt</code></a></li> </ul> </li> <li><a href="#class-hmacimportparams">Class: <code>HmacImportParams</code></a><ul> <li><a href="#hmacimportparamshash"><code>hmacImportParams.hash</code></a></li> <li><a href="#hmacimportparamslength"><code>hmacImportParams.length</code></a></li> <li><a href="#hmacimportparamsname"><code>hmacImportParams.name</code></a></li> </ul> </li> <li><a href="#class-hmackeygenparams">Class: <code>HmacKeyGenParams</code></a><ul> <li><a href="#hmackeygenparamshash"><code>hmacKeyGenParams.hash</code></a></li> <li><a href="#hmackeygenparamslength"><code>hmacKeyGenParams.length</code></a></li> <li><a href="#hmackeygenparamsname"><code>hmacKeyGenParams.name</code></a></li> </ul> </li> <li><a href="#class-pbkdf2params">Class: <code>Pbkdf2Params</code></a><ul> <li><a href="#pbkdb2paramshash"><code>pbkdb2Params.hash</code></a></li> <li><a href="#pbkdf2paramsiterations"><code>pbkdf2Params.iterations</code></a></li> <li><a href="#pbkdf2paramsname"><code>pbkdf2Params.name</code></a></li> <li><a href="#pbkdf2paramssalt"><code>pbkdf2Params.salt</code></a></li> </ul> </li> <li><a href="#class-rsahashedimportparams">Class: <code>RsaHashedImportParams</code></a><ul> <li><a href="#rsahashedimportparamshash"><code>rsaHashedImportParams.hash</code></a></li> <li><a href="#rsahashedimportparamsname"><code>rsaHashedImportParams.name</code></a></li> </ul> </li> <li><a href="#class-rsahashedkeygenparams">Class: <code>RsaHashedKeyGenParams</code></a><ul> <li><a href="#rsahashedkeygenparamshash"><code>rsaHashedKeyGenParams.hash</code></a></li> <li><a href="#rsahashedkeygenparamsmoduluslength"><code>rsaHashedKeyGenParams.modulusLength</code></a></li> <li><a href="#rsahashedkeygenparamsname"><code>rsaHashedKeyGenParams.name</code></a></li> <li><a href="#rsahashedkeygenparamspublicexponent"><code>rsaHashedKeyGenParams.publicExponent</code></a></li> </ul> </li> <li><a href="#class-rsaoaepparams">Class: <code>RsaOaepParams</code></a><ul> <li><a href="#rsaoaepparamslabel"><code>rsaOaepParams.label</code></a></li> <li><a href="#rsaoaepparamsname"><code>rsaOaepParams.name</code></a></li> </ul> </li> <li><a href="#class-rsapssparams">Class: <code>RsaPssParams</code></a><ul> <li><a href="#rsapssparamsname"><code>rsaPssParams.name</code></a></li> <li><a href="#rsapssparamssaltlength"><code>rsaPssParams.saltLength</code></a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </div></div> </li> <li class="picker-header"> <a href="#"> <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> Index </a> <div class="picker"><ul> <li><a href="documentation.html" class="nav-documentation">About this documentation</a></li> <li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li> <li> <a href="index.html">Index</a> </li> </ul> <hr class="line"/> <ul> <li><a href="assert.html" class="nav-assert">Assertion testing</a></li> <li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li> <li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li> <li><a href="buffer.html" class="nav-buffer">Buffer</a></li> <li><a href="addons.html" class="nav-addons">C++ addons</a></li> <li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li> <li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li> <li><a href="child_process.html" class="nav-child_process">Child processes</a></li> <li><a href="cluster.html" class="nav-cluster">Cluster</a></li> <li><a href="cli.html" class="nav-cli">Command-line options</a></li> <li><a href="console.html" class="nav-console">Console</a></li> <li><a href="corepack.html" class="nav-corepack">Corepack</a></li> <li><a href="crypto.html" class="nav-crypto">Crypto</a></li> <li><a href="debugger.html" class="nav-debugger">Debugger</a></li> <li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li> <li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li> <li><a href="dns.html" class="nav-dns">DNS</a></li> <li><a href="domain.html" class="nav-domain">Domain</a></li> <li><a href="errors.html" class="nav-errors">Errors</a></li> <li><a href="events.html" class="nav-events">Events</a></li> <li><a href="fs.html" class="nav-fs">File system</a></li> <li><a href="globals.html" class="nav-globals">Globals</a></li> <li><a href="http.html" class="nav-http">HTTP</a></li> <li><a href="http2.html" class="nav-http2">HTTP/2</a></li> <li><a href="https.html" class="nav-https">HTTPS</a></li> <li><a href="inspector.html" class="nav-inspector">Inspector</a></li> <li><a href="intl.html" class="nav-intl">Internationalization</a></li> <li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li> <li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li> <li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li> <li><a href="packages.html" class="nav-packages">Modules: Packages</a></li> <li><a href="net.html" class="nav-net">Net</a></li> <li><a href="os.html" class="nav-os">OS</a></li> <li><a href="path.html" class="nav-path">Path</a></li> <li><a href="perf_hooks.html" class="nav-perf_hooks">Performance hooks</a></li> <li><a href="permissions.html" class="nav-permissions">Permissions</a></li> <li><a href="process.html" class="nav-process">Process</a></li> <li><a href="punycode.html" class="nav-punycode">Punycode</a></li> <li><a href="querystring.html" class="nav-querystring">Query strings</a></li> <li><a href="readline.html" class="nav-readline">Readline</a></li> <li><a href="repl.html" class="nav-repl">REPL</a></li> <li><a href="report.html" class="nav-report">Report</a></li> <li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li> <li><a href="stream.html" class="nav-stream">Stream</a></li> <li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li> <li><a href="test.html" class="nav-test">Test runner</a></li> <li><a href="timers.html" class="nav-timers">Timers</a></li> <li><a href="tls.html" class="nav-tls">TLS/SSL</a></li> <li><a href="tracing.html" class="nav-tracing">Trace events</a></li> <li><a href="tty.html" class="nav-tty">TTY</a></li> <li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li> <li><a href="url.html" class="nav-url">URL</a></li> <li><a href="util.html" class="nav-util">Utilities</a></li> <li><a href="v8.html" class="nav-v8">V8</a></li> <li><a href="vm.html" class="nav-vm">VM</a></li> <li><a href="wasi.html" class="nav-wasi">WASI</a></li> <li><a href="webcrypto.html" class="nav-webcrypto active">Web Crypto API</a></li> <li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li> <li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li> <li><a href="zlib.html" class="nav-zlib">Zlib</a></li> </ul> <hr class="line"/> <ul> <li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li> </ul> </div> </li> <li class="picker-header"> <a href="#"> <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> Other versions </a> <div class="picker"><ol id="alt-docs"><li><a href="https://nodejs.org/docs/latest-v18.x/api/webcrypto.html">18.x <b>LTS</b></a></li> <li><a href="https://nodejs.org/docs/latest-v17.x/api/webcrypto.html">17.x</a></li> <li><a href="https://nodejs.org/docs/latest-v16.x/api/webcrypto.html">16.x <b>LTS</b></a></li> <li><a href="https://nodejs.org/docs/latest-v15.x/api/webcrypto.html">15.x</a></li></ol></div> </li> <li class="picker-header"> <a href="#"> <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> Options </a> <div class="picker"> <ul> <li> <a href="all.html">View on single page</a> </li> <li> <a href="webcrypto.json">View as JSON</a> </li> <li class="edit_on_github"><a href="https://github.com/nodejs/node/edit/master/doc/api/webcrypto.md">Edit on GitHub</a></li> </ul> </div> </li> </ul> </div> <hr> </header> <details id="toc" open><summary>Table of contents</summary><ul> <li><a href="#web-crypto-api">Web Crypto API</a><ul> <li><a href="#examples">Examples</a><ul> <li><a href="#generating-keys">Generating keys</a><ul> <li><a href="#aes-keys">AES keys</a></li> <li><a href="#ecdsa-key-pairs">ECDSA key pairs</a></li> <li><a href="#ed25519ed448x25519x448-key-pairs">Ed25519/Ed448/X25519/X448 key pairs</a></li> <li><a href="#hmac-keys">HMAC keys</a></li> <li><a href="#rsa-key-pairs">RSA key pairs</a></li> </ul> </li> <li><a href="#encryption-and-decryption">Encryption and decryption</a></li> <li><a href="#exporting-and-importing-keys">Exporting and importing keys</a></li> <li><a href="#wrapping-and-unwrapping-keys">Wrapping and unwrapping keys</a></li> <li><a href="#sign-and-verify">Sign and verify</a></li> <li><a href="#deriving-bits-and-keys">Deriving bits and keys</a></li> <li><a href="#digest">Digest</a></li> </ul> </li> <li><a href="#algorithm-matrix">Algorithm matrix</a></li> <li><a href="#class-crypto">Class: <code>Crypto</code></a><ul> <li><a href="#cryptosubtle"><code>crypto.subtle</code></a></li> <li><a href="#cryptogetrandomvaluestypedarray"><code>crypto.getRandomValues(typedArray)</code></a></li> <li><a href="#cryptorandomuuid"><code>crypto.randomUUID()</code></a></li> </ul> </li> <li><a href="#class-cryptokey">Class: <code>CryptoKey</code></a><ul> <li><a href="#cryptokeyalgorithm"><code>cryptoKey.algorithm</code></a></li> <li><a href="#cryptokeyextractable"><code>cryptoKey.extractable</code></a></li> <li><a href="#cryptokeytype"><code>cryptoKey.type</code></a></li> <li><a href="#cryptokeyusages"><code>cryptoKey.usages</code></a></li> </ul> </li> <li><a href="#class-cryptokeypair">Class: <code>CryptoKeyPair</code></a><ul> <li><a href="#cryptokeypairprivatekey"><code>cryptoKeyPair.privateKey</code></a></li> <li><a href="#cryptokeypairpublickey"><code>cryptoKeyPair.publicKey</code></a></li> </ul> </li> <li><a href="#class-subtlecrypto">Class: <code>SubtleCrypto</code></a><ul> <li><a href="#subtledecryptalgorithm-key-data"><code>subtle.decrypt(algorithm, key, data)</code></a></li> <li><a href="#subtlederivebitsalgorithm-basekey-length"><code>subtle.deriveBits(algorithm, baseKey, length)</code></a></li> <li><a href="#subtlederivekeyalgorithm-basekey-derivedkeyalgorithm-extractable-keyusages"><code>subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtledigestalgorithm-data"><code>subtle.digest(algorithm, data)</code></a></li> <li><a href="#subtleencryptalgorithm-key-data"><code>subtle.encrypt(algorithm, key, data)</code></a></li> <li><a href="#subtleexportkeyformat-key"><code>subtle.exportKey(format, key)</code></a></li> <li><a href="#subtlegeneratekeyalgorithm-extractable-keyusages"><code>subtle.generateKey(algorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtleimportkeyformat-keydata-algorithm-extractable-keyusages"><code>subtle.importKey(format, keyData, algorithm, extractable, keyUsages)</code></a></li> <li><a href="#subtlesignalgorithm-key-data"><code>subtle.sign(algorithm, key, data)</code></a></li> <li><a href="#subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgo-unwrappedkeyalgo-extractable-keyusages"><code>subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)</code></a></li> <li><a href="#subtleverifyalgorithm-key-signature-data"><code>subtle.verify(algorithm, key, signature, data)</code></a></li> <li><a href="#subtlewrapkeyformat-key-wrappingkey-wrapalgo"><code>subtle.wrapKey(format, key, wrappingKey, wrapAlgo)</code></a></li> </ul> </li> <li><a href="#algorithm-parameters">Algorithm parameters</a><ul> <li><a href="#class-algorithmidentifier">Class: <code>AlgorithmIdentifier</code></a><ul> <li><a href="#algorithmidentifiername"><code>algorithmIdentifier.name</code></a></li> </ul> </li> <li><a href="#class-aescbcparams">Class: <code>AesCbcParams</code></a><ul> <li><a href="#aescbcparamsiv"><code>aesCbcParams.iv</code></a></li> <li><a href="#aescbcparamsname"><code>aesCbcParams.name</code></a></li> </ul> </li> <li><a href="#class-aesctrparams">Class: <code>AesCtrParams</code></a><ul> <li><a href="#aesctrparamscounter"><code>aesCtrParams.counter</code></a></li> <li><a href="#aesctrparamslength"><code>aesCtrParams.length</code></a></li> <li><a href="#aesctrparamsname"><code>aesCtrParams.name</code></a></li> </ul> </li> <li><a href="#class-aesgcmparams">Class: <code>AesGcmParams</code></a><ul> <li><a href="#aesgcmparamsadditionaldata"><code>aesGcmParams.additionalData</code></a></li> <li><a href="#aesgcmparamsiv"><code>aesGcmParams.iv</code></a></li> <li><a href="#aesgcmparamsname"><code>aesGcmParams.name</code></a></li> <li><a href="#aesgcmparamstaglength"><code>aesGcmParams.tagLength</code></a></li> </ul> </li> <li><a href="#class-aeskeygenparams">Class: <code>AesKeyGenParams</code></a><ul> <li><a href="#aeskeygenparamslength"><code>aesKeyGenParams.length</code></a></li> <li><a href="#aeskeygenparamsname"><code>aesKeyGenParams.name</code></a></li> </ul> </li> <li><a href="#class-ecdhkeyderiveparams">Class: <code>EcdhKeyDeriveParams</code></a><ul> <li><a href="#ecdhkeyderiveparamsname"><code>ecdhKeyDeriveParams.name</code></a></li> <li><a href="#ecdhkeyderiveparamspublic"><code>ecdhKeyDeriveParams.public</code></a></li> </ul> </li> <li><a href="#class-ecdsaparams">Class: <code>EcdsaParams</code></a><ul> <li><a href="#ecdsaparamshash"><code>ecdsaParams.hash</code></a></li> <li><a href="#ecdsaparamsname"><code>ecdsaParams.name</code></a></li> </ul> </li> <li><a href="#class-eckeygenparams">Class: <code>EcKeyGenParams</code></a><ul> <li><a href="#eckeygenparamsname"><code>ecKeyGenParams.name</code></a></li> <li><a href="#eckeygenparamsnamedcurve"><code>ecKeyGenParams.namedCurve</code></a></li> </ul> </li> <li><a href="#class-eckeyimportparams">Class: <code>EcKeyImportParams</code></a><ul> <li><a href="#eckeyimportparamsname"><code>ecKeyImportParams.name</code></a></li> <li><a href="#eckeyimportparamsnamedcurve"><code>ecKeyImportParams.namedCurve</code></a></li> </ul> </li> <li><a href="#class-ed448params">Class: <code>Ed448Params</code></a><ul> <li><a href="#ed448paramsname"><code>ed448Params.name</code></a></li> <li><a href="#ed448paramscontext"><code>ed448Params.context</code></a></li> </ul> </li> <li><a href="#class-hkdfparams">Class: <code>HkdfParams</code></a><ul> <li><a href="#hkdfparamshash"><code>hkdfParams.hash</code></a></li> <li><a href="#hkdfparamsinfo"><code>hkdfParams.info</code></a></li> <li><a href="#hkdfparamsname"><code>hkdfParams.name</code></a></li> <li><a href="#hkdfparamssalt"><code>hkdfParams.salt</code></a></li> </ul> </li> <li><a href="#class-hmacimportparams">Class: <code>HmacImportParams</code></a><ul> <li><a href="#hmacimportparamshash"><code>hmacImportParams.hash</code></a></li> <li><a href="#hmacimportparamslength"><code>hmacImportParams.length</code></a></li> <li><a href="#hmacimportparamsname"><code>hmacImportParams.name</code></a></li> </ul> </li> <li><a href="#class-hmackeygenparams">Class: <code>HmacKeyGenParams</code></a><ul> <li><a href="#hmackeygenparamshash"><code>hmacKeyGenParams.hash</code></a></li> <li><a href="#hmackeygenparamslength"><code>hmacKeyGenParams.length</code></a></li> <li><a href="#hmackeygenparamsname"><code>hmacKeyGenParams.name</code></a></li> </ul> </li> <li><a href="#class-pbkdf2params">Class: <code>Pbkdf2Params</code></a><ul> <li><a href="#pbkdb2paramshash"><code>pbkdb2Params.hash</code></a></li> <li><a href="#pbkdf2paramsiterations"><code>pbkdf2Params.iterations</code></a></li> <li><a href="#pbkdf2paramsname"><code>pbkdf2Params.name</code></a></li> <li><a href="#pbkdf2paramssalt"><code>pbkdf2Params.salt</code></a></li> </ul> </li> <li><a href="#class-rsahashedimportparams">Class: <code>RsaHashedImportParams</code></a><ul> <li><a href="#rsahashedimportparamshash"><code>rsaHashedImportParams.hash</code></a></li> <li><a href="#rsahashedimportparamsname"><code>rsaHashedImportParams.name</code></a></li> </ul> </li> <li><a href="#class-rsahashedkeygenparams">Class: <code>RsaHashedKeyGenParams</code></a><ul> <li><a href="#rsahashedkeygenparamshash"><code>rsaHashedKeyGenParams.hash</code></a></li> <li><a href="#rsahashedkeygenparamsmoduluslength"><code>rsaHashedKeyGenParams.modulusLength</code></a></li> <li><a href="#rsahashedkeygenparamsname"><code>rsaHashedKeyGenParams.name</code></a></li> <li><a href="#rsahashedkeygenparamspublicexponent"><code>rsaHashedKeyGenParams.publicExponent</code></a></li> </ul> </li> <li><a href="#class-rsaoaepparams">Class: <code>RsaOaepParams</code></a><ul> <li><a href="#rsaoaepparamslabel"><code>rsaOaepParams.label</code></a></li> <li><a href="#rsaoaepparamsname"><code>rsaOaepParams.name</code></a></li> </ul> </li> <li><a href="#class-rsapssparams">Class: <code>RsaPssParams</code></a><ul> <li><a href="#rsapssparamsname"><code>rsaPssParams.name</code></a></li> <li><a href="#rsapssparamssaltlength"><code>rsaPssParams.saltLength</code></a></li> </ul> </li> </ul> </li> </ul> </li> </ul> </details> <div id="apicontent"> <h2>Web Crypto API<span><a class="mark" href="#web-crypto-api" id="web-crypto-api">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_web_crypto_api"></a></h2> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.17.0</td> <td><p>Arguments are now coerced and validated as per their WebIDL definitions like in other Web Crypto API implementations.</p> </td></tr> <tr><td>v18.4.0</td> <td><p>Removed proprietary <code>'node.keyObject'</code> import/export format.</p> </td></tr> <tr><td>v18.4.0</td> <td><p>Removed proprietary <code>'NODE-DSA'</code>, <code>'NODE-DH'</code>, and <code>'NODE-SCRYPT'</code> algorithms.</p> </td></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'Ed25519'</code>, <code>'Ed448'</code>, <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> </td></tr> <tr><td>v18.4.0</td> <td><p>Removed proprietary <code>'NODE-ED25519'</code> and <code>'NODE-ED448'</code> algorithms.</p> </td></tr> <tr><td>v18.4.0</td> <td><p>Removed proprietary <code>'NODE-X25519'</code> and <code>'NODE-X448'</code> named curves from the <code>'ECDH'</code> algorithm.</p> </td></tr> </table> </details> </div><!-- introduced_in=v15.0.0 --> <blockquote> <p>Stability: 1 - Experimental</p> </blockquote> <p>Node.js provides an implementation of the standard <a href="https://www.w3.org/TR/WebCryptoAPI/">Web Crypto API</a>.</p> <p>Use <code>require('node:crypto').webcrypto</code> to access this module.</p> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; (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); })(); </code></pre> <section><h3>Examples<span><a class="mark" href="#examples" id="examples">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_examples"></a></h3> <h4>Generating keys<span><a class="mark" href="#generating-keys" id="generating-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_generating_keys"></a></h4> <p>The <a href="webcrypto.html#class-subtlecrypto" class="type"><SubtleCrypto></a> class can be used to generate symmetric (secret) keys or asymmetric key pairs (public key and private key).</p> <h5>AES keys<span><a class="mark" href="#aes-keys" id="aes-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aes_keys"></a></h5> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; async function generateAesKey(length = 256) { const key = await subtle.generateKey({ name: 'AES-CBC', length, }, true, ['encrypt', 'decrypt']); return key; } </code></pre> <h5>ECDSA key pairs<span><a class="mark" href="#ecdsa-key-pairs" id="ecdsa-key-pairs">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ecdsa_key_pairs"></a></h5> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; async function generateEcKey(namedCurve = 'P-521') { const { publicKey, privateKey, } = await subtle.generateKey({ name: 'ECDSA', namedCurve, }, true, ['sign', 'verify']); return { publicKey, privateKey }; } </code></pre> <h5>Ed25519/Ed448/X25519/X448 key pairs<span><a class="mark" href="#ed25519ed448x25519x448-key-pairs" id="ed25519ed448x25519x448-key-pairs">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ed25519_ed448_x25519_x448_key_pairs"></a></h5> <blockquote> <p>Stability: 1 - Experimental</p> </blockquote> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; async function generateEd25519Key() { return subtle.generateKey({ name: 'Ed25519', }, true, ['sign', 'verify']); } async function generateX25519Key() { return subtle.generateKey({ name: 'X25519', }, true, ['deriveKey']); } </code></pre> <h5>HMAC keys<span><a class="mark" href="#hmac-keys" id="hmac-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmac_keys"></a></h5> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; async function generateHmacKey(hash = 'SHA-256') { const key = await subtle.generateKey({ name: 'HMAC', hash, }, true, ['sign', 'verify']); return key; } </code></pre> <h5>RSA key pairs<span><a class="mark" href="#rsa-key-pairs" id="rsa-key-pairs">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsa_key_pairs"></a></h5> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; 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 }; } </code></pre> <h4>Encryption and decryption<span><a class="mark" href="#encryption-and-decryption" id="encryption-and-decryption">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_encryption_and_decryption"></a></h4> <pre><code class="language-js">const crypto = require('node:crypto').webcrypto; 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); } </code></pre> <h4>Exporting and importing keys<span><a class="mark" href="#exporting-and-importing-keys" id="exporting-and-importing-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_exporting_and_importing_keys"></a></h4> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; 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; } </code></pre> <h4>Wrapping and unwrapping keys<span><a class="mark" href="#wrapping-and-unwrapping-keys" id="wrapping-and-unwrapping-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_wrapping_and_unwrapping_keys"></a></h4> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; 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; } </code></pre> <h4>Sign and verify<span><a class="mark" href="#sign-and-verify" id="sign-and-verify">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_sign_and_verify"></a></h4> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; 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; } </code></pre> <h4>Deriving bits and keys<span><a class="mark" href="#deriving-bits-and-keys" id="deriving-bits-and-keys">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_deriving_bits_and_keys"></a></h4> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; 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: 256, }, true, ['encrypt', 'decrypt']); return key; } </code></pre> <h4>Digest<span><a class="mark" href="#digest" id="digest">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_digest"></a></h4> <pre><code class="language-js">const { subtle } = require('node:crypto').webcrypto; async function digest(data, algorithm = 'SHA-512') { const ec = new TextEncoder(); const digest = await subtle.digest(algorithm, ec.encode(data)); return digest; } </code></pre> </section><section><h3>Algorithm matrix<span><a class="mark" href="#algorithm-matrix" id="algorithm-matrix">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_algorithm_matrix"></a></h3> <p>The table details the algorithms supported by the Node.js Web Crypto API implementation and the APIs supported for each:</p> <table> <thead> <tr> <th>Algorithm</th> <th><code>generateKey</code></th> <th><code>exportKey</code></th> <th><code>importKey</code></th> <th><code>encrypt</code></th> <th><code>decrypt</code></th> <th><code>wrapKey</code></th> <th><code>unwrapKey</code></th> <th><code>deriveBits</code></th> <th><code>deriveKey</code></th> <th><code>sign</code></th> <th><code>verify</code></th> <th><code>digest</code></th> </tr> </thead> <tbody><tr> <td><code>'RSASSA-PKCS1-v1_5'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSA-PSS'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSA-OAEP'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'ECDSA'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'ECDH'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'X448'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'AES-CTR'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'AES-CBC'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'AES-GCM'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'AES-KW'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'HMAC'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'HKDF'</code></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'PBKDF2'</code></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'SHA-1'</code></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> <tr> <td><code>'SHA-256'</code></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> <tr> <td><code>'SHA-384'</code></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> <tr> <td><code>'SHA-512'</code></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> </tbody></table> </section><section><h3>Class: <code>Crypto</code><span><a class="mark" href="#class-crypto" id="class-crypto">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_crypto"></a></h3> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><p>Calling <code>require('node:crypto').webcrypto</code> returns an instance of the <code>Crypto</code> class. <code>Crypto</code> is a singleton that provides access to the remainder of the crypto API.</p> <h4><code>crypto.subtle</code><span><a class="mark" href="#cryptosubtle" id="cryptosubtle">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_crypto_subtle"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="webcrypto.html#class-subtlecrypto" class="type"><SubtleCrypto></a></li> </ul> <p>Provides access to the <code>SubtleCrypto</code> API.</p> <h4><code>crypto.getRandomValues(typedArray)</code><span><a class="mark" href="#cryptogetrandomvaluestypedarray" id="cryptogetrandomvaluestypedarray">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_crypto_getrandomvalues_typedarray"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li><code>typedArray</code> {Buffer|TypedArray}</li> <li>Returns: {Buffer|TypedArray}</li> </ul> <p>Generates cryptographically strong random values. The given <code>typedArray</code> is filled with random values, and a reference to <code>typedArray</code> is returned.</p> <p>The given <code>typedArray</code> must be an integer-based instance of <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray" class="type"><TypedArray></a>, i.e. <code>Float32Array</code> and <code>Float64Array</code> are not accepted.</p> <p>An error will be thrown if the given <code>typedArray</code> is larger than 65,536 bytes.</p> <h4><code>crypto.randomUUID()</code><span><a class="mark" href="#cryptorandomuuid" id="cryptorandomuuid">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_crypto_randomuuid"></a></h4> <div class="api_metadata"> <span>Added in: v16.7.0</span> </div><ul> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> </ul> <p>Generates a random <a href="https://www.rfc-editor.org/rfc/rfc4122.txt">RFC 4122</a> version 4 UUID. The UUID is generated using a cryptographic pseudorandom number generator.</p> </section><section><h3>Class: <code>CryptoKey</code><span><a class="mark" href="#class-cryptokey" id="class-cryptokey">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_cryptokey"></a></h3> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h4><code>cryptoKey.algorithm</code><span><a class="mark" href="#cryptokeyalgorithm" id="cryptokeyalgorithm">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokey_algorithm"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li>Type: {AesKeyGenParams|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams}</li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.</p> <p>Read-only.</p> <h4><code>cryptoKey.extractable</code><span><a class="mark" href="#cryptokeyextractable" id="cryptokeyextractable">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokey_extractable"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> </ul> <p>When <code>true</code>, the <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> can be extracted using either <code>subtleCrypto.exportKey()</code> or <code>subtleCrypto.wrapKey()</code>.</p> <p>Read-only.</p> <h4><code>cryptoKey.type</code><span><a class="mark" href="#cryptokeytype" id="cryptokeytype">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokey_type"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> One of <code>'secret'</code>, <code>'private'</code>, or <code>'public'</code>.</li> </ul> <p>A string identifying whether the key is a symmetric (<code>'secret'</code>) or asymmetric (<code>'private'</code> or <code>'public'</code>) key.</p> <h4><code>cryptoKey.usages</code><span><a class="mark" href="#cryptokeyusages" id="cryptokeyusages">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokey_usages"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a></li> </ul> <p>An array of strings identifying the operations for which the key may be used.</p> <p>The possible usages are:</p> <ul> <li><code>'encrypt'</code> - The key may be used to encrypt data.</li> <li><code>'decrypt'</code> - The key may be used to decrypt data.</li> <li><code>'sign'</code> - The key may be used to generate digital signatures.</li> <li><code>'verify'</code> - The key may be used to verify digital signatures.</li> <li><code>'deriveKey'</code> - The key may be used to derive a new key.</li> <li><code>'deriveBits'</code> - The key may be used to derive bits.</li> <li><code>'wrapKey'</code> - The key may be used to wrap another key.</li> <li><code>'unwrapKey'</code> - The key may be used to unwrap another key.</li> </ul> <p>Valid key usages depend on the key algorithm (identified by <code>cryptokey.algorithm.name</code>).</p> <table> <thead> <tr> <th>Key Type</th> <th><code>'encrypt'</code></th> <th><code>'decrypt'</code></th> <th><code>'sign'</code></th> <th><code>'verify'</code></th> <th><code>'deriveKey'</code></th> <th><code>'deriveBits'</code></th> <th><code>'wrapKey'</code></th> <th><code>'unwrapKey'</code></th> </tr> </thead> <tbody><tr> <td><code>'AES-CBC'</code></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-CTR'</code></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-GCM'</code></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-KW'</code></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'ECDH'</code></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> </tr> <tr> <td><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> </tr> <tr> <td><code>'X448'</code> <span class="experimental-inline"></span>[^1]</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> </tr> <tr> <td><code>'ECDSA'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'HDKF'</code></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> </tr> <tr> <td><code>'HMAC'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'PBKDF2'</code></td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> </tr> <tr> <td><code>'RSA-OAEP'</code></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'RSA-PSS'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'RSASSA-PKCS1-v1_5'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody></table> </section><section><h3>Class: <code>CryptoKeyPair</code><span><a class="mark" href="#class-cryptokeypair" id="class-cryptokeypair">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_cryptokeypair"></a></h3> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><p>The <code>CryptoKeyPair</code> is a simple dictionary object with <code>publicKey</code> and <code>privateKey</code> properties, representing an asymmetric key pair.</p> <h4><code>cryptoKeyPair.privateKey</code><span><a class="mark" href="#cryptokeypairprivatekey" id="cryptokeypairprivatekey">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokeypair_privatekey"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> A <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> whose <code>type</code> will be <code>'private'</code>.</li> </ul> <h4><code>cryptoKeyPair.publicKey</code><span><a class="mark" href="#cryptokeypairpublickey" id="cryptokeypairpublickey">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_cryptokeypair_publickey"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> A <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> whose <code>type</code> will be <code>'public'</code>.</li> </ul> </section><section><h3>Class: <code>SubtleCrypto</code><span><a class="mark" href="#class-subtlecrypto" id="class-subtlecrypto">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_subtlecrypto"></a></h3> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h4><code>subtle.decrypt(algorithm, key, data)</code><span><a class="mark" href="#subtledecryptalgorithm-key-data" id="subtledecryptalgorithm-key-data">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_decrypt_algorithm_key_data"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li><code>algorithm</code>: {RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>data</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <p>Using the method and parameters specified in <code>algorithm</code> and the keying material provided by <code>key</code>, <code>subtle.decrypt()</code> attempts to decipher the provided <code>data</code>. If successful, the returned promise will be resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the plaintext result.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'RSA-OAEP'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM</code>'</li> </ul> <h4><code>subtle.deriveBits(algorithm, baseKey, length)</code><span><a class="mark" href="#subtlederivebitsalgorithm-basekey-length" id="subtlederivebitsalgorithm-basekey-length">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_derivebits_algorithm_basekey_length"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params}</li> <li><code>baseKey</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>length</code>: {number|null}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>Using the method and parameters specified in <code>algorithm</code> and the keying material provided by <code>baseKey</code>, <code>subtle.deriveBits()</code> attempts to generate <code>length</code> bits.</p> <p>The Node.js implementation requires that when <code>length</code> is a number it must be multiple of <code>8</code>.</p> <p>When <code>length</code> is <code>null</code> the maximum number of bits for a given algorithm is generated. This is allowed for the <code>'ECDH'</code>, <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> <p>If successful, the returned promise will be resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the generated data.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'ECDH'</code></li> <li><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'X448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'HKDF'</code></li> <li><code>'PBKDF2'</code></li> </ul> <h4><code>subtle.deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages)</code><span><a class="mark" href="#subtlederivekeyalgorithm-basekey-derivedkeyalgorithm-extractable-keyusages" id="subtlederivekeyalgorithm-basekey-derivedkeyalgorithm-extractable-keyusages">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_derivekey_algorithm_basekey_derivedkeyalgorithm_extractable_keyusages"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|EcdhKeyDeriveParams|HkdfParams|Pbkdf2Params}</li> <li><code>baseKey</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>derivedKeyAlgorithm</code>: {HmacKeyGenParams|AesKeyGenParams}</li> <li><code>extractable</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> <li><code>keyUsages</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a> See <a href="#cryptokeyusages">Key usages</a>.</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>Using the method and parameters specified in <code>algorithm</code>, and the keying material provided by <code>baseKey</code>, <code>subtle.deriveKey()</code> attempts to generate a new <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> based on the method and parameters in <code>derivedKeyAlgorithm</code>.</p> <p>Calling <code>subtle.deriveKey()</code> is equivalent to calling <code>subtle.deriveBits()</code> to generate raw keying material, then passing the result into the <code>subtle.importKey()</code> method using the <code>deriveKeyAlgorithm</code>, <code>extractable</code>, and <code>keyUsages</code> parameters as input.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'ECDH'</code></li> <li><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'X448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'HKDF'</code></li> <li><code>'PBKDF2'</code></li> </ul> <h4><code>subtle.digest(algorithm, data)</code><span><a class="mark" href="#subtledigestalgorithm-data" id="subtledigestalgorithm-data">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_digest_algorithm_data"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li><code>algorithm</code>: {string|Object}</li> <li><code>data</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <p>Using the method identified by <code>algorithm</code>, <code>subtle.digest()</code> attempts to generate a digest of <code>data</code>. If successful, the returned promise is resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the computed digest.</p> <p>If <code>algorithm</code> is provided as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, it must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If <code>algorithm</code> is provided as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, it must have a <code>name</code> property whose value is one of the above.</p> <h4><code>subtle.encrypt(algorithm, key, data)</code><span><a class="mark" href="#subtleencryptalgorithm-key-data" id="subtleencryptalgorithm-key-data">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_encrypt_algorithm_key_data"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li><code>algorithm</code>: {RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <p>Using the method and parameters specified by <code>algorithm</code> and the keying material provided by <code>key</code>, <code>subtle.encrypt()</code> attempts to encipher <code>data</code>. If successful, the returned promise is resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the encrypted result.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'RSA-OAEP'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM</code>'</li> </ul> <h4><code>subtle.exportKey(format, key)</code><span><a class="mark" href="#subtleexportkeyformat-key" id="subtleexportkeyformat-key">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_exportkey_format_key"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'Ed25519'</code>, <code>'Ed448'</code>, <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> </td></tr> <tr><td>v15.9.0</td> <td><p>Removed <code>'NODE-DSA'</code> JWK export.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><ul> <li><code>format</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'raw'</code>, <code>'pkcs8'</code>, <code>'spki'</code>, or <code>'jwk'</code>.</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing {ArrayBuffer|Object}.</li> </ul> <p>Exports the given key into the specified format, if supported.</p> <p>If the <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> is not extractable, the returned promise will reject.</p> <p>When <code>format</code> is either <code>'pkcs8'</code> or <code>'spki'</code> and the export is successful, the returned promise will be resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the exported key data.</p> <p>When <code>format</code> is <code>'jwk'</code> and the export is successful, the returned promise will be resolved with a JavaScript object conforming to the <a href="https://tools.ietf.org/html/rfc7517">JSON Web Key</a> specification.</p> <table> <thead> <tr> <th>Key Type</th> <th><code>'spki'</code></th> <th><code>'pkcs8'</code></th> <th><code>'jwk'</code></th> <th><code>'raw'</code></th> </tr> </thead> <tbody><tr> <td><code>'AES-CBC'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-CTR'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-GCM'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-KW'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'ECDH'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'ECDSA'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'HDKF'</code></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'HMAC'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'PBKDF2'</code></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><code>'RSA-OAEP'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSA-PSS'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSASSA-PKCS1-v1_5'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> </tbody></table> <h4><code>subtle.generateKey(algorithm, extractable, keyUsages)</code><span><a class="mark" href="#subtlegeneratekeyalgorithm-extractable-keyusages" id="subtlegeneratekeyalgorithm-extractable-keyusages">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_generatekey_algorithm_extractable_keyusages"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|RsaHashedKeyGenParams|EcKeyGenParams|HmacKeyGenParams|AesKeyGenParams}</li> </ul> <!--lint enable maximum-line-length remark-lint--> <ul> <li><code>extractable</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> <li><code>keyUsages</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a> See <a href="#cryptokeyusages">Key usages</a>.</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing {CryptoKey|CryptoKeyPair}</li> </ul> <p>Using the method and parameters provided in <code>algorithm</code>, <code>subtle.generateKey()</code> attempts to generate new keying material. Depending the method used, the method may generate either a single <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> or a <a href="webcrypto.html#class-cryptokeypair" class="type"><CryptoKeyPair></a>.</p> <p>The <a href="webcrypto.html#class-cryptokeypair" class="type"><CryptoKeyPair></a> (public and private key) generating algorithms supported include:</p> <ul> <li><code>'RSASSA-PKCS1-v1_5'</code></li> <li><code>'RSA-PSS'</code></li> <li><code>'RSA-OAEP'</code></li> <li><code>'ECDSA'</code></li> <li><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'ECDH'</code></li> <li><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'X448'</code> <span class="experimental-inline"></span>[^1]</li> </ul> <p>The <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> (secret key) generating algorithms supported include:</p> <ul> <li><code>'HMAC'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM'</code></li> <li><code>'AES-KW'</code></li> </ul> <h4><code>subtle.importKey(format, keyData, algorithm, extractable, keyUsages)</code><span><a class="mark" href="#subtleimportkeyformat-keydata-algorithm-extractable-keyusages" id="subtleimportkeyformat-keydata-algorithm-extractable-keyusages">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_importkey_format_keydata_algorithm_extractable_keyusages"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'Ed25519'</code>, <code>'Ed448'</code>, <code>'X25519'</code>, and <code>'X448'</code> algorithms.</p> </td></tr> <tr><td>v15.9.0</td> <td><p>Removed <code>'NODE-DSA'</code> JWK import.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><ul> <li><code>format</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'raw'</code>, <code>'pkcs8'</code>, <code>'spki'</code>, or <code>'jwk'</code>.</li> <li><code>keyData</code>: {ArrayBuffer|TypedArray|DataView|Buffer|Object}</li> </ul> <!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}</li> </ul> <!--lint enable maximum-line-length remark-lint--> <ul> <li><code>extractable</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> <li><code>keyUsages</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a> See <a href="#cryptokeyusages">Key usages</a>.</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> </ul> <p>The <code>subtle.importKey()</code> method attempts to interpret the provided <code>keyData</code> as the given <code>format</code> to create a <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> instance using the provided <code>algorithm</code>, <code>extractable</code>, and <code>keyUsages</code> arguments. If the import is successful, the returned promise will be resolved with the created <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a>.</p> <p>If importing a <code>'PBKDF2'</code> key, <code>extractable</code> must be <code>false</code>.</p> <p>The algorithms currently supported include:</p> <table> <thead> <tr> <th>Key Type</th> <th><code>'spki'</code></th> <th><code>'pkcs8'</code></th> <th><code>'jwk'</code></th> <th><code>'raw'</code></th> </tr> </thead> <tbody><tr> <td><code>'AES-CBC'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-CTR'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-GCM'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'AES-KW'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'ECDH'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'X448'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'ECDSA'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</td> <td>✔</td> <td>✔</td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'HDKF'</code></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> <tr> <td><code>'HMAC'</code></td> <td></td> <td></td> <td>✔</td> <td>✔</td> </tr> <tr> <td><code>'PBKDF2'</code></td> <td></td> <td></td> <td></td> <td>✔</td> </tr> <tr> <td><code>'RSA-OAEP'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSA-PSS'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> <tr> <td><code>'RSASSA-PKCS1-v1_5'</code></td> <td>✔</td> <td>✔</td> <td>✔</td> <td></td> </tr> </tbody></table> <h4><code>subtle.sign(algorithm, key, data)</code><span><a class="mark" href="#subtlesignalgorithm-key-data" id="subtlesignalgorithm-key-data">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_sign_algorithm_key_data"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'Ed25519'</code>, and <code>'Ed448'</code> algorithms.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|RsaPssParams|EcdsaParams|Ed448Params}</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>data</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>Using the method and parameters given by <code>algorithm</code> and the keying material provided by <code>key</code>, <code>subtle.sign()</code> attempts to generate a cryptographic signature of <code>data</code>. If successful, the returned promise is resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the generated signature.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'RSASSA-PKCS1-v1_5'</code></li> <li><code>'RSA-PSS'</code></li> <li><code>'ECDSA'</code></li> <li><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'HMAC'</code></li> </ul> <h4><code>subtle.unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgo, unwrappedKeyAlgo, extractable, keyUsages)</code><span><a class="mark" href="#subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgo-unwrappedkeyalgo-extractable-keyusages" id="subtleunwrapkeyformat-wrappedkey-unwrappingkey-unwrapalgo-unwrappedkeyalgo-extractable-keyusages">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_unwrapkey_format_wrappedkey_unwrappingkey_unwrapalgo_unwrappedkeyalgo_extractable_keyusages"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li><code>format</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'raw'</code>, <code>'pkcs8'</code>, <code>'spki'</code>, or <code>'jwk'</code>.</li> <li><code>wrappedKey</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li><code>unwrappingKey</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> </ul> <!--lint disable maximum-line-length remark-lint--> <ul> <li><code>unwrapAlgo</code>: {AlgorithmIdentifier|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}</li> <li><code>unwrappedKeyAlgo</code>: {AlgorithmIdentifier|RsaHashedImportParams|EcKeyImportParams|HmacImportParams}</li> </ul> <!--lint enable maximum-line-length remark-lint--> <ul> <li><code>extractable</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> <li><code>keyUsages</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a> See <a href="#cryptokeyusages">Key usages</a>.</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> </ul> <p>In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. The <code>subtle.unwrapKey()</code> method attempts to decrypt a wrapped key and create a <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> instance. It is equivalent to calling <code>subtle.decrypt()</code> first on the encrypted key data (using the <code>wrappedKey</code>, <code>unwrapAlgo</code>, and <code>unwrappingKey</code> arguments as input) then passing the results in to the <code>subtle.importKey()</code> method using the <code>unwrappedKeyAlgo</code>, <code>extractable</code>, and <code>keyUsages</code> arguments as inputs. If successful, the returned promise is resolved with a <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a> object.</p> <p>The wrapping algorithms currently supported include:</p> <ul> <li><code>'RSA-OAEP'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM'</code></li> <li><code>'AES-KW'</code></li> </ul> <p>The unwrapped key algorithms supported include:</p> <ul> <li><code>'RSASSA-PKCS1-v1_5'</code></li> <li><code>'RSA-PSS'</code></li> <li><code>'RSA-OAEP'</code></li> <li><code>'ECDSA'</code></li> <li><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'ECDH'</code></li> <li><code>'X25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'X448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'HMAC'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM'</code></li> <li><code>'AES-KW'</code></li> </ul> <h4><code>subtle.verify(algorithm, key, signature, data)</code><span><a class="mark" href="#subtleverifyalgorithm-key-signature-data" id="subtleverifyalgorithm-key-signature-data">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_verify_algorithm_key_signature_data"></a></h4> <div class="api_metadata"> <details class="changelog"><summary>History</summary> <table> <tr><th>Version</th><th>Changes</th></tr> <tr><td>v18.4.0</td> <td><p>Added <code>'Ed25519'</code>, and <code>'Ed448'</code> algorithms.</p> </td></tr> <tr><td>v15.0.0</td> <td><p><span>Added in: v15.0.0</span></p> </td></tr> </table> </details> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>algorithm</code>: {AlgorithmIdentifier|RsaPssParams|EcdsaParams|Ed448Params}</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>signature</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li><code>data</code>: {ArrayBuffer|TypedArray|DataView|Buffer}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>Using the method and parameters given in <code>algorithm</code> and the keying material provided by <code>key</code>, <code>subtle.verify()</code> attempts to verify that <code>signature</code> is a valid cryptographic signature of <code>data</code>. The returned promise is resolved with either <code>true</code> or <code>false</code>.</p> <p>The algorithms currently supported include:</p> <ul> <li><code>'RSASSA-PKCS1-v1_5'</code></li> <li><code>'RSA-PSS'</code></li> <li><code>'ECDSA'</code></li> <li><code>'Ed25519'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'Ed448'</code> <span class="experimental-inline"></span>[^1]</li> <li><code>'HMAC'</code></li> </ul> <h4><code>subtle.wrapKey(format, key, wrappingKey, wrapAlgo)</code><span><a class="mark" href="#subtlewrapkeyformat-key-wrappingkey-wrapalgo" id="subtlewrapkeyformat-key-wrappingkey-wrapalgo">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_subtle_wrapkey_format_key_wrappingkey_wrapalgo"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><!--lint disable maximum-line-length remark-lint--> <ul> <li><code>format</code>: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'raw'</code>, <code>'pkcs8'</code>, <code>'spki'</code>, or <code>'jwk'</code>.</li> <li><code>key</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>wrappingKey</code>: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> <li><code>wrapAlgo</code>: {AlgorithmIdentifier|RsaOaepParams|AesCtrParams|AesCbcParams|AesGcmParams}</li> <li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise" class="type"><Promise></a> containing <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a></li> </ul> <!--lint enable maximum-line-length remark-lint--> <p>In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material. The <code>subtle.wrapKey()</code> method exports the keying material into the format identified by <code>format</code>, then encrypts it using the method and parameters specified by <code>wrapAlgo</code> and the keying material provided by <code>wrappingKey</code>. It is the equivalent to calling <code>subtle.exportKey()</code> using <code>format</code> and <code>key</code> as the arguments, then passing the result to the <code>subtle.encrypt()</code> method using <code>wrappingKey</code> and <code>wrapAlgo</code> as inputs. If successful, the returned promise will be resolved with an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" class="type"><ArrayBuffer></a> containing the encrypted key data.</p> <p>The wrapping algorithms currently supported include:</p> <ul> <li><code>'RSA-OAEP'</code></li> <li><code>'AES-CTR'</code></li> <li><code>'AES-CBC'</code></li> <li><code>'AES-GCM'</code></li> <li><code>'AES-KW'</code></li> </ul> </section><section><h3>Algorithm parameters<span><a class="mark" href="#algorithm-parameters" id="algorithm-parameters">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_algorithm_parameters"></a></h3> <p>The algorithm parameter objects define the methods and parameters used by the various <a href="webcrypto.html#class-subtlecrypto" class="type"><SubtleCrypto></a> methods. While described here as "classes", they are simple JavaScript dictionary objects.</p> <h4>Class: <code>AlgorithmIdentifier</code><span><a class="mark" href="#class-algorithmidentifier" id="class-algorithmidentifier">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_algorithmidentifier"></a></h4> <div class="api_metadata"> <span>Added in: v18.4.0</span> </div><h5><code>algorithmIdentifier.name</code><span><a class="mark" href="#algorithmidentifiername" id="algorithmidentifiername">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_algorithmidentifier_name"></a></h5> <div class="api_metadata"> <span>Added in: v18.4.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> </ul> <h4>Class: <code>AesCbcParams</code><span><a class="mark" href="#class-aescbcparams" id="class-aescbcparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_aescbcparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>aesCbcParams.iv</code><span><a class="mark" href="#aescbcparamsiv" id="aescbcparamsiv">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aescbcparams_iv"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>Provides the initialization vector. It must be exactly 16-bytes in length and should be unpredictable and cryptographically random.</p> <h5><code>aesCbcParams.name</code><span><a class="mark" href="#aescbcparamsname" id="aescbcparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aescbcparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'AES-CBC'</code>.</li> </ul> <h4>Class: <code>AesCtrParams</code><span><a class="mark" href="#class-aesctrparams" id="class-aesctrparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_aesctrparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>aesCtrParams.counter</code><span><a class="mark" href="#aesctrparamscounter" id="aesctrparamscounter">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesctrparams_counter"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>The initial value of the counter block. This must be exactly 16 bytes long.</p> <p>The <code>AES-CTR</code> method uses the rightmost <code>length</code> bits of the block as the counter and the remaining bits as the nonce.</p> <h5><code>aesCtrParams.length</code><span><a class="mark" href="#aesctrparamslength" id="aesctrparamslength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesctrparams_length"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of bits in the <code>aesCtrParams.counter</code> that are to be used as the counter.</li> </ul> <h5><code>aesCtrParams.name</code><span><a class="mark" href="#aesctrparamsname" id="aesctrparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesctrparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'AES-CTR'</code>.</li> </ul> <h4>Class: <code>AesGcmParams</code><span><a class="mark" href="#class-aesgcmparams" id="class-aesgcmparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_aesgcmparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>aesGcmParams.additionalData</code><span><a class="mark" href="#aesgcmparamsadditionaldata" id="aesgcmparamsadditionaldata">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesgcmparams_additionaldata"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}</li> </ul> <p>With the AES-GCM method, the <code>additionalData</code> is extra input that is not encrypted but is included in the authentication of the data. The use of <code>additionalData</code> is optional.</p> <h5><code>aesGcmParams.iv</code><span><a class="mark" href="#aesgcmparamsiv" id="aesgcmparamsiv">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesgcmparams_iv"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>The initialization vector must be unique for every encryption operation using a given key.</p> <p>Ideally, this is a deterministic 12-byte value that is computed in such a way that it is guaranteed to be unique across all invocations that use the same key. Alternatively, the initialization vector may consist of at least 12 cryptographically random bytes. For more information on constructing initialization vectors for AES-GCM, refer to Section 8 of <a href="https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf">NIST SP 800-38D</a>.</p> <h5><code>aesGcmParams.name</code><span><a class="mark" href="#aesgcmparamsname" id="aesgcmparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesgcmparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'AES-GCM'</code>.</li> </ul> <h5><code>aesGcmParams.tagLength</code><span><a class="mark" href="#aesgcmparamstaglength" id="aesgcmparamstaglength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aesgcmparams_taglength"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The size in bits of the generated authentication tag. This values must be one of <code>32</code>, <code>64</code>, <code>96</code>, <code>104</code>, <code>112</code>, <code>120</code>, or <code>128</code>. <strong>Default:</strong> <code>128</code>.</li> </ul> <h4>Class: <code>AesKeyGenParams</code><span><a class="mark" href="#class-aeskeygenparams" id="class-aeskeygenparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_aeskeygenparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>aesKeyGenParams.length</code><span><a class="mark" href="#aeskeygenparamslength" id="aeskeygenparamslength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aeskeygenparams_length"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The length of the AES key to be generated. This must be either <code>128</code>, <code>192</code>, or <code>256</code>.</p> <h5><code>aesKeyGenParams.name</code><span><a class="mark" href="#aeskeygenparamsname" id="aeskeygenparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_aeskeygenparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'AES-CBC'</code>, <code>'AES-CTR'</code>, <code>'AES-GCM'</code>, or <code>'AES-KW'</code></li> </ul> <h4>Class: <code>EcdhKeyDeriveParams</code><span><a class="mark" href="#class-ecdhkeyderiveparams" id="class-ecdhkeyderiveparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_ecdhkeyderiveparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>ecdhKeyDeriveParams.name</code><span><a class="mark" href="#ecdhkeyderiveparamsname" id="ecdhkeyderiveparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ecdhkeyderiveparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'ECDH'</code>, <code>'X25519'</code>, or <code>'X448'</code>.</li> </ul> <h5><code>ecdhKeyDeriveParams.public</code><span><a class="mark" href="#ecdhkeyderiveparamspublic" id="ecdhkeyderiveparamspublic">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ecdhkeyderiveparams_public"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="webcrypto.html#class-cryptokey" class="type"><CryptoKey></a></li> </ul> <p>ECDH key derivation operates by taking as input one parties private key and another parties public key -- using both to generate a common shared secret. The <code>ecdhKeyDeriveParams.public</code> property is set to the other parties public key.</p> <h4>Class: <code>EcdsaParams</code><span><a class="mark" href="#class-ecdsaparams" id="class-ecdsaparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_ecdsaparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>ecdsaParams.hash</code><span><a class="mark" href="#ecdsaparamshash" id="ecdsaparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ecdsaparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>ecdsaParams.name</code><span><a class="mark" href="#ecdsaparamsname" id="ecdsaparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ecdsaparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'ECDSA'</code>.</li> </ul> <h4>Class: <code>EcKeyGenParams</code><span><a class="mark" href="#class-eckeygenparams" id="class-eckeygenparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_eckeygenparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>ecKeyGenParams.name</code><span><a class="mark" href="#eckeygenparamsname" id="eckeygenparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_eckeygenparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'ECDSA'</code> or <code>'ECDH'</code>.</li> </ul> <h5><code>ecKeyGenParams.namedCurve</code><span><a class="mark" href="#eckeygenparamsnamedcurve" id="eckeygenparamsnamedcurve">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_eckeygenparams_namedcurve"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'P-256'</code>, <code>'P-384'</code>, <code>'P-521'</code>.</li> </ul> <h4>Class: <code>EcKeyImportParams</code><span><a class="mark" href="#class-eckeyimportparams" id="class-eckeyimportparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_eckeyimportparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>ecKeyImportParams.name</code><span><a class="mark" href="#eckeyimportparamsname" id="eckeyimportparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_eckeyimportparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'ECDSA'</code> or <code>'ECDH'</code>.</li> </ul> <h5><code>ecKeyImportParams.namedCurve</code><span><a class="mark" href="#eckeyimportparamsnamedcurve" id="eckeyimportparamsnamedcurve">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_eckeyimportparams_namedcurve"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'P-256'</code>, <code>'P-384'</code>, <code>'P-521'</code>.</li> </ul> <h4>Class: <code>Ed448Params</code><span><a class="mark" href="#class-ed448params" id="class-ed448params">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_ed448params"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>ed448Params.name</code><span><a class="mark" href="#ed448paramsname" id="ed448paramsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ed448params_name"></a></h5> <div class="api_metadata"> <span>Added in: v18.4.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'Ed448'</code>.</li> </ul> <h5><code>ed448Params.context</code><span><a class="mark" href="#ed448paramscontext" id="ed448paramscontext">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_ed448params_context"></a></h5> <div class="api_metadata"> <span>Added in: v18.4.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer|undefined}</li> </ul> <p>The <code>context</code> member represents the optional context data to associate with the message. The Node.js Web Crypto API implementation only supports zero-length context which is equivalent to not providing context at all.</p> <h4>Class: <code>HkdfParams</code><span><a class="mark" href="#class-hkdfparams" id="class-hkdfparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_hkdfparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>hkdfParams.hash</code><span><a class="mark" href="#hkdfparamshash" id="hkdfparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hkdfparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>hkdfParams.info</code><span><a class="mark" href="#hkdfparamsinfo" id="hkdfparamsinfo">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hkdfparams_info"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>Provides application-specific contextual input to the HKDF algorithm. This can be zero-length but must be provided.</p> <h5><code>hkdfParams.name</code><span><a class="mark" href="#hkdfparamsname" id="hkdfparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hkdfparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'HKDF'</code>.</li> </ul> <h5><code>hkdfParams.salt</code><span><a class="mark" href="#hkdfparamssalt" id="hkdfparamssalt">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hkdfparams_salt"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>The salt value significantly improves the strength of the HKDF algorithm. It should be random or pseudorandom and should be the same length as the output of the digest function (for instance, if using <code>'SHA-256'</code> as the digest, the salt should be 256-bits of random data).</p> <h4>Class: <code>HmacImportParams</code><span><a class="mark" href="#class-hmacimportparams" id="class-hmacimportparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_hmacimportparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>hmacImportParams.hash</code><span><a class="mark" href="#hmacimportparamshash" id="hmacimportparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmacimportparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>hmacImportParams.length</code><span><a class="mark" href="#hmacimportparamslength" id="hmacimportparamslength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmacimportparams_length"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The optional number of bits in the HMAC key. This is optional and should be omitted for most cases.</p> <h5><code>hmacImportParams.name</code><span><a class="mark" href="#hmacimportparamsname" id="hmacimportparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmacimportparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'HMAC'</code>.</li> </ul> <h4>Class: <code>HmacKeyGenParams</code><span><a class="mark" href="#class-hmackeygenparams" id="class-hmackeygenparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_hmackeygenparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>hmacKeyGenParams.hash</code><span><a class="mark" href="#hmackeygenparamshash" id="hmackeygenparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmackeygenparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>hmacKeyGenParams.length</code><span><a class="mark" href="#hmackeygenparamslength" id="hmackeygenparamslength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmackeygenparams_length"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The number of bits to generate for the HMAC key. If omitted, the length will be determined by the hash algorithm used. This is optional and should be omitted for most cases.</p> <h5><code>hmacKeyGenParams.name</code><span><a class="mark" href="#hmackeygenparamsname" id="hmackeygenparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_hmackeygenparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'HMAC'</code>.</li> </ul> <h4>Class: <code>Pbkdf2Params</code><span><a class="mark" href="#class-pbkdf2params" id="class-pbkdf2params">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_pbkdf2params"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>pbkdb2Params.hash</code><span><a class="mark" href="#pbkdb2paramshash" id="pbkdb2paramshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_pbkdb2params_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>pbkdf2Params.iterations</code><span><a class="mark" href="#pbkdf2paramsiterations" id="pbkdf2paramsiterations">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_pbkdf2params_iterations"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The number of iterations the PBKDF2 algorithm should make when deriving bits.</p> <h5><code>pbkdf2Params.name</code><span><a class="mark" href="#pbkdf2paramsname" id="pbkdf2paramsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_pbkdf2params_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'PBKDF2'</code>.</li> </ul> <h5><code>pbkdf2Params.salt</code><span><a class="mark" href="#pbkdf2paramssalt" id="pbkdf2paramssalt">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_pbkdf2params_salt"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>Should be at least 16 random or pseudorandom bytes.</p> <h4>Class: <code>RsaHashedImportParams</code><span><a class="mark" href="#class-rsahashedimportparams" id="class-rsahashedimportparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_rsahashedimportparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>rsaHashedImportParams.hash</code><span><a class="mark" href="#rsahashedimportparamshash" id="rsahashedimportparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedimportparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>rsaHashedImportParams.name</code><span><a class="mark" href="#rsahashedimportparamsname" id="rsahashedimportparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedimportparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'RSASSA-PKCS1-v1_5'</code>, <code>'RSA-PSS'</code>, or <code>'RSA-OAEP'</code>.</li> </ul> <h4>Class: <code>RsaHashedKeyGenParams</code><span><a class="mark" href="#class-rsahashedkeygenparams" id="class-rsahashedkeygenparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_rsahashedkeygenparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>rsaHashedKeyGenParams.hash</code><span><a class="mark" href="#rsahashedkeygenparamshash" id="rsahashedkeygenparamshash">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedkeygenparams_hash"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {string|Object}</li> </ul> <p>If represented as a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a>, the value must be one of:</p> <ul> <li><code>'SHA-1'</code></li> <li><code>'SHA-256'</code></li> <li><code>'SHA-384'</code></li> <li><code>'SHA-512'</code></li> </ul> <p>If represented as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>, the object must have a <code>name</code> property whose value is one of the above listed values.</p> <h5><code>rsaHashedKeyGenParams.modulusLength</code><span><a class="mark" href="#rsahashedkeygenparamsmoduluslength" id="rsahashedkeygenparamsmoduluslength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedkeygenparams_moduluslength"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The length in bits of the RSA modulus. As a best practice, this should be at least <code>2048</code>.</p> <h5><code>rsaHashedKeyGenParams.name</code><span><a class="mark" href="#rsahashedkeygenparamsname" id="rsahashedkeygenparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedkeygenparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be one of <code>'RSASSA-PKCS1-v1_5'</code>, <code>'RSA-PSS'</code>, or <code>'RSA-OAEP'</code>.</li> </ul> <h5><code>rsaHashedKeyGenParams.publicExponent</code><span><a class="mark" href="#rsahashedkeygenparamspublicexponent" id="rsahashedkeygenparamspublicexponent">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsahashedkeygenparams_publicexponent"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {Uint8Array}</li> </ul> <p>The RSA public exponent. This must be a {Uint8Array} containing a big-endian, unsigned integer that must fit within 32-bits. The {Uint8Array} may contain an arbitrary number of leading zero-bits. The value must be a prime number. Unless there is reason to use a different value, use <code>new Uint8Array([1, 0, 1])</code> (65537) as the public exponent.</p> <h4>Class: <code>RsaOaepParams</code><span><a class="mark" href="#class-rsaoaepparams" id="class-rsaoaepparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_rsaoaepparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>rsaOaepParams.label</code><span><a class="mark" href="#rsaoaepparamslabel" id="rsaoaepparamslabel">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsaoaepparams_label"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: {ArrayBuffer|TypedArray|DataView|Buffer}</li> </ul> <p>An additional collection of bytes that will not be encrypted, but will be bound to the generated ciphertext.</p> <p>The <code>rsaOaepParams.label</code> parameter is optional.</p> <h5><code>rsaOaepParams.name</code><span><a class="mark" href="#rsaoaepparamsname" id="rsaoaepparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsaoaepparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> must be <code>'RSA-OAEP'</code>.</li> </ul> <h4>Class: <code>RsaPssParams</code><span><a class="mark" href="#class-rsapssparams" id="class-rsapssparams">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_class_rsapssparams"></a></h4> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><h5><code>rsaPssParams.name</code><span><a class="mark" href="#rsapssparamsname" id="rsapssparamsname">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsapssparams_name"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Must be <code>'RSA-PSS'</code>.</li> </ul> <h5><code>rsaPssParams.saltLength</code><span><a class="mark" href="#rsapssparamssaltlength" id="rsapssparamssaltlength">#</a></span><a aria-hidden="true" class="legacy" id="webcrypto_rsapssparams_saltlength"></a></h5> <div class="api_metadata"> <span>Added in: v15.0.0</span> </div><ul> <li>Type: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> </ul> <p>The length (in bytes) of the random salt to use.</p> <p>[^1]: An experimental implementation of <a href="https://wicg.github.io/webcrypto-secure-curves/">Secure Curves in the Web Cryptography API</a> as of 05 May 2022</p> </section> <!-- API END --> </div> </div> </div> </body> </html>