Classes
A cryptographic key chain which allows signing of data to prevent tampering, but also allows for easy key rotation without needing to re-sign the data.
- indexOf(): Promise<number>data: Data,digest: string
Given
dataand adigest, return the current index of the key in thekeyspassed the constructor that was used to generate the digest. If no key can be found, the method returns-1. - length(): number
Number of keys
- sign(data: Data): Promise<string>
Take
dataand return a SHA256 HMAC digest that uses the current 0 index of thekeyspassed to the constructor. This digest is in the form of a URL safe base64 encoded string. - verify(): Promise<boolean>data: Data,digest: string
Given
dataand adigest, verify that one of thekeysprovided the constructor was used to generate thedigest. Returnstrueif one of the keys was used, otherwisefalse.
Functions
When checking the values of cryptographic hashes are equal, default comparisons can be susceptible to timing based attacks, where attacker is able to find out information about the host system by repeatedly checking response times to equality comparisons of values.
Interfaces
- subtle: StdSubtleCrypto
Extension to the
crypto.SubtleCryptointerface.
Extensions to the web standard SubtleCrypto interface.
- digest(): Promise<ArrayBuffer>algorithm: DigestAlgorithm,data:BufferSource
| AsyncIterable<BufferSource>
| Iterable<BufferSource>Returns a new
Promiseobject that will digestdatausing the specifiedAlgorithmIdentifier. - digestSync(): ArrayBufferalgorithm: DigestAlgorithm,data: BufferSource | Iterable<BufferSource>
Returns a ArrayBuffer with the result of digesting
datausing the specifiedAlgorithmIdentifier.
Type Aliases
Types of data that can be signed cryptographically.
Extended digest algorithms accepted by stdCrypto.subtle.digest.
Extended digest algorithm names.
Extended digest algorithm objects.
FNV (Fowler/Noll/Vo) algorithms names.
Types of keys that can be used to sign data.
An algorithm name supported by std/crypto/_wasm.
Variables
An wrapper for WebCrypto adding support for additional non-standard algorithms, but delegating to the runtime WebCrypto implementation whenever possible.
| "BLAKE2B-160"
| "BLAKE2B-224"
| "BLAKE2B-256"
| "BLAKE2B-384"
| "BLAKE2B"
| "BLAKE2S"
| "BLAKE3"
| "KECCAK-224"
| "KECCAK-256"
| "KECCAK-384"
| "KECCAK-512"
| "SHA-384"
| "SHA3-224"
| "SHA3-256"
| "SHA3-384"
| "SHA3-512"
| "SHAKE128"
| "SHAKE256"
| "TIGER"
| "RIPEMD-160"
| "SHA-224"
| "SHA-256"
| "SHA-512"
| "MD4"
| "MD5"
| "SHA-1"
All cryptographic hash/digest algorithms supported by std/crypto/_wasm.