安全上下文
此特征只可用于
安全上下文
(HTTPS),在某些或所有
支持浏览器
.
CryptoKey
接口在
Web 加密 API
represents a cryptographic
key
obtained from one of the
SubtleCrypto
方法
generateKey()
,
deriveKey()
,
importKey()
,或
unwrapKey()
.
For security reasons, the
CryptoKey
interface can only be used in a
secure context
.
CryptoKey.type
String which may take one of the following values:
"secret"
: This key is a secret key for use with a
symmetric algorithm
.
"private"
: This key is the private half of an
asymmetric algorithm's
CryptoKeyPair
.
"public"
: This key is the public half of an
asymmetric algorithm's
CryptoKeyPair
.
CryptoKey.extractable
布尔
indicating whether or not the key may be extracted using
SubtleCrypto.exportKey()
or
SubtleCrypto.wrapKey()
.
true
: The key may be extracted.
false
The key may not be extracted.
exportKey()
or
wrapKey()
will throw an exception if used to extract this key.
CryptoKey.algorithm
An object describing the algorithm for which this key can be used and any associated extra parameters.
AesKeyGenParams
if the algorithm is any of the AES variants.
RsaHashedKeyGenParams
if the algorithm is any of the RSA variants.
EcKeyGenParams
if the algorithm is any of the EC variants.
HmacKeyGenParams
if the algorithm is HMAC.
CryptoKey.usages
数组
of strings, indicating what can be done with the key. Possible values for array elements are:
"encrypt"
: The key may be used to
encrypt
messages.
"decrypt"
: The key may be used to
decrypt
messages.
"sign"
: The key may be used to
sign
messages.
"verify"
: The key may be used to
verify
signatures.
"deriveKey"
: The key may be used in
deriving a new key
.
"deriveBits"
: The key may be used in
deriving bits
.
"wrapKey"
: The key may be used to
wrap a key
.
"unwrapKey"
: The key may be used to
unwrap a key
.
The examples for
SubtleCrypto
methods often use
CryptoKey
objects. For example:
SubtleCrypto.generateKey()
SubtleCrypto.deriveKey()
SubtleCrypto.importKey()
SubtleCrypto.exportKey()
SubtleCrypto.wrapKey()
SubtleCrypto.unwrapKey()
SubtleCrypto.encrypt()
SubtleCrypto.decrypt()
SubtleCrypto.sign()
SubtleCrypto.verify()
| 规范 | 状态 | 注释 |
|---|---|---|
|
Web Cryptography API
The definition of 'CryptoKey' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CryptoKey
|
Chrome 37 | Edge ≤18 | Firefox 34 | IE No | Opera Yes | Safari No | WebView Android 37 | Chrome Android 37 | Firefox Android 34 | Opera Android Yes | Safari iOS No | Samsung Internet Android 3.0 |
algorithm
|
Chrome 37 | Edge 12 | Firefox 34 | IE No | Opera Yes | Safari No | WebView Android 37 | Chrome Android 37 | Firefox Android 34 | Opera Android Yes | Safari iOS No | Samsung Internet Android 3.0 |
extractable
|
Chrome 37 | Edge 12 | Firefox 34 | IE No | Opera Yes | Safari No | WebView Android 37 | Chrome Android 37 | Firefox Android 34 | Opera Android Yes | Safari iOS No | Samsung Internet Android 3.0 |
| Secure context required | Chrome 60 | Edge 79 | Firefox 75 | IE No | Opera 47 | Safari No | WebView Android 60 | Chrome Android 60 | Firefox Android No | Opera Android 47 | Safari iOS No | Samsung Internet Android No |
type
|
Chrome 37 | Edge 12 | Firefox 34 | IE No | Opera Yes | Safari No | WebView Android 37 | Chrome Android 37 | Firefox Android 34 | Opera Android Yes | Safari iOS No | Samsung Internet Android 3.0 |
usages
|
Chrome 37 | Edge 12 | Firefox 34 | IE No | Opera Yes | Safari No | WebView Android 37 | Chrome Android 37 | Firefox Android 34 | Opera Android Yes | Safari iOS No | Samsung Internet Android 3.0 |
完整支持
不支持
CryptoKey