@@ -0,0 +1,41 @@
1+{ lib
2+, buildDunePackage
3+, fetchurl
4+, ocaml
5+
6+, alcotest
7+, cstruct
8+, mirage-crypto
9+}:
10+
11+buildDunePackage rec {
12+ pname = "chacha";
13+ version = "1.0.0";
14+
15+ src = fetchurl {
16+ url = "https://github.com/abeaumont/ocaml-chacha/releases/download/${version}/${pname}-${version}.tbz";
17+ sha256 = "sha256-t8dOMQQDpje0QbuOhjSIa3xnXuXcxMVTLENa/rwdgA4=";
18+ };
19+
20+ useDune2 = true;
21+
22+ minimumOCamlVersion = "4.02";
23+
24+ propagatedBuildInputs = [ cstruct mirage-crypto ];
25+
26+ # alcotest isn't available for OCaml < 4.05 due to fmt
27+ doCheck = lib.versionAtLeast ocaml.version "4.05";
28+ checkInputs = [ alcotest ];
29+
30+ meta = {
31+ homepage = "https://github.com/abeaumont/ocaml-chacha";
32+ description = "ChaCha20, ChaCha12 and ChaCha8 encryption functions, in OCaml";
33+ longDescription = ''
34+ An OCaml implementation of ChaCha functions, both ChaCha20 and the reduced
35+ ChaCha8 and ChaCha12 functions. The hot loop is implemented in C for efficiency
36+ reasons.
37+ '';
38+ license = lib.licenses.bsd2;
39+ maintainers = with lib.maintainers; [ fufexan ];
40+ };
41+}