web api overview
Web Crypto API
Secure contextAvailable in workers
The Web Crypto API is an interface allowing a script to use cryptographic primitives in order to build systems using cryptography.
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 have been removed from browsers implementing the Web Crypto API, and all Web Crypto API methods are available on a new interface: SubtleCrypto.
The subtle property gives access to an object implementing it.
[!WARNING] The Web Crypto API provides a number of low-level cryptographic primitives. It’s very easy to misuse them, and the pitfalls involved can be very subtle.
Even assuming you use the basic cryptographic functions correctly, secure key management and overall security system design are extremely hard to get right, and are generally the domain of specialist security experts.
Errors in security system design and implementation can make the security of the system completely ineffective.
Please learn and experiment, but don’t guarantee or imply the security of your work before an individual knowledgeable in this subject matter thoroughly reviews it. The Crypto 101 Course can be a great place to start learning about the design and implementation of secure systems.
Interfaces
Crypto- : Provides basic cryptography features, such as a cryptographically strong random number generator, and access to cryptographic primitives via a
SubtleCryptoobject. An object of this type can be accessed in the global scope usingcryptoorcrypto.
- : Provides basic cryptography features, such as a cryptographically strong random number generator, and access to cryptographic primitives via a
SubtleCrypto- : Represents an object that provides low-level cryptographic functions for key generation, encryption, decryption, key wrapping and unwrapping, and so on.
CryptoKey- : Represents a cryptographic key obtained from one of the
SubtleCryptomethodsgenerateKey(),deriveKey(),importKey(), orunwrapKey().
- : Represents a cryptographic key obtained from one of the
Dictionaries
AesCbcParams- : Represents the object that should be passed as the
algorithmparameter intoencrypt(),decrypt(),wrapKey(), orunwrapKey(), when using the AES-CBC algorithm.
- : Represents the object that should be passed as the
AesCtrParams- : Represents the object that should be passed as the
algorithmparameter intoencrypt(),decrypt(),wrapKey(), orunwrapKey(), when using the AES-CTR algorithm.
- : Represents the object that should be passed as the
AesGcmParams- : Represents the object that should be passed as the
algorithmparameter intoencrypt(),decrypt(),wrapKey(), orunwrapKey(), when using the AES-GCM algorithm.
- : Represents the object that should be passed as the
AesKeyGenParams- : Represents the object that should be passed as the
algorithmparameter intogenerateKey(), when generating an AES key: that is, when the algorithm is identified as any of AES-CBC, AES-CTR, AES-GCM, or AES-KW.
- : Represents the object that should be passed as the
CryptoKeyPair- : Represents a public and private key pair used for an asymmetric cryptography algorithm.
EcKeyGenParams- : Represents the object that should be passed as the
algorithmparameter intogenerateKey(), when generating any elliptic-curve-based key pair: that is, when the algorithm is identified as either of ECDSA or ECDH.
- : Represents the object that should be passed as the
EcKeyImportParams- : Represents the object that should be passed as the
algorithmparameter intoimportKey()orunwrapKey(), when generating any elliptic-curve-based key pair: that is, when the algorithm is identified as either of ECDSA or ECDH.
- : Represents the object that should be passed as the
EcdhKeyDeriveParams- : Represents the object that should be passed as the
algorithmparameter intoderiveKey(), when using the ECDH algorithm.
- : Represents the object that should be passed as the
EcdsaParamsHkdfParams- : Represents the object that should be passed as the
algorithmparameter intoderiveKey(), when using the HKDF algorithm.
- : Represents the object that should be passed as the
HmacImportParams- : Represents the object that should be passed as the
algorithmparameter intoimportKey()orunwrapKey(), when generating a key for the HMAC algorithm.
- : Represents the object that should be passed as the
HmacKeyGenParams- : Represents the object that should be passed as the
algorithmparameter intogenerateKey(), when generating a key for the HMAC algorithm.
- : Represents the object that should be passed as the
Pbkdf2Params- : Represents the object that should be passed as the
algorithmparameter intoderiveKey(), when using the PBKDF2 algorithm.
- : Represents the object that should be passed as the
RsaHashedImportParams- : Represents the object that should be passed as the
algorithmparameter intoimportKey()orunwrapKey(), when importing any RSA-based key pair: that is, when the algorithm is identified as any of RSASSA-PKCS1-v1_5, RSA-PSS, or RSA-OAEP.
- : Represents the object that should be passed as the
RsaHashedKeyGenParams- : Represents the object that should be passed as the
algorithmparameter intogenerateKey(), when generating any RSA-based key pair: that is, when the algorithm is identified as any of RSASSA-PKCS1-v1_5, RSA-PSS, or RSA-OAEP.
- : Represents the object that should be passed as the
RsaOaepParams- : Represents the object that should be passed as the
algorithmparameter intoencrypt(),decrypt(),wrapKey(), orunwrapKey(), when using the RSA_OAEP algorithm.
- : Represents the object that should be passed as the
RsaPssParams
Extensions to other interfaces
crypto- : Represents the
Cryptoobject associated with the global object in the main thread scope.
- : Represents the
crypto- : Represents
Cryptoobject associated with the global object in worker scope.
- : Represents