subtle.importKey(format, keyData, algorithm, extractable, keyUsages)
-
format
:<string> 必须是'raw'
、'pkcs8'
、'spki'
或'jwk'
之一。¥
format
: <string> Must be one of'raw'
,'pkcs8'
,'spki'
, or'jwk'
. -
keyData
:<ArrayBuffer> | <TypedArray> | <DataView> | <Buffer> | <Object>
algorithm
:<AlgorithmIdentifier> | <RsaHashedImportParams> | <EcKeyImportParams> | <HmacImportParams>
-
extractable
:<boolean> -
keyUsages
:<string[]> 参见 关键用法。¥
keyUsages
: <string[]> See Key usages. -
返回:<Promise> 包含 <CryptoKey>
¥Returns: <Promise> containing <CryptoKey>
subtle.importKey()
方法尝试将提供的 keyData
解释为给定的 format
,以使用提供的 algorithm
、extractable
和 keyUsages
参数创建 <CryptoKey> 实例。如果导入成功,返回的 promise 将使用创建的 <CryptoKey> 进行解析。
¥The subtle.importKey()
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 the created <CryptoKey>.
如果导入 'PBKDF2'
密钥,extractable
必须是 false
。
¥If importing a 'PBKDF2'
key, extractable
must be false
.
目前支持的算法包括:
¥The algorithms currently supported include:
密钥类型 | 'spki' | 'pkcs8' | 'jwk' | 'raw' |
---|---|---|---|---|
'AES-CBC' | ✔ | ✔ | ||
'AES-CTR' | ✔ | ✔ | ||
'AES-GCM' | ✔ | ✔ | ||
'AES-KW' | ✔ | ✔ | ||
'ECDH' | ✔ | ✔ | ✔ | ✔ |
'X25519' 1 | ✔ | ✔ | ✔ | ✔ |
'X448' 1 | ✔ | ✔ | ✔ | ✔ |
'ECDSA' | ✔ | ✔ | ✔ | ✔ |
'Ed25519' 1 | ✔ | ✔ | ✔ | ✔ |
'Ed448' 1 | ✔ | ✔ | ✔ | ✔ |
'HDKF' | ✔ | |||
'HMAC' | ✔ | ✔ | ||
'PBKDF2' | ✔ | |||
'RSA-OAEP' | ✔ | ✔ | ✔ | |
'RSA-PSS' | ✔ | ✔ | ✔ | |
'RSASSA-PKCS1-v1_5' | ✔ | ✔ | ✔ |