diff --git a/.cirrus.yml b/.cirrus.yml index a435b11f..4db97b5c 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -13,8 +13,8 @@ freebsd_task: - opam env pin_packages_script: - - opam install -y --deps-only -t ./mirage-crypto.opam ./mirage-crypto-rng.opam ./mirage-crypto-rng-lwt.opam ./mirage-crypto-rng-mirage.opam ./mirage-crypto-ec.opam ./mirage-crypto-pk.opam + - opam install -y --deps-only -t ./mirage-crypto.opam ./mirage-crypto-rng.opam ./mirage-crypto-rng-mirage.opam ./mirage-crypto-ec.opam ./mirage-crypto-pk.opam - test_script: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec + test_script: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec test_mirage_script: eval `opam env` && ./.test-mirage.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9d5415b..d7dd4fc6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,18 +23,17 @@ jobs: with: opam-local-packages: | *.opam - !mirage-crypto-rng-eio.opam !mirage-crypto-rng-miou-unix.opam ocaml-compiler: ${{ matrix.ocaml-version }} - name: Install dependencies - run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-lwt mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec mirage-crypto-rng-async + run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec - name: Build - run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec,mirage-crypto-rng-async + run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec - name: Test - run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec,mirage-crypto-rng-async + run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec build-test-ocaml-5: name : Tests with OCaml 5 @@ -57,15 +56,14 @@ jobs: opam-local-packages: | mirage-crypto.opam mirage-crypto-rng.opam - mirage-crypto-rng-eio.opam mirage-crypto-rng-miou-unix.opam ocaml-compiler: ${{ matrix.ocaml-version }} - name: Install dependencies - run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-eio mirage-crypto-rng-miou-unix + run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-miou-unix - name: Build - run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-eio,mirage-crypto-rng-miou-unix + run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-miou-unix - name: Test - run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-eio,mirage-crypto-rng-miou-unix + run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-miou-unix diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 453831ca..c5a72694 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -26,16 +26,14 @@ jobs: default: https://github.com/ocaml/opam-repository.git opam-local-packages: | *.opam - !mirage-crypto-rng-async.opam - !mirage-crypto-rng-eio.opam !mirage-crypto-rng-miou-unix.opam ocaml-compiler: ${{ matrix.ocaml-version }} - name: Install dependencies - run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-lwt mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec + run: opam install --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec - name: Build - run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec + run: opam exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec - name: Test - run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec + run: opam exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec diff --git a/ci/build-test.sh b/ci/build-test.sh index c2c48bde..d8be0f0f 100644 --- a/ci/build-test.sh +++ b/ci/build-test.sh @@ -81,7 +81,7 @@ opamrun update # Build logic # 2024-02-09: Remove mirage-crypto-pk on Windows since no portable GMP library (used by Zarith). # 2024-02-24: Remove mirage-crypto-ec on Windows since it results in test failures. -packages_TOPOLOGICALSORT="mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage" +packages_TOPOLOGICALSORT="mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-mirage" case "$dkml_host_abi" in windows_*) packages_TOPOLOGICALSORT="$packages_TOPOLOGICALSORT" diff --git a/mirage-crypto-rng-async.opam b/mirage-crypto-rng-async.opam deleted file mode 100644 index f9da9228..00000000 --- a/mirage-crypto-rng-async.opam +++ /dev/null @@ -1,31 +0,0 @@ -opam-version: "2.0" -homepage: "https://github.com/mirage/mirage-crypto" -dev-repo: "git+https://github.com/mirage/mirage-crypto.git" -bug-reports: "https://github.com/mirage/mirage-crypto/issues" -doc: "https://mirage.github.io/mirage-crypto/doc" -authors: ["David Kaloper " "Hannes Mehnert " ] -maintainer: "Hannes Mehnert " -license: "ISC" -synopsis: "Feed the entropy source in an Async-friendly way" - -build: [ ["dune" "subst"] {dev} - ["dune" "build" "-p" name "-j" jobs ] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] - -depends: [ - "ocaml" {>= "4.13.0"} - "dune" {>= "2.7"} - "dune-configurator" {>= "2.0.0"} - "async" {>= "v0.14"} - "logs" - "mirage-crypto-rng" {=version} - "ohex" {with-test & >= "0.2.0"} -] -available: os != "win32" -description: """ - -Mirage-crypto-rng-async feeds the entropy source for Mirage_crypto_rng-based -random number generator implementations, in an Async-friendly way. -""" - -x-maintenance-intent: [ "(latest)" ] diff --git a/mirage-crypto-rng-eio.opam b/mirage-crypto-rng-eio.opam deleted file mode 100644 index 759548cf..00000000 --- a/mirage-crypto-rng-eio.opam +++ /dev/null @@ -1,31 +0,0 @@ -opam-version: "2.0" -homepage: "https://github.com/mirage/mirage-crypto" -dev-repo: "git+https://github.com/mirage/mirage-crypto.git" -bug-reports: "https://github.com/mirage/mirage-crypto/issues" -doc: "https://mirage.github.io/mirage-crypto/doc" -authors: ["Bikal Gurung " ] -maintainer: "Bikal Gurung " -license: "ISC" -synopsis: "Feed the entropy source in an eio-friendly way" - -build: [ ["dune" "subst"] {dev} - ["dune" "build" "-p" name "-j" jobs ] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] - -depends: [ - "ocaml" {>= "5.0.0"} - "dune" {>= "2.7"} - "eio" {>= "0.12"} - "logs" - "mirage-crypto-rng" {=version} - "duration" - "mtime" - "cstruct" {>= "6.1.0"} - "eio_main" {with-test} - "ohex" {with-test & >= "0.2.0"} -] -description: """ -Mirage-crypto-rng-eio feeds the entropy source for Mirage_crypto_rng-based -random number generator implementations, in an eio-friendly way. -""" -x-maintenance-intent: [ "(latest)" ] diff --git a/mirage-crypto-rng-lwt.opam b/mirage-crypto-rng-lwt.opam deleted file mode 100644 index 8fb89d8f..00000000 --- a/mirage-crypto-rng-lwt.opam +++ /dev/null @@ -1,27 +0,0 @@ -opam-version: "2.0" -homepage: "https://github.com/mirage/mirage-crypto" -dev-repo: "git+https://github.com/mirage/mirage-crypto.git" -bug-reports: "https://github.com/mirage/mirage-crypto/issues" -doc: "https://mirage.github.io/mirage-crypto/doc" -authors: ["David Kaloper " "Hannes Mehnert " ] -maintainer: "Hannes Mehnert " -license: "ISC" -synopsis: "A cryptographically secure PRNG" - -build: [ ["dune" "subst"] {dev} - ["dune" "build" "-p" name "-j" jobs ] - ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] - -depends: [ - "ocaml" {>= "4.13.0"} - "dune" {>= "2.7"} - "duration" - "logs" - "mirage-crypto-rng" {=version} - "mtime" {>= "1.0.0"} - "lwt" {>= "4.0.0"} -] -description: """ -Mirage-crypto-rng-lwt provides entropy collection code for the RNG using Lwt. -""" -x-maintenance-intent: [ "(latest)" ] diff --git a/rng/async/dune b/rng/async/dune deleted file mode 100644 index d09c88ec..00000000 --- a/rng/async/dune +++ /dev/null @@ -1,5 +0,0 @@ -(library - (name mirage_crypto_rng_async) - (public_name mirage-crypto-rng-async) - (modules mirage_crypto_rng_async) - (libraries async mirage-crypto-rng mirage-crypto-rng.unix logs)) diff --git a/rng/async/mirage_crypto_rng_async.ml b/rng/async/mirage_crypto_rng_async.ml deleted file mode 100644 index ef4d282d..00000000 --- a/rng/async/mirage_crypto_rng_async.ml +++ /dev/null @@ -1,84 +0,0 @@ -open Core -open Async - -open Mirage_crypto_rng - -let src = Logs.Src.create "mirage-crypto-rng-async" ~doc:"Mirage crypto RNG Async" -module Log = (val Logs.src_log src : Logs.LOG) - -let running = ref false - -let ns_since_epoch time_source () = - Synchronous_time_source.now time_source - |> Time_ns.to_int_ns_since_epoch - |> Int64.of_int - -let periodically_collect_cpu_entropy time_source span = - match Entropy.cpu_rng with - | Error `Not_supported -> () - | Ok cpu_rng -> - Synchronous_time_source.run_at_intervals - time_source - span - (cpu_rng None) - -let periodically_collect_getrandom_entropy time_source span = - let source = Entropy.register_source "getrandom" in - Synchronous_time_source.run_at_intervals - time_source - span - (fun () -> - let per_pool = 8 in - let size = per_pool * pools None in - let random = Mirage_crypto_rng_unix.getrandom size in - let idx = ref 0 in - let f () = - incr idx; - Ok (String.sub random ~pos:(per_pool * (pred !idx)) ~len:per_pool) - in - Entropy.feed_pools None source f) - -let read_cpu_counter_at_the_start_of_every_cycle () = - Scheduler.Expert.run_every_cycle_start - (Entropy.timer_accumulator None) - -let getrandom_init i = - let data = Mirage_crypto_rng_unix.getrandom 128 in - Entropy.header i data - -let initialize ?g ?time_source ?(sleep = Time_ns.Span.of_int_sec 1) generator = - let time_source = - Option.value ~default:(Synchronous_time_source.wall_clock ()) time_source - in - if !running then - Log.debug - (fun m -> m "Mirage_crypto_rng_async.initialize has already been called, \ - ignoring this call.") - else begin - (try - let _ = default_generator () in - Log.warn (fun m -> m "Mirage_crypto_rng.default_generator has already \ - been set (but not via \ - Mirage_crypto_rng_async.initialize). Please check \ - that this is intentional"); - with - No_default_generator -> ()); - running := true; - let seed = - (* getrandom_init might block, but this is initialization so prima facie, it - doesn't matter. *) - let init = - Entropy.[ bootstrap ; whirlwind_bootstrap ; bootstrap ; getrandom_init ] - in - List.mapi ~f:(fun i f -> f i) init |> String.concat ~sep:"" - in - let rng = - create ?g ~seed ~time:(ns_since_epoch time_source) generator - in - set_default_generator rng; - periodically_collect_cpu_entropy time_source sleep; - periodically_collect_getrandom_entropy - time_source - (Time_ns.Span.scale_int sleep 10); - read_cpu_counter_at_the_start_of_every_cycle (); - end diff --git a/rng/async/mirage_crypto_rng_async.mli b/rng/async/mirage_crypto_rng_async.mli deleted file mode 100644 index 78d35266..00000000 --- a/rng/async/mirage_crypto_rng_async.mli +++ /dev/null @@ -1,19 +0,0 @@ -open! Core -open! Async - -(** {b RNG} seeding on {b Async}. - - This module initializes a Fortuna RNG with [getrandom()], and CPU RNG. -*) - -(** [initialize ~sleep generator] will bring the RNG into a working state. The - argument [sleep] is measured in ns (default 1s), and used to sleep between - collection of entropy from the CPU RNG, every [10 * sleep] getrandom is used - to collect entropy. *) -val initialize - : ?g:'a - -> ?time_source:Synchronous_time_source.t - -> ?sleep:Time_ns.Span.t - -> 'a Mirage_crypto_rng.generator - -> unit -[@@deprecated "Use 'Mirage_crypto_rng_unix.use_default ()' instead."] diff --git a/rng/eio/dune b/rng/eio/dune deleted file mode 100644 index 44df0317..00000000 --- a/rng/eio/dune +++ /dev/null @@ -1,4 +0,0 @@ -(library - (name mirage_crypto_rng_eio) - (public_name mirage-crypto-rng-eio) - (libraries eio logs mirage-crypto-rng duration mtime cstruct)) diff --git a/rng/eio/mirage_crypto_rng_eio.ml b/rng/eio/mirage_crypto_rng_eio.ml deleted file mode 100644 index 811f5b15..00000000 --- a/rng/eio/mirage_crypto_rng_eio.ml +++ /dev/null @@ -1,87 +0,0 @@ -open Mirage_crypto_rng - -type 'a env = < - clock: [> ] Eio.Time.clock; - mono_clock: [> ] Eio.Time.Mono.t; - secure_random: [> ] Eio.Flow.source; - .. -> as 'a - -let src = Logs.Src.create "mirage-crypto-rng-eio" ~doc:"Mirage crypto RNG Eio" -module Log = (val Logs.src_log src: Logs.LOG) - -let getrandom env i = - let buf = Cstruct.create i in - Eio.Flow.read_exact env#secure_random buf; - Cstruct.to_string buf - -let getrandom_init env i = - let data = getrandom env 128 in - Entropy.header i data - -let rec periodic env f delta = - f (); - Eio.Time.sleep env#clock (Duration.to_f delta); - periodic env f delta - -let periodically_feed_entropy env delta source = - let task () = - let per_pool = 8 in - let size = per_pool * pools None in - let random = getrandom env size in - let idx = ref 0 in - let f () = - incr idx; - Ok (String.sub random (per_pool * (pred !idx)) per_pool) - in - Entropy.feed_pools None source f - in - periodic env task delta - -let rdrand_task env delta = - match Entropy.cpu_rng with - | Error `Not_supported -> [] - | Ok cpu_rng -> [ fun () -> periodic env (cpu_rng None) delta ] - -let running = ref false - -let run - ?g - ?(sleep = Duration.of_sec 1) - generator - env - fn - = - if !running then begin - Log.debug - (fun m -> m "Mirage_crypto_rng_eio.initialize has already been called, \ - ignoring this call."); - fn () - end - else begin - running := true; - Fun.protect - ~finally:(fun () -> - running := false; - unset_default_generator ()) - (fun () -> - (try - let _ = default_generator () in - Log.warn (fun m -> m "Mirage_crypto_rng.default_generator has already \ - been set, check that this call is intentional"); - with - No_default_generator -> ()); - let seed = - let init = - Entropy.[ bootstrap ; whirlwind_bootstrap ; bootstrap ; getrandom_init env ] in - List.mapi (fun i f -> f i) init |> String.concat "" - in - let time () = - Eio.Stdenv.mono_clock env |> Eio.Time.Mono.now |> Mtime.to_uint64_ns - in - let rng = create ?g ~seed ~time generator in - set_default_generator rng; - let source = Entropy.register_source "getrandom" in - let feed_entropy () = periodically_feed_entropy env (Int64.mul sleep 10L) source in - Eio.Fiber.any (rdrand_task env sleep @ [feed_entropy ; fn])) - end diff --git a/rng/eio/mirage_crypto_rng_eio.mli b/rng/eio/mirage_crypto_rng_eio.mli deleted file mode 100644 index e14c0f3d..00000000 --- a/rng/eio/mirage_crypto_rng_eio.mli +++ /dev/null @@ -1,42 +0,0 @@ -(** {b RNG} seeding on {b Eio backends}. - - This module initializes a given random number generator with [getrandom()] and a CPU RNG. - [Eio.Stdenv.secure_random] is used as the [getrandom()] implementation. -*) - -type 'a env = < - clock: [> ]Eio.Time.clock; - mono_clock: [> ]Eio.Time.Mono.t; - secure_random: [> ] Eio.Flow.source; - .. -> as 'a - -(** [run ~g ~sleep gen env fn] will bring the RNG into a working state. The argument - [sleep] is measured in ns (default 1s), and is used to sleep between collection - of entropy from the CPU RNG. Every [10 * sleep] getrandom is used to collect - entropy. - - {b Note} In a multi-domain setting [run] ensures that entropy collection, feeding - and RNG setup are limited to one domain. - - [fn] is the main function that will have access to a running RNG. - - [g] [gen] denotes random number generator scheme to be used, eg [Mirage_crypto_rng.Fortuna]. - - [[ - open Mirage_crypto_rng - - let () = - Eio_main.run @@ fun env -> - Mirage_crypto_rng_eio.run (module Fortuna) env @@ fun () -> - let random_num = Mirage_crypto_rng.generate 32 in - Printf.printf "Random number: %S%!" (Cstruct.to_string random_num) - ]] -*) -val run - : ?g:'a - -> ?sleep:int64 - -> 'a Mirage_crypto_rng.generator - -> _ env - -> (unit -> 'b) -> 'b -[@@deprecated "Use 'Mirage_crypto_rng_unix.use_default ()' instead."] diff --git a/rng/lwt/dune b/rng/lwt/dune deleted file mode 100644 index 99ad358c..00000000 --- a/rng/lwt/dune +++ /dev/null @@ -1,6 +0,0 @@ -(library - (name mirage_crypto_rng_lwt) - (public_name mirage-crypto-rng-lwt) - (modules mirage_crypto_rng_lwt) - (libraries lwt lwt.unix mirage-crypto-rng mirage-crypto-rng.unix duration - mtime.clock.os logs)) diff --git a/rng/lwt/mirage_crypto_rng_lwt.ml b/rng/lwt/mirage_crypto_rng_lwt.ml deleted file mode 100644 index 001e8460..00000000 --- a/rng/lwt/mirage_crypto_rng_lwt.ml +++ /dev/null @@ -1,69 +0,0 @@ -open Mirage_crypto_rng - -let src = Logs.Src.create "mirage-crypto-rng-lwt" ~doc:"Mirage crypto RNG Lwt" -module Log = (val Logs.src_log src : Logs.LOG) - -let periodic f delta = - let open Lwt.Infix in - Lwt.async (fun () -> - let rec one () = - f (); Lwt_unix.sleep (Duration.to_f delta) >>= one - in - one ()) - -let getrandom_task delta source = - let task () = - let per_pool = 8 in - let size = per_pool * pools None in - let random = Mirage_crypto_rng_unix.getrandom size in - let idx = ref 0 in - let f () = - incr idx; - Ok (String.sub random (per_pool * (pred !idx)) per_pool) - in - Entropy.feed_pools None source f - in - periodic task delta - -let rdrand_task delta = - match Entropy.cpu_rng with - | Error `Not_supported -> () - | Ok cpu_rng -> periodic (cpu_rng None) delta - -let running = ref false - -let getrandom_init i = - let data = Mirage_crypto_rng_unix.getrandom 128 in - Entropy.header i data - -let initialize (type a) ?g ?(sleep = Duration.of_sec 1) (rng : a generator) = - if !running then - Log.debug - (fun m -> m "Mirage_crypto_rng_lwt.initialize has already been called, \ - ignoring this call.") - else begin - (try - let _ = default_generator () in - Log.warn (fun m -> m "Mirage_crypto_rng.default_generator has already \ - been set (but not via \ - Mirage_crypto_rng_lwt.initialize). Please check \ - that this is intentional"); - with - No_default_generator -> ()); - running := true; - let seed = - let init = - Entropy.[ bootstrap ; whirlwind_bootstrap ; bootstrap ; getrandom_init ] - in - List.mapi (fun i f -> f i) init |> String.concat "" - in - let rng = create ?g ~seed ~time:Mtime_clock.elapsed_ns rng in - set_default_generator rng; - rdrand_task sleep; - let source = Entropy.register_source "getrandom" in - getrandom_task (Int64.mul sleep 10L) source; - let _ = - Lwt_main.Enter_iter_hooks.add_first (Entropy.timer_accumulator None) - in - () - end diff --git a/rng/lwt/mirage_crypto_rng_lwt.mli b/rng/lwt/mirage_crypto_rng_lwt.mli deleted file mode 100644 index af251d3c..00000000 --- a/rng/lwt/mirage_crypto_rng_lwt.mli +++ /dev/null @@ -1,12 +0,0 @@ -(** {b RNG} seeding on {b Lwt}. - - This module initializes a Fortuna RNG with [getrandom()], and CPU RNG. -*) - -(** [initialize ~g ~sleep generator] will bring the RNG into a working state. - The argument [sleep] is measured in ns (default 1s), and used to sleep - between collection of entropy from the CPU RNG, every [10 * sleep] getrandom - is used to collect entropy. -*) -val initialize : ?g:'a -> ?sleep:int64 -> 'a Mirage_crypto_rng.generator -> unit -[@@deprecated "Use 'Mirage_crypto_rng_unix.use_default ()' instead."] diff --git a/tests/dune b/tests/dune index dd80599f..b6be7ac6 100644 --- a/tests/dune +++ b/tests/dune @@ -31,18 +31,12 @@ (libraries mirage-crypto-rng-mirage mirage-unix mirage-time-unix mirage-clock-unix duration ohex)) -(test - (name test_entropy_collection_async) - (modules test_entropy_collection_async) - (package mirage-crypto-rng-async) - (libraries mirage-crypto-rng-async ohex)) - (test (name test_entropy) (modules test_entropy) (package mirage-crypto-rng) (libraries mirage-crypto-rng ohex) - (enabled_if (or (<> %{architecture} "arm64") (<> %{architecture} "riscv64")))) + (enabled_if (and (<> %{architecture} "arm64") (<> %{architecture} "riscv64")))) ; see https://github.com/mirage/mirage-crypto/issues/216 (test @@ -62,12 +56,6 @@ (libraries alcotest mirage-crypto-ec wycheproof digestif asn1-combinators) (package mirage-crypto-ec)) -(tests - (names test_eio_rng test_eio_entropy_collection) - (modules test_eio_rng test_eio_entropy_collection) - (libraries mirage-crypto-rng-eio duration eio_main ohex) - (package mirage-crypto-rng-eio)) - (tests (names test_miou_rng test_miou_entropy_collection) (modules test_miou_rng test_miou_entropy_collection) diff --git a/tests/test_eio_entropy_collection.ml b/tests/test_eio_entropy_collection.ml deleted file mode 100644 index 09a4cade..00000000 --- a/tests/test_eio_entropy_collection.ml +++ /dev/null @@ -1,38 +0,0 @@ -module Printing_rng = struct - type g = unit - - let block = 16 - let create ?time:_ () = () - let generate_into ~g:_ _buf ~off:_ _len = assert false - let seeded ~g:_ = true - let pools = 1 - - let reseed ~g:_ data = - Format.printf "reseeding:@.%a@.%!" (Ohex.pp_hexdump ()) data - - let accumulate ~g:_ source = - let print data = - Format.printf "accumulate: (src: %a) %a@.%!" - Mirage_crypto_rng.Entropy.pp_source source Ohex.pp data - in - `Acc print -end - -let () = - Eio_main.run @@ fun env -> - begin[@alert "-deprecated"] - Mirage_crypto_rng_eio.run (module Printing_rng) env @@ fun () -> - Eio.Fiber.both - begin fun () -> - let sleep = Duration.(of_sec 2 |> to_f) in - Eio.Time.sleep env#clock sleep - end - begin fun () -> - Format.printf "entropy sources: %a@,%!" - (fun ppf -> List.iter (fun x -> - Mirage_crypto_rng.Entropy.pp_source ppf x; - Format.pp_print_space ppf ())) - (Mirage_crypto_rng.Entropy.sources ()) - end - end - diff --git a/tests/test_eio_rng.ml b/tests/test_eio_rng.ml deleted file mode 100644 index 5e5ce5a7..00000000 --- a/tests/test_eio_rng.ml +++ /dev/null @@ -1,13 +0,0 @@ -open Mirage_crypto_rng - -let () = - Eio_main.run @@ fun env -> - begin[@alert "-deprecated"] - Mirage_crypto_rng_eio.run (module Fortuna) env @@ fun () -> - let random_num = Mirage_crypto_rng.generate 32 in - assert (String.length random_num = 32); - Printf.printf "32 bit random number: %S\n%!" random_num; - let random_num = Mirage_crypto_rng.generate 16 in - assert (String.length random_num = 16); - Printf.printf "16 bit random number: %S\n%!" random_num; - end diff --git a/tests/test_entropy_collection_async.ml b/tests/test_entropy_collection_async.ml deleted file mode 100644 index 2b4b54d1..00000000 --- a/tests/test_entropy_collection_async.ml +++ /dev/null @@ -1,46 +0,0 @@ -open Core -open Async - -module Printing_rng = struct - type g = unit - - let block = 16 - - let create ?time:_ () = () - - let generate_into ~g:_ _buf ~off:_ _len = assert false - - let reseed ~g:_ data = - Format.printf "reseeding:@.%a@.%!" (Ohex.pp_hexdump ()) data - - let accumulate ~g:_ source = - let print data = - Format.printf "accumulate: (src: %a) %a@.%!" - Mirage_crypto_rng.Entropy.pp_source source Ohex.pp data - in - `Acc print - - let seeded ~g:_ = true - let pools = 1 -end - -module E = Mirage_crypto_rng_async - - -let main () = - begin[@alert "-deprecated"] - E.initialize (module Printing_rng); - end; - Format.printf "entropy sources: %a@,%!" - (fun ppf -> List.iter ~f:(fun x -> - Mirage_crypto_rng.Entropy.pp_source ppf x; - Format.pp_print_space ppf ())) - (Mirage_crypto_rng.Entropy.sources ()); - don't_wait_for ( - Time_source.after - (Time_source.wall_clock ()) - (Time_ns.Span.of_int_sec 10) - >>= fun () -> - Shutdown.exit 0) - -let () = ignore (Scheduler.go_main ~main () : never_returns)