package digestif

  1. Overview
  2. Docs
Hashes implementations (SHA*, RIPEMD160, BLAKE2* and MD5)

Install

Dune Dependency

Authors

Maintainers

Sources

digestif-v0.7.3.tbz
sha256=fa0e3fd543b84ab4fb11e2f2333ba51678b0d607895f0f5528e0f640c382cd8e
sha512=7c2efbd63d893ab743efa9de0e9c31f47ef84e5319a2293529c8ffd7ced40e2d5906c43ee011bb0aa0020a96e7f67bc5e5e66ac43bafc598d7e08bbeb781a0c5

Description

Digestif is a toolbox to provide hashes implementations in C and OCaml.

It uses the linking trick and user can decide at the end to use the C implementation or the OCaml implementation.

We provides implementation of:

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

Published: 09 Jul 2019

README

Digestif - Hash algorithms in C and OCaml

Digestif is a toolbox which implements hashes:

  • MD5

  • SHA1

  • SHA224

  • SHA256

  • SHA384

  • SHA512

  • WHIRLPOOL

  • BLAKE2B

  • BLAKE2S

  • RIPEMD160

Digestif uses a trick about linking and let the end-user to choose which implementation he wants to use. We provide 2 implementations:

  • C implementation with digestif.c

  • OCaml implementation with digestif.ocaml

Both are well-tested. However, OCaml implementation is slower than the C implementation.

Note: The linking trick requires digestif.c or digestif.ocaml to be the first of your dependencies.

Home page: http://din.osau.re/

Contact: Romain Calascibetta <romain.calascibet ta@gmail.com>

API

For each hash, we implement the same API which is referentially transparent. Then, on the top of these, we reflect functions (like digesti or hmaci) with GADT - however, conversion from GADT to hash type is not possible (but you can destruct GADT with to_raw_string).

Equal/Compare function

We deciced to protect users to timing-attack. In this case, Digestif.equal (by eqaf package) compares hashes in constant-time.

However, we provide unsafe_compare function too which is not a constant time function. In some contexts, like ocaml-git, we don't care about timing attack and we use unsafe_compare - then, we need to make a wrap where we rename unsafe_compare to compare to be able to use it in some functors like Map.Make or Set.Make.

It's little annoying to do that but it forces the user to get the right question about security issues. So, please, don't ask to rename this function.

MirageOS

Of course, this package is available to be used on MirageOS (both implementations). User is able to compile digestif.ocaml with js_of_ocaml and this package is platform agnostic.

Build Requirements

  • OCaml >= 4.03.0 (may be less but need test)

  • base-bytes meta-package

  • base-bigarray meta-package

  • dune to build the project

If you want to compile the test program, you need:

  • alcotest

Credits

This work is from the nocrypto library and the Vincent hanquez's work in ocaml-sha.

All credits appear in the begin of files and this library is motivated by two reasons:

  • delete the dependancy with nocrypto if you don't use the encryption (and common) part

  • aggregate all hashes functions in one library

Dependencies (5)

  1. base-bigarray
  2. base-bytes
  3. eqaf
  4. dune >= "1.9.2" & < "2.6"
  5. ocaml >= "4.03.0" & < "5.0"

Dev Dependencies (2)

  1. alcotest with-test & < "1.0.0"
  2. fmt with-test

Used by (29)

  1. archetype < "1.2.2"
  2. aws >= "1.2"
  3. aws-s3 >= "4.2.0"
  4. dkim-mirage >= "0.2.0"
  5. docfd >= "2.1.0"
  6. dream < "1.0.0~alpha3"
  7. dream-httpaf
  8. git >= "2.0.0" & < "3.0.0"
  9. graphql-cohttp >= "0.9.0"
  10. index-bench >= "1.5.0"
  11. irmin >= "2.0.0" & < "2.3.0"
  12. irmin-git >= "2.0.0" & < "2.3.0"
  13. irmin-http = "2.0.0"
  14. irmin-tezos
  15. irmin-unix >= "2.0.0" & < "2.3.0"
  16. jupyter-kernel >= "0.4"
  17. learn-ocaml >= "0.12"
  18. learn-ocaml-client
  19. miou
  20. nocoiner
  21. noise >= "0.2.0"
  22. ometrics >= "0.1.2"
  23. soupault >= "4.4.0"
  24. swhid_compute
  25. tezos-base58
  26. tezos-context < "11.0" | >= "12.0" & < "16.0"
  27. tezos-storage
  28. tezos-store < "12.0"
  29. zeit

Conflicts (3)

  1. mirage-runtime < "4.0.0"
  2. ocaml-freestanding < "0.4.3"
  3. mirage-xen-posix < "3.1.0"