[ANN] Digestif 0.7.1

Greetings everyone,

I’m happy to announce a new release of digestif 0.7.1, available for installation via OPAM.

Digestif is a library which contains some hashes function like:

  • MD5
  • SHA1
  • SHA224
  • SHA256
  • SHA384
  • SHA512
  • BLAKE2B
  • BLAKE2S
  • RIPEMD160

And the recently added

  • WHIRLPOOL

Particularities of digestif:

Linking trick:

This project provides 2 implementations of the hash algorithms: one written in C (digestif.c) and the other in OCaml (digestif.ocaml), each one fulfilling the same interface. In order to choose your implementation, you can simply use the linking trick, by selecting at link time the implementation you wish to use. The C implementation will provide a smaller execution time, while the OCaml one will bring more portability to your project (ex: to JavaScript with js_of_ocaml).

Constant time:

Some applications require that secret values are compared in constant time. This Functions like String.equal do not have this property, so we provide a small package — eqaf — providing a constant-time equal function. Digestif uses it to check equality of hashes — it also exposes unsafe_compare if you don’t care about timing attacks in your application.

Run-time lock:

When calling C code from the OCaml environment, the garbage collector states needs to be saved as C code may need allocated values, which the GC could move or change. This is why we implemented the hash algorithms with bigarrays, which are contained in a specific area of the GC, and never will be moved. This way, we were able to remove the run-time lock when calling the others C functions, improving the speed of the computations. A behavior even more useful as the GC is global in a multi-threaded environment, locking it pauses every threads: With digestif you can compute the hash in parallel of others operations without affecting your performances.

10 Likes