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