-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dune #158
base: master
Are you sure you want to change the base?
Dune #158
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,15 @@ _build | |
*.install | ||
*.native | ||
*.byte | ||
.merlin | ||
|
||
*~ | ||
\.\#* | ||
\#*# | ||
|
||
gmon.out | ||
.gdb_history | ||
*.prof | ||
perf.data* | ||
*.json | ||
rondom |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executables | ||
(names speed) | ||
(modules speed) | ||
(libraries nocrypto)) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let evar = "NOCRYPTO_ACCELERATE" | ||
let needs = [`SSSE3; `AES; `PCLMULQDQ] | ||
let flags = ["-DACCELERATE"; "-mssse3"; "-maes"; "-mpclmul"] | ||
|
||
let _ = | ||
let auto = match Cpuid.supports needs with Ok true -> flags | _ -> [] in | ||
let fs = match Sys.getenv evar with | ||
"true" -> flags | ||
| "false" -> [] | ||
| _ -> auto | ||
| exception Not_found -> auto in | ||
Format.(printf "(@[%a@])%!" (fun ppf -> List.iter (fprintf ppf "%s@ ")) fs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(executables | ||
(names cfg) | ||
(libraries dune.configurator result cpuid)) |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,3 @@ | ||||||
(lang dune 1.7) | ||||||
(name nocrypto) | ||||||
(version %%VERSION_NUM%%) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that this is necessary
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, it's not strictly necessary. But it adds version to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. META files are automatically generated with the correct version. For example, ̀cstruct There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not what I'm seeing while playing with a pinned package. I won't pretend to understand why. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(library | ||
(name nocrypto_entropy_lwt) | ||
(public_name nocrypto.lwt) | ||
(synopsis "Unix+Lwt entropy seeding") | ||
(libraries nocrypto nocrypto.unix lwt.unix) | ||
(optional)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
open Lwt | ||
open Lwt.Infix | ||
open Nocrypto | ||
|
||
let chunk = 32 | ||
and period = 30 | ||
and device = Nocrypto_entropy_unix.sys_rng | ||
|
||
|
||
let mvar_map v f = | ||
Lwt_mvar.take v >>= fun x -> | ||
catch (fun () -> f x >>= Lwt_mvar.put v) | ||
(fun exn -> Lwt_mvar.put v x >>= fun () -> fail exn) | ||
Lwt.catch (fun () -> f x >>= Lwt_mvar.put v) | ||
(fun exn -> Lwt_mvar.put v x >>= fun () -> Lwt.fail exn) | ||
|
||
let some x = Some x | ||
|
||
[@@@ocaml.warning "-3"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that's for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or more precisely, |
||
|
||
type t = { | ||
fd : Lwt_unix.file_descr ; | ||
|
@@ -25,34 +25,36 @@ let background ~period f = | |
and live = ref false | ||
and period = float period in | ||
fun () -> | ||
let t1 = !last | ||
and t2 = Unix.gettimeofday () in | ||
if (not !live) && (t2 -. t1 >= period) then begin | ||
last := t2 ; | ||
let t = Unix.gettimeofday () in | ||
if (not !live) && (t -. !last >= period) then begin | ||
last := t ; | ||
live := true ; | ||
async @@ fun () -> f () >|= fun () -> live := false | ||
Lwt.async @@ fun () -> f () >|= fun () -> live := false | ||
end | ||
|
||
let rec read_cs fd cs = | ||
Lwt_bytes.read fd cs.Cstruct.buffer cs.Cstruct.off cs.Cstruct.len >>= | ||
function 0 -> Lwt.return_unit | n -> read_cs fd (Cstruct.shift cs n) | ||
|
||
let attach ~period ?(device = device) g = | ||
Lwt_unix.(openfile device [O_RDONLY] 0) >|= fun fd -> | ||
let buf = Cstruct.create chunk in | ||
let seed () = | ||
Lwt_cstruct.(complete (read fd) buf) >|= fun () -> Rng.reseed ~g buf in | ||
let seed () = read_cs fd buf >|= fun () -> Rng.reseed ~g buf in | ||
let remove = | ||
Lwt_sequence.add_r (background ~period seed) Lwt_main.enter_iter_hooks in | ||
{ g ; fd ; remove } | ||
|
||
let stop t = | ||
Lwt_sequence.remove t.remove ; | ||
catch (fun () -> Lwt_unix.close t.fd) | ||
Unix.(function Unix_error (EBADF, _, _) -> return_unit | exn -> fail exn) | ||
Lwt.(catch (fun () -> Lwt_unix.close t.fd) | ||
Unix.(function Unix_error (EBADF, _, _) -> return_unit | exn -> fail exn)) | ||
|
||
let active = Lwt_mvar.create None | ||
|
||
let initialize () = | ||
Nocrypto_entropy_unix.initialize () ; | ||
let g = !Rng.generator in | ||
mvar_map active @@ function | ||
| Some t when t.g == g -> return (Some t) | ||
| Some t when t.g == g -> Lwt.return_some t | ||
| Some t -> stop t >>= fun () -> attach ~period g >|= some | ||
| None -> attach ~period g >|= some |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(library | ||
(name nocrypto_entropy_mirage) | ||
(public_name nocrypto.mirage) | ||
(synopsis "Mirage entropy seeding") | ||
(libraries nocrypto lwt mirage-entropy) | ||
(optional)) |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
opam-version: "2.0" | ||
homepage: "https://github.com/mirleft/ocaml-nocrypto" | ||
dev-repo: "git+https://github.com/mirleft/ocaml-nocrypto.git" | ||
bug-reports: "https://github.com/mirleft/ocaml-nocrypto/issues" | ||
doc: "https://mirleft.github.io/ocaml-nocrypto/doc" | ||
authors: ["David Kaloper <[email protected]>"] | ||
maintainer: "David Kaloper <[email protected]>" | ||
license: "ISC" | ||
synopsis: "Simple crypto for the modern age" | ||
|
||
build: [ ["dune" "subst"] {pinned} | ||
["dune" "build" "-p" name "-j" jobs ] | ||
["dune" "runtest"] {with-test} ] | ||
|
||
depends: [ | ||
"ocaml" {>= "4.03.0"} | ||
"dune" {build & >= "1.7"} | ||
"cpuid" {build} | ||
"ounit" {with-test} | ||
"cstruct" {>="3.0.0"} | ||
"ocplib-endian" | ||
"zarith" | ||
("mirage-no-xen" | ("mirage-xen" & "zarith-xen")) | ||
("mirage-no-solo5" | ("mirage-solo5" & "zarith-freestanding")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these still needed since the mirage packages are removed from this repo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mirage package, Hence the PR: the state of this branch is still incoherent. |
||
] | ||
|
||
depopts: [ "unix" "lwt" "mirage-entropy" ] | ||
|
||
conflicts: [ "mirage-xen" {< "2.2.0"} ] |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should be an error (or at least a warning)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... right, if you set it but not to
true
orfalse
. I was hoping I'd snatch a parser for configuration things from somewhere else, before I start writing that in the discovery tool.I did try to emit text to confirm override, but dune seems to swallow my
stderr
.