subtle.exportKey(format, key)
format<string> 必须是'raw'、'pkcs8'、'spki'、'jwk'、'raw-secret'4、'raw-public'4 或'raw-seed'4 之一。key<CryptoKey>- 返回:<Promise> 成功时会触发一个 <ArrayBuffer> | <Object>。
如果支持,将给定的密钥导出为指定的格式。
🌐 Exports the given key into the specified format, if supported.
如果 <CryptoKey> 无法提取,返回的 Promise 将会被拒绝。
🌐 If the <CryptoKey> is not extractable, the returned promise will reject.
当 format 为 'pkcs8' 或 'spki' 且导出成功时,返回的 promise 将被解析为一个包含导出密钥数据的 <ArrayBuffer>。
🌐 When format is either 'pkcs8' or 'spki' and the export is successful,
the returned promise will be resolved with an <ArrayBuffer> containing the
exported key data.
当 format 为 'jwk' 且导出成功时,返回的 promise 将会以一个符合 JSON 网钥 规范的 JavaScript 对象来解析。
🌐 When format is 'jwk' and the export is successful, the returned promise
will be resolved with a JavaScript object conforming to the JSON Web Key
specification.
| 支持的密钥算法 | 'spki' | 'pkcs8' | 'jwk' | 'raw' | 'raw-secret' | 'raw-public' | 'raw-seed' |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 'AES-CBC' | | | ✔ | ✔ | ✔ | | |
| 'AES-CTR' | | | ✔ | ✔ | ✔ | | |
| 'AES-GCM' | | | ✔ | ✔ | ✔ | | |
| 'AES-KW' | | | ✔ | ✔ | ✔ | | |
| 'AES-OCB'4 | | | ✔ | | ✔ | | |
| 'ChaCha20-Poly1305'4 | | | ✔ | | ✔ | | |
| 'ECDH' | ✔ | ✔ | ✔ | ✔ | | ✔ | |
| 'ECDSA' | ✔ | ✔ | ✔ | ✔ | | ✔ | |
| 'Ed25519' | ✔ | ✔ | ✔ | ✔ | | ✔ | |
| 'Ed448'5 | ✔ | ✔ | ✔ | ✔ | | ✔ | |
| 'HMAC' | | | ✔ | ✔ | ✔ | | |
| 'KMAC128'4 | | | ✔ | | ✔ | | |
| 'KMAC256'4 | | | ✔ | | ✔ | | |
| 'ML-DSA-44'4 | ✔ | ✔ | ✔ | | | ✔ | ✔ |
| 'ML-DSA-65'4 | ✔ | ✔ | ✔ | | | ✔ | ✔ |
| 'ML-DSA-87'4 | ✔ | ✔ | ✔ | | | ✔ | ✔ |
| 'ML-KEM-512'[^现代算法] | ✔ | ✔ | | | | ✔ | ✔ |
| 'ML-KEM-768'[^现代算法] | ✔ | ✔ | | | | ✔ | ✔ |
| 'ML-KEM-1024'4 | ✔ | ✔ | | | | ✔ | ✔ |
| 'RSA-OAEP' | ✔ | ✔ | ✔ | | | | |
| 'RSA-PSS' | ✔ | ✔ | ✔ | | | | |
| 'RSASSA-PKCS1-v1_5' | ✔ | ✔ | ✔ | | | | |