The Crypto interface represents basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives.
The CryptoKey interface represents a cryptographic key derived from a specific key algorithm.
The SubtleCrypto interface represents a set of cryptographic primitives. It is available via the Crypto.subtle properties available in a window context (via Window.crypto).
Different algorithms are supported for the different functions provided by the Web Crypto API. Also, depending of the context, these algorithms needs parameters or they will raise a SyntaxError. This pages lists the context, the available algorithms and the required parameters.
The Crypto.subtle read-only property returns a SubtleCrypto object allowing to perform cryptographical operations.
The CryptoKey.algorithm read-only property is an opaque value containing all the information about the algorithm related to the key.
The CryptoKey.extractable read-only property that indicates if the raw material key can be extracted, for example for archiving it.
The CryptoKey.type read-only property that indicates the type of the key: if it is the key for a symmetric algorithm ("secret") or for an asymmetric algorithm ("public" or "private", depending of its purpose).
The CryptoKey.usages read-only property is an array of enumerated that indicates the purposes of the key.
RandomSource represents a source of cryptographically secure random numbers. It is available via the Crypto object of the global object: Window.crypto on Web pages, WorkerGlobalScope.crypto in workers.
The SubtleCrypto.decrypt() method returns a Promise of the cleartext corresponding to the ciphertext, algorithm and key given as parameters.
The SubtleCrypto.encrypt() method returns a Promise of the encrypted data corresponding to the cleartext, algorithm and key given as parameters.
The SubtleCrypto.exportKey() method returns a Promise of the key encrypted in the requested format. If the key is not extractable, that is if CryptoKey.extractable returns false, the promise fails with an InvalidAccessError exception; it the format is unknown, the promive fails with a NotSupported exception.
The SubtleCrypto.generateKey() method returns a Promise of a newly generated CryptoKey, for symmetrical algorithms, or a CryptoKeyPair, containing two newly generated keys, for asymmetrical algorithm, that matches the algorithm, the usages and the extractability given as parameters.
The SubtleCrypto.importKey() method returns a Promise of the CryptoKey generated from the data given in parameters.
The SubtleCrypto.sign() method returns a Promise containing the signature corresponding to the text, algorithm and key given as parameters.
The SubtleCrypto.unwrapKey() method returns a Promise of a CryptoKey corresponding to the wrapped key given in parameter.
The SubtleCrypto.verify() method returns a Promise of a Boolean value indicating if the signature given as parameter matches the text, algorithm and key also given as parameters.
The SubtleCrypto.wrapKey() method returns a Promise of a wrapped symmetric key for usage (transfer, storage) in unsecure environments. The wrapped buffer returned is in the format given in parameters, and contained the key wrapped by the give wrapping key with the given algorithm.