package hacl-star
Install
Dune Dependency
Authors
Maintainers
Sources
md5=fdcd7a590913428d5d3142872d7089a0
sha256=47bf253f804ec369b2fbc76c892ba89275fde17d7444d291d5eb5c179a05e174
sha512=1f2c144852566464ef72caeb21567b125fa9eb395d9e25b64bb110f116e75b7befdb3e3e190dd8a3f59c74b36d70bb4eb6dcd7ba62061fd91b4c263de0f29c4f
doc/hacl-star/Hacl_star/EverCrypt/Hash/index.html
Module EverCrypt.Hash
Source
Agile, multiplexing hashing interface, exposing 4 variants of SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512), BLAKE2, and 2 legacy algorithms (SHA-1, MD5). It offers both direct hashing and a streaming interface.
Note: The agile BLAKE2 interface is NOT currently multiplexing and it only exposes the portable C implementations of BLAKE2b and BLAKE2s. Optimised, platform-specific versions are aviailable in Hacl.
For digest
, its size must match the size of the digest produced by the algorithm being used:
- SHA-224: 28 bytes
- SHA-256: 32 bytes
- SHA-384: 48 bytes
- SHA-512: 64 bytes
- BLAKE2b: <= 64 bytes
- BLAKE2s: <= 32 bytes
The legacy algorithms (marked deprecated
) should NOT be used for cryptographic purposes. For these, the size of the digest is:
- SHA-1: 20 bytes
- MD5: 16 bytes
Direct interface
hash alg msg
hashes msg
using algorithm alg
and returns the digest.
Streaming interface
To use the agile streaming interface, users first need to initialise an internal state using init
. The state will then need to be passed to every call to update
and finish
. Both update
and finish
can be called as many times as needed without invalidating the state. Users are not required to manually free the state.
When using the streaming interface, the total number of bytes passed through update
must not exceed
- 261 for SHA-224, SHA-256, and the legacy algorithms
- 2125 for SHA-384 and SHA-512
init alg
allocates the internal state for algorithm alg
and returns a t
.
update st msg
updates the internal state st
with the contents of msg
.
finish st
returns the digest without invalidating the internal state st
.