Skip to content

Commit d68f01d

Browse files
committed
Nocrypto patches for compatibility with sexplib/ppx_sexp_conv > v0.11.0
ppx_sexp_conv v0.11.0 compiles successfully, but contains an undesired dependency on base, and is thus still marked as conflicting. This is fixed in ppx_sexp_conv v0.11.1. This commit submits @gasche's fixes from mirleft/ocaml-nocrypto#144 and @diml's fixes from mirleft/ocaml-nocrypto#146
1 parent c8cb075 commit d68f01d

7 files changed

+244
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Simpler crypto
2+
3+
4+
nocrypto is a small cryptographic library that puts emphasis on the applicative
5+
style and ease of use. It includes basic ciphers (AES, 3DES, RC4), hashes (MD5,
6+
SHA1, SHA2), public-key primitives (RSA, DSA, DH) and a strong RNG (Fortuna).
7+
8+
RSA timing attacks are countered by blinding. AES timing attacks are avoided by
9+
delegating to AES-NI.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From cad7cfe15ae8eca95c4e284f3a679c35842659f2 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 16:09:16 +0200
4+
Subject: [PATCH 2/6] add missing runtime dependencies in _tags
5+
6+
Binaries in <bench/*>, <tests/*> depend on ppx_sexp_conv's runtime
7+
library within ppx_sexp_conv.
8+
9+
The packed modules <src/nocrypto.cm{x,o}> also depend on the package
10+
ppx_sexp_conv: its presence at pack-creation time influences the
11+
generated .cmi interface, see
12+
13+
https://github.com/ocaml/opam-repository/pull/11628#issuecomment-375697444
14+
15+
Note: the package ppx_sexp_conv.runtime-lib would suffice, but it is
16+
only available as such under recent ppx_sexp_conv versions, so its
17+
explicit use would make the build description (needlessly)
18+
incompatible with older ppx_sexp_conv versions.
19+
---
20+
_tags | 5 +++--
21+
1 file changed, 3 insertions(+), 2 deletions(-)
22+
23+
diff --git a/_tags b/_tags
24+
index 6d4e7de..c2a6610 100644
25+
--- a/_tags
26+
+++ b/_tags
27+
@@ -7,6 +7,7 @@ true: package(bytes), package(cstruct)
28+
<src/*.ml{,i}>: package(zarith), package(sexplib), package(ppx_sexp_conv)
29+
<src/*.cm{x,o}> and not <src/nocrypto.cmx>: for-pack(Nocrypto)
30+
<src/*.cm{,x}a>: link_stubs(src/libnocrypto_stubs)
31+
+<src/nocrypto.cm{x,o}>: package(ppx_sexp_conv)
32+
33+
<unix>: include
34+
<unix/*.ml{,i}>: package(unix), package(bytes)
35+
@@ -19,7 +20,7 @@ true: package(bytes), package(cstruct)
36+
37+
<**/*.c>: ccopt(--std=c99 -Wall -Wextra -O3)
38+
39+
-<bench/*>: use_nocrypto, package(zarith), package(cstruct.unix)
40+
-<tests/*>: use_nocrypto, package(zarith), package(oUnit)
41+
+<bench/*>: use_nocrypto, package(zarith), package(ppx_sexp_conv)
42+
+<tests/*>: use_nocrypto, package(zarith), package(ppx_sexp_conv), package(oUnit)
43+
44+
<rondom>: -traverse
45+
--
46+
2.17.0
47+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From 55fbc3531afde59ba34cde1c14d99704439756e6 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Tue, 27 Mar 2018 12:00:23 +0200
4+
Subject: [PATCH 4/6] add ppx_sexp_conv as a runtime dependency in the
5+
packaging metadata
6+
7+
---
8+
opam | 2 +-
9+
pkg/META | 2 +-
10+
2 files changed, 2 insertions(+), 2 deletions(-)
11+
12+
diff --git a/opam b/opam
13+
index ad1dbc7..c35570b 100644
14+
--- a/opam
15+
+++ b/opam
16+
@@ -20,7 +20,7 @@ depends: [
17+
"topkg" {build}
18+
"cpuid" {build}
19+
"ocb-stubblr" {build}
20+
- "ppx_sexp_conv" {build}
21+
+ "ppx_sexp_conv"
22+
"oUnit" {test}
23+
"cstruct"
24+
"zarith"
25+
diff --git a/pkg/META b/pkg/META
26+
index 242b2bb..a7929c7 100644
27+
--- a/pkg/META
28+
+++ b/pkg/META
29+
@@ -1,6 +1,6 @@
30+
version = "%%VERSION_NUM%%"
31+
description = "Simple crypto for the modern age"
32+
-requires = "cstruct zarith sexplib"
33+
+requires = "cstruct zarith sexplib ppx_sexp_conv"
34+
archive(byte) = "nocrypto.cma"
35+
archive(native) = "nocrypto.cmxa"
36+
plugin(byte) = "nocrypto.cma"
37+
--
38+
2.17.0
39+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 25e1206eb1b173acdfc7312d072e0583327c4ac0 Mon Sep 17 00:00:00 2001
2+
From: Jeremie Dimino <[email protected]>
3+
Date: Fri, 11 May 2018 15:44:47 +0200
4+
Subject: [PATCH 5/6] Auto-detect ppx_sexp_conv runtime library
5+
6+
---
7+
myocamlbuild.ml | 25 ++++++++++++++++++++++---
8+
pkg/{META => META.in} | 2 +-
9+
2 files changed, 23 insertions(+), 4 deletions(-)
10+
rename pkg/{META => META.in} (95%)
11+
12+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
13+
index 2752315..7b29635 100644
14+
--- a/myocamlbuild.ml
15+
+++ b/myocamlbuild.ml
16+
@@ -1,5 +1,24 @@
17+
open Ocamlbuild_plugin
18+
19+
-let () = dispatch Ocb_stubblr.(
20+
- init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
21+
-)
22+
+let runtime_deps_of_ppx ppx =
23+
+ (Findlib.query "ppx_sexp_conv").dependencies
24+
+ |> List.filter_opt (fun { Findlib.name; _ } ->
25+
+ if name = ppx || name = "ppx_deriving" then
26+
+ None
27+
+ else
28+
+ Some name)
29+
+
30+
+let () = dispatch (fun hook ->
31+
+ Ocb_stubblr.(
32+
+ init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
33+
+ ) hook;
34+
+ match hook with
35+
+ | After_rules ->
36+
+ let meta = "pkg/META" in
37+
+ let meta_in = meta ^ ".in" in
38+
+ rule meta ~dep:meta_in ~prod:meta (fun _ _ ->
39+
+ let deps = String.concat " " (runtime_deps_of_ppx "ppx_sexp_conv") in
40+
+ Echo([String.subst "PPX_SEXP_CONV_RUNTIME" deps
41+
+ (Pathname.read meta_in)],
42+
+ meta))
43+
+ | _ -> ())
44+
diff --git a/pkg/META b/pkg/META.in
45+
similarity index 95%
46+
rename from pkg/META
47+
rename to pkg/META.in
48+
index a7929c7..0b263d7 100644
49+
--- a/pkg/META
50+
+++ b/pkg/META.in
51+
@@ -1,6 +1,6 @@
52+
version = "%%VERSION_NUM%%"
53+
description = "Simple crypto for the modern age"
54+
-requires = "cstruct zarith sexplib ppx_sexp_conv"
55+
+requires = "cstruct zarith sexplib PPX_SEXP_CONV_RUNTIME"
56+
archive(byte) = "nocrypto.cma"
57+
archive(native) = "nocrypto.cmxa"
58+
plugin(byte) = "nocrypto.cma"
59+
--
60+
2.17.0
61+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 1befe5d2ab60653d1d44fa734d2b8057cf3410db Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 16:07:45 +0200
4+
Subject: [PATCH 6/6] pack+package: workaround ocamlbuild#272
5+
6+
ocamlbuild should pass -package(...) flags to ocamlfind when building
7+
a -pack-ed file, see
8+
9+
https://github.com/ocaml/opam-repository/pull/11628#issuecomment-375697444
10+
---
11+
myocamlbuild.ml | 8 ++++++++
12+
1 file changed, 8 insertions(+)
13+
14+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
15+
index 7b29635..7a5cdb6 100644
16+
--- a/myocamlbuild.ml
17+
+++ b/myocamlbuild.ml
18+
@@ -8,9 +8,17 @@ let runtime_deps_of_ppx ppx =
19+
else
20+
Some name)
21+
22+
+let ocamlfind_and_pack = function
23+
+ | After_rules ->
24+
+ if !Options.use_ocamlfind then
25+
+ pflag ["ocaml"; "pack"] "package"
26+
+ (fun pkg -> S [A "-package"; A pkg]);
27+
+ | _ -> ()
28+
+
29+
let () = dispatch (fun hook ->
30+
Ocb_stubblr.(
31+
init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
32+
+ & ocamlfind_and_pack
33+
) hook;
34+
match hook with
35+
| After_rules ->
36+
--
37+
2.17.0
38+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
opam-version: "1.2"
2+
homepage: "https://github.com/mirleft/ocaml-nocrypto"
3+
dev-repo: "https://github.com/mirleft/ocaml-nocrypto.git"
4+
bug-reports: "https://github.com/mirleft/ocaml-nocrypto/issues"
5+
doc: "https://mirleft.github.io/ocaml-nocrypto/doc"
6+
authors: ["David Kaloper <[email protected]>"]
7+
maintainer: "David Kaloper <[email protected]>"
8+
license: "ISC"
9+
tags: [ "org:mirage" ]
10+
available: [ ocaml-version >= "4.02.0" ]
11+
12+
build: ["ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "--tests" "false"
13+
"--jobs" "1"
14+
"--with-lwt" "%{lwt:installed}%"
15+
"--xen" "%{mirage-xen:installed}%"
16+
"--freestanding" "%{mirage-solo5:installed}%"]
17+
18+
depends: [
19+
"ocamlfind" {build}
20+
"ocamlbuild" {build}
21+
"topkg" {build}
22+
"cpuid" {build}
23+
"ocb-stubblr" {build}
24+
"ppx_deriving" {build}
25+
"ppx_sexp_conv" {>= "113.33.01" & != "v0.11.0"}
26+
"ounit" {test}
27+
"cstruct" {>="2.4.0"}
28+
"cstruct-lwt"
29+
"zarith"
30+
"lwt"
31+
"sexplib"
32+
("mirage-no-xen" | ("mirage-xen" & "mirage-entropy" & "zarith-xen"))
33+
("mirage-no-solo5" | ("mirage-solo5" & "mirage-entropy" & "zarith-freestanding"))
34+
]
35+
36+
conflicts: [
37+
"topkg" {<"0.9.1"}
38+
"ocb-stubblr" {<"0.1.0"}
39+
"mirage-xen" {<"2.2.0"}
40+
"sexplib" {="v0.9.0"}
41+
]
42+
43+
patches: [
44+
"0002-add-missing-runtime-dependencies-in-_tags.patch"
45+
"0004-add-ppx_sexp_conv-as-a-runtime-dependency-in-the-pac.patch"
46+
"0005-Auto-detect-ppx_sexp_conv-runtime-library.patch"
47+
"0006-pack-package-workaround-ocamlbuild-272.patch"
48+
]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
archive: "https://github.com/mirleft/ocaml-nocrypto/releases/download/v0.5.4/nocrypto-0.5.4.tbz"
2+
checksum: "c331a7a4d2a563d1d5ed581aeb849011"

0 commit comments

Comments
 (0)