From bb600e29d25f363dde109b8d08bf981279003323 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Tue, 7 May 2024 15:53:09 +0200 Subject: [PATCH] use mirage-crypto-rng directly, no need for mirage-random-test --- tcpip.opam | 4 ++-- test/dune | 2 +- test/low_level.ml | 2 +- test/test.ml | 3 +-- test/test_deadlock.ml | 4 ++-- test/test_icmpv4.ml | 4 ++-- test/test_ipv6.ml | 4 ++-- test/test_udp.ml | 4 ++-- test/vnetif_common.ml | 10 +++++----- 9 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tcpip.opam b/tcpip.opam index a272b7ae..d7244549 100644 --- a/tcpip.opam +++ b/tcpip.opam @@ -30,7 +30,7 @@ depends: [ "cstruct-lwt" "mirage-net" {>= "3.0.0"} "mirage-clock" {>= "3.0.0"} - "mirage-random" {>= "2.0.0"} + "mirage-random" {>= "2.0.0" & < "4.0.0"} "mirage-time" {>= "2.0.0"} "ipaddr" {>= "5.0.0"} "macaddr" {>="4.0.0"} @@ -48,7 +48,7 @@ depends: [ "alcotest" {with-test & >="1.5.0"} "pcap-format" {with-test} "mirage-clock-unix" {with-test & >= "3.0.0"} - "mirage-random-test" {with-test & >= "0.1.0"} + "mirage-crypto-rng" {with-test & >= "0.11.0"} "ipaddr-cstruct" "macaddr-cstruct" "lru" {>= "0.3.0"} diff --git a/test/dune b/test/dune index 4315ca3e..56f13488 100644 --- a/test/dune +++ b/test/dune @@ -1,6 +1,6 @@ (test (name test) - (libraries alcotest mirage-random-test lwt.unix logs logs.fmt + (libraries alcotest mirage-crypto-rng mirage-crypto-rng.unix lwt.unix logs logs.fmt mirage-flow mirage-vnetif mirage-clock-unix pcap-format duration mirage-random arp arp.mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4v6-socket tcpip.tcpv4v6-socket diff --git a/test/low_level.ml b/test/low_level.ml index 204bac1d..5c4f59c6 100644 --- a/test/low_level.ml +++ b/test/low_level.ml @@ -12,7 +12,7 @@ module Time = Vnetif_common.Time module V = Vnetif.Make(Vnetif_backends.Basic) module E = Ethernet.Make(V) module A = Arp.Make(E)(Time) -module I = Static_ipv4.Make(Mirage_random_test)(Vnetif_common.Clock)(E)(A) +module I = Static_ipv4.Make(Mirage_crypto_rng)(Vnetif_common.Clock)(E)(A) module Wire = Tcp.Wire module WIRE = Wire.Make(I) module Tcp_wire = Tcp.Tcp_wire diff --git a/test/test.ml b/test/test.ml index 92e8c0b8..3e8e7d80 100644 --- a/test/test.ml +++ b/test/test.ml @@ -39,8 +39,7 @@ let run test () = let () = Printexc.record_backtrace true; - (* someone has to call Mirage_random_test.initialize () *) - Mirage_random_test.initialize (); + Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna); (* enable logging to stdout for all modules *) Logs.set_reporter (Logs_fmt.reporter ()); Logs.set_level ~all:true (Some Logs.Debug); diff --git a/test/test_deadlock.ml b/test/test_deadlock.ml index 6f1bf86b..0021412c 100644 --- a/test/test_deadlock.ml +++ b/test/test_deadlock.ml @@ -10,7 +10,7 @@ module Client_log = (val Logs.src_log client_log : Logs.LOG) module TCPIP = struct - module RANDOM = Mirage_random_test + module RANDOM = Mirage_crypto_rng module TIME = struct @@ -80,7 +80,7 @@ let test_digest netif1 netif2 = TCPIP.make `Server netif2 >>= fun server_stack -> let send_data () = - let data = Mirage_random_test.generate 100_000_000 |> Cstruct.to_string in + let data = Mirage_crypto_rng.generate 100_000_000 |> Cstruct.to_string in let t0 = Unix.gettimeofday () in TCPIP.TCP.create_connection TCPIP.(tcp @@ tcpip server_stack) (Ipaddr.V4 TCPIP.client_ip, port) >>= function diff --git a/test/test_icmpv4.ml b/test/test_icmpv4.ml index 7455f980..2b26a1b6 100644 --- a/test/test_icmpv4.ml +++ b/test/test_icmpv4.ml @@ -18,10 +18,10 @@ type decomposed = { ethernet_header : Ethernet.Packet.t; } -module Ip = Static_ipv4.Make(Mirage_random_test)(Mclock)(E)(Static_arp) +module Ip = Static_ipv4.Make(Mirage_crypto_rng)(Mclock)(E)(Static_arp) module Icmp = Icmpv4.Make(Ip) -module Udp = Udp.Make(Ip)(Mirage_random_test) +module Udp = Udp.Make(Ip)(Mirage_crypto_rng) type stack = { backend : B.t; diff --git a/test/test_ipv6.ml b/test/test_ipv6.ml index 7e5ea5bf..fcea9fa9 100644 --- a/test/test_ipv6.ml +++ b/test/test_ipv6.ml @@ -4,8 +4,8 @@ module B = Vnetif_backends.Basic module V = Vnetif.Make(B) module E = Ethernet.Make(V) -module Ipv6 = Ipv6.Make(V)(E)(Mirage_random_test)(Time)(Mclock) -module Udp = Udp.Make(Ipv6)(Mirage_random_test) +module Ipv6 = Ipv6.Make(V)(E)(Mirage_crypto_rng)(Time)(Mclock) +module Udp = Udp.Make(Ipv6)(Mirage_crypto_rng) open Lwt.Infix let ip = diff --git a/test/test_udp.ml b/test/test_udp.ml index 2f7d8bb5..d049f567 100644 --- a/test/test_udp.ml +++ b/test/test_udp.ml @@ -5,8 +5,8 @@ module B = Basic_backend.Make module V = Vnetif.Make(B) module E = Ethernet.Make(V) module Static_arp = Static_arp.Make(E)(Time) -module Ip = Static_ipv4.Make(Mirage_random_test)(Mclock)(E)(Static_arp) -module Udp = Udp.Make(Ip)(Mirage_random_test) +module Ip = Static_ipv4.Make(Mirage_crypto_rng)(Mclock)(E)(Static_arp) +module Udp = Udp.Make(Ip)(Mirage_crypto_rng) type stack = { backend : B.t; diff --git a/test/vnetif_common.ml b/test/vnetif_common.ml index 2791e505..d25bdedb 100644 --- a/test/vnetif_common.ml +++ b/test/vnetif_common.ml @@ -70,15 +70,15 @@ end module E = Ethernet.Make(V) module A = Arp.Make(E)(Time) - module Ip4 = Static_ipv4.Make(Mirage_random_test)(Clock)(E)(A) + module Ip4 = Static_ipv4.Make(Mirage_crypto_rng)(Clock)(E)(A) module Icmp4 = Icmpv4.Make(Ip4) - module Ip6 = Ipv6.Make(V)(E)(Mirage_random_test)(Time)(Clock) + module Ip6 = Ipv6.Make(V)(E)(Mirage_crypto_rng)(Time)(Clock) module Ip46 = Tcpip_stack_direct.IPV4V6(Ip4)(Ip6) - module U = Udp.Make(Ip46)(Mirage_random_test) - module T = Tcp.Flow.Make(Ip46)(Time)(Clock)(Mirage_random_test) + module U = Udp.Make(Ip46)(Mirage_crypto_rng) + module T = Tcp.Flow.Make(Ip46)(Time)(Clock)(Mirage_crypto_rng) module Stack = - Tcpip_stack_direct.MakeV4V6(Time)(Mirage_random_test)(V)(E)(A)(Ip46)(Icmp4)(U)(T) + Tcpip_stack_direct.MakeV4V6(Time)(Mirage_crypto_rng)(V)(E)(A)(Ip46)(Icmp4)(U)(T) let create_backend () = B.create ()