Web Crypto API
This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.
This page is not complete.
The Web Crypto API is an interface allowing a script to use cryptographic primitives in order to build systems using cryptography.
This interface allows script to access the following primitives:
- digest, the ability to compute a hash of an arbitrary block of data, in order to detect any change in it.
- mac, the ability to compute a message authentication code.
- sign and verify, the ability to digitally sign a document, and to verify a signature.
- encrypt and decrypt, the ability to encode or decode a document.
- import and export, the ability to import a key or export a key.
- key generation, the ability to create a cryptographically secure key, or key pair, without the use of base key, but using the available entropy of the local system.
- random, the ability to generate cryptographically sound pseudo-random numbers.
Web Crypto API doesn't solve all cryptographic problem a Web site or an application may encounter:
- It doesn't relax the same-origin security model of the browser, like cases where keys are issued by centralized entities used by several Web sites.
- It doesn't interact with dedicated hardware, like smart cards, USB dongles, or randomness generators.
- The mere use of cryptography doesn't make your system secure. Security is a process that constantly evaluates the risks a system incurs in its context of use. The context and the risks experienced evolve over time.
- When dealing with security, the whole system must be considered. In the case of the Web Crypto API, Web developers shouldn't consider only the security of the script, but the security of the connection to the server and the data this one may have in clear text. The overall security can't be stronger than the security of the weakest part of the overall system.
Some browsers implemented an interface called
Crypto without having it well defined or being cryptographically sound. In order to avoid confusion, methods and properties of this interface are gone in browsers implementing the Web Crypto API, and all Web Crypto API methods are available on a new interface:
Crypto.subtle property gives access to an object implementing it.
The Web Crypto API can be used:
- to verify that data has not been tampered by a third-party. Even if the data is stored in the clear, the storage of a signature, generated from a password, allows the people knowing the password to know that it is genuine.
|Web Cryptography API||Candidate Recommendation||Initial definition|
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.