Keys in Web Crypto
Using the Web Crypto APIs, cryptographic keys are stored inside CryptoKey objects, which are used for both symmetric and asymmetric (private or public) keys. There are additional methods that allow us to generate, derive, import, and export keys that are stored in CryptoKey
objects.
The CryptoKey object
All cryptographic keys that are used with Web Crypto APIs are contained in CryptoKey
objects, which also determine what operations are possible with the keys and whether they're extractable.
In particular, a CryptoKey
object contains the following properties, which are all read-only:
type
is a string that indicates the type of the key. Its possible values are'public'
and'private'
for each part of an asymmetric key, and'secret'
for symmetric keys.algorithm
is an object that contains information about the algorithm the key can be used for, as well as extra parameters. We'll learn more about these...