title | slug | page-type | browser-compat |
---|---|---|---|
CryptoKey |
Web/API/CryptoKey |
web-api-interface |
api.CryptoKey |
{{APIRef("Web Crypto API")}}{{SecureContext_header}}
The CryptoKey
interface of the Web Crypto API represents a cryptographic {{glossary("key")}} obtained from one of the {{domxref("SubtleCrypto")}} methods {{domxref("SubtleCrypto.generateKey", "generateKey()")}}, {{domxref("SubtleCrypto.deriveKey", "deriveKey()")}}, {{domxref("SubtleCrypto.importKey", "importKey()")}}, or {{domxref("SubtleCrypto.unwrapKey", "unwrapKey()")}}.
For security reasons, the CryptoKey
interface can only be used in a secure context.
-
{{domxref("CryptoKey.type")}} {{ReadOnlyInline}}
- : The type of key the object represents. It may take one of the following values:
"secret"
,"private"
or"public"
.
- : The type of key the object represents. It may take one of the following values:
-
{{domxref("CryptoKey.extractable")}} {{ReadOnlyInline}}
- : A boolean value indicating whether or not the key may be extracted using
SubtleCrypto.exportKey()
orSubtleCrypto.wrapKey()
.
- : A boolean value indicating whether or not the key may be extracted using
-
{{domxref("CryptoKey.algorithm")}} {{ReadOnlyInline}}
- : An object describing the algorithm for which this key can be used and any associated extra parameters.
-
{{domxref("CryptoKey.usages")}} {{ReadOnlyInline}}
- : An {{jsxref("Array")}} of strings, indicating what can be done with the key. Possible values for array elements are
"encrypt"
,"decrypt"
,"sign"
,"verify"
,"deriveKey"
,"deriveBits"
,"wrapKey"
, and"unwrapKey"
.
- : An {{jsxref("Array")}} of strings, indicating what can be done with the key. Possible values for array elements are
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()
{{Specifications}}
{{Compat}}
- Web Crypto API
- Web security
- Privacy, permissions, and information security
- {{domxref("Crypto")}} and {{domxref("Crypto.subtle")}}.