subtle.importKey(format, keyData, algorithm, extractable, keyUsages)
-
format<string> 必须是'raw'、'pkcs8'、'spki'、'jwk'、'raw-secret'4、'raw-public'4 或'raw-seed'4 之一。¥
format<string> Must be one of'raw','pkcs8','spki','jwk','raw-secret'4,'raw-public'4, or'raw-seed'4. -
keyData<ArrayBuffer> | <TypedArray> | <DataView> | <Buffer> | <Object>
algorithm<string> | <RsaHashedImportParams> | <EcKeyImportParams> | <HmacImportParams>
-
extractable<boolean> -
keyUsages<string[]> 参见 关键用法。¥
keyUsages<string[]> See Key usages. -
返回:<Promise> 成功后获得 <CryptoKey>。
¥Returns: <Promise> Fulfills with a <CryptoKey> upon success.
此方法尝试将提供的 keyData 解释为给定的 format,以便使用提供的 algorithm、extractable 和 keyUsages 参数创建 <CryptoKey> 实例。如果导入成功,返回的 Promise 将使用密钥材料的 <CryptoKey> 表示进行解析。
¥This method attempts to interpret the provided keyData
as the given format to create a <CryptoKey> instance using the provided
algorithm, extractable, and keyUsages arguments. If the import is
successful, the returned promise will be resolved with a <CryptoKey>
representation of the key material.
如果导入 KDF 算法键,extractable 必须是 false。
¥If importing KDF algorithm keys, extractable must be false.
目前支持的算法包括:
¥The algorithms currently supported include:
| 支持的密钥算法 | 'spki' | 'pkcs8' | 'jwk' | 'raw' | 'raw-secret' | 'raw-public' | 'raw-seed' |
|---|---|---|---|---|---|---|---|
'AES-CBC' | ✔ | ✔ | ✔ | ||||
'AES-CTR' | ✔ | ✔ | ✔ | ||||
'AES-GCM' | ✔ | ✔ | ✔ | ||||
'AES-KW' | ✔ | ✔ | ✔ | ||||
'AES-OCB'[^modern-algos] | ✔ | ✔ | |||||
'Argon2d'[^modern-algos] | ✔ | ||||||
'Argon2i'[^modern-algos] | ✔ | ||||||
'Argon2id'[^modern-algos] | ✔ | ||||||
'ChaCha20-Poly1305'[^modern-algos] | ✔ | ✔ | |||||
'ECDH' | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'ECDSA' | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'Ed25519' | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'Ed448'[^secure-curves] | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'HDKF' | ✔ | ✔ | |||||
'HMAC' | ✔ | ✔ | ✔ | ||||
'KMAC128'[^modern-algos] | ✔ | ✔ | |||||
'KMAC256'[^modern-algos] | ✔ | ✔ | |||||
'ML-DSA-44'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'ML-DSA-65'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'ML-DSA-87'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'ML-KEM-512'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | |||
'ML-KEM-768'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | |||
'ML-KEM-1024'[^modern-algos] | ✔ | ✔ | ✔ | ✔ | |||
'PBKDF2' | ✔ | ✔ | |||||
'RSA-OAEP' | ✔ | ✔ | ✔ | ||||
'RSA-PSS' | ✔ | ✔ | ✔ | ||||
'RSASSA-PKCS1-v1_5' | ✔ | ✔ | ✔ | ||||
'X25519' | ✔ | ✔ | ✔ | ✔ | ✔ | ||
'X448'[^secure-curves] | ✔ | ✔ | ✔ | ✔ | ✔ |