package hacl-star

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Agile, multiplexing hashing interface, exposing 4 variants of SHA-2 (SHA-224, SHA-256, SHA-384, SHA-512), 4 variants of SHA-3 (SHA3-224, SHA3-256, SHA3-384, SHA3-512), BLAKE2 (both BLAKE2b and BLAKE2s), and 2 legacy algorithms (SHA-1, MD5). It offers both direct hashing and a streaming interface.

Direct interface

val hash : alg:SharedDefs.HashDefs.alg -> msg:bytes -> bytes

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
  • 264 for BLAKE2s
  • 2128 for BLAKE2b
type t
val init : alg:SharedDefs.HashDefs.alg -> t

init alg allocates the internal state for algorithm alg and returns a t.

val update : st:t -> msg:bytes -> unit

update st msg updates the internal state st with the contents of msg.

val finish : st:t -> bytes

finish st returns the digest without invalidating the internal state st.

module Noalloc : sig ... end

Versions of these functions which write their output in a buffer passed in as an argument

OCaml

Innovation. Community. Security.