1{
2 lib,
3 buildDunePackage,
4 fetchFromGitHub,
5 fetchpatch,
6 ocaml,
7
8 alcotest,
9 cstruct,
10 mirage-crypto,
11}:
12
13buildDunePackage rec {
14 pname = "chacha";
15 version = "1.1.0";
16
17 src = fetchFromGitHub {
18 owner = "abeaumont";
19 repo = "ocaml-chacha";
20 rev = version;
21 hash = "sha256-PmeiFloU0k3SqOK1VjaliiCEzDzrzyMSasgnO5fJS1k=";
22 };
23
24 # Ensure compatibility with cstruct ≥ 6.1.0
25 patches = [
26 (fetchpatch {
27 url = "https://github.com/abeaumont/ocaml-chacha/commit/fbe4a0a808226229728a68f278adf370251196fd.patch";
28 sha256 = "sha256-y7X9toFDrgdv3qmFmUs7K7QS+Gy45rRLulKy48m7uqc=";
29 })
30 ];
31
32 propagatedBuildInputs = [
33 cstruct
34 mirage-crypto
35 ];
36
37 # alcotest isn't available for OCaml < 4.05 due to fmt
38 doCheck = lib.versionAtLeast ocaml.version "4.05";
39 checkInputs = [ alcotest ];
40
41 meta = {
42 homepage = "https://github.com/abeaumont/ocaml-chacha";
43 description = "ChaCha20, ChaCha12 and ChaCha8 encryption functions, in OCaml";
44 longDescription = ''
45 An OCaml implementation of ChaCha functions, both ChaCha20 and the reduced
46 ChaCha8 and ChaCha12 functions. The hot loop is implemented in C for efficiency
47 reasons.
48 '';
49 license = lib.licenses.bsd2;
50 maintainers = with lib.maintainers; [ fufexan ];
51 broken = true; # Not compatible with mirage-crypto ≥ 1.0
52 };
53}