diff --git a/src/ipv4/dune b/src/ipv4/dune index 2a70bb3f..07e6bd93 100644 --- a/src/ipv4/dune +++ b/src/ipv4/dune @@ -3,6 +3,6 @@ (public_name tcpip.ipv4) (instrumentation (backend bisect_ppx)) - (libraries logs ipaddr cstruct tcpip tcpip.udp tcpip.checksum mirage-random - mirage-clock randomconv lru arp.mirage ethernet) + (libraries logs ipaddr cstruct tcpip tcpip.udp tcpip.checksum + mirage-crypto-rng-mirage mirage-clock randomconv lru arp.mirage ethernet) (wrapped false)) diff --git a/src/ipv4/static_ipv4.ml b/src/ipv4/static_ipv4.ml index 1b9065d7..75a7c299 100644 --- a/src/ipv4/static_ipv4.ml +++ b/src/ipv4/static_ipv4.ml @@ -19,7 +19,7 @@ open Lwt.Infix let src = Logs.Src.create "ipv4" ~doc:"Mirage IPv4" module Log = (val Logs.src_log src : Logs.LOG) -module Make (R: Mirage_random.S) (C: Mirage_clock.MCLOCK) (Ethernet: Ethernet.S) (Arpv4 : Arp.S) = struct +module Make (R: Mirage_crypto_rng_mirage.S) (C: Mirage_clock.MCLOCK) (Ethernet: Ethernet.S) (Arpv4 : Arp.S) = struct module Routing = Routing.Make(Log)(Arpv4) (** IO operation errors *) diff --git a/src/ipv4/static_ipv4.mli b/src/ipv4/static_ipv4.mli index 603873b2..c206dfe5 100644 --- a/src/ipv4/static_ipv4.mli +++ b/src/ipv4/static_ipv4.mli @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) -module Make (R: Mirage_random.S) (C: Mirage_clock.MCLOCK) (E: Ethernet.S) (A: Arp.S) : sig +module Make (R: Mirage_crypto_rng_mirage.S) (C: Mirage_clock.MCLOCK) (E: Ethernet.S) (A: Arp.S) : sig include Tcpip.Ip.S with type ipaddr = Ipaddr.V4.t and type prefix = Ipaddr.V4.Prefix.t val connect : ?no_init:bool -> cidr:Ipaddr.V4.Prefix.t -> ?gateway:Ipaddr.V4.t -> diff --git a/src/ipv6/dune b/src/ipv6/dune index 792cc214..b40c804c 100644 --- a/src/ipv6/dune +++ b/src/ipv6/dune @@ -4,6 +4,6 @@ (instrumentation (backend bisect_ppx)) (libraries logs mirage-time mirage-net macaddr-cstruct tcpip.checksum - mirage-clock duration ipaddr cstruct mirage-random tcpip randomconv - ethernet ipaddr-cstruct) + mirage-clock duration ipaddr cstruct tcpip randomconv + mirage-crypto-rng-mirage ethernet ipaddr-cstruct) (wrapped false)) diff --git a/src/ipv6/ipv6.ml b/src/ipv6/ipv6.ml index 37ddbd43..e132a9af 100644 --- a/src/ipv6/ipv6.ml +++ b/src/ipv6/ipv6.ml @@ -23,7 +23,7 @@ open Lwt.Infix module Make (N : Mirage_net.S) (E : Ethernet.S) - (R : Mirage_random.S) + (R : Mirage_crypto_rng_mirage.S) (T : Mirage_time.S) (C : Mirage_clock.MCLOCK) = struct type ipaddr = Ipaddr.V6.t diff --git a/src/ipv6/ipv6.mli b/src/ipv6/ipv6.mli index 33aac241..788397fd 100644 --- a/src/ipv6/ipv6.mli +++ b/src/ipv6/ipv6.mli @@ -16,7 +16,7 @@ module Make (N : Mirage_net.S) (E : Ethernet.S) - (R : Mirage_random.S) + (R : Mirage_crypto_rng_mirage.S) (T : Mirage_time.S) (Clock : Mirage_clock.MCLOCK) : sig include Tcpip.Ip.S with type ipaddr = Ipaddr.V6.t and type prefix = Ipaddr.V6.Prefix.t diff --git a/src/ipv6/ndpv6.mli b/src/ipv6/ndpv6.mli index a353681b..2c033235 100644 --- a/src/ipv6/ndpv6.mli +++ b/src/ipv6/ndpv6.mli @@ -27,7 +27,7 @@ type event = type context -val local : handle_ra:bool -> now:time -> random:(int -> Cstruct.t) -> Macaddr.t -> +val local : handle_ra:bool -> now:time -> random:(int -> string) -> Macaddr.t -> context * (Macaddr.t * int * (Cstruct.t -> int)) list (** [local ~handle_ra ~now ~random mac] is a pair [ctx, outs] where [ctx] is a local IPv6 context associated to the hardware address [mac]. [outs] is a list of ethif packets @@ -48,7 +48,7 @@ val select_source : context -> ipaddr -> ipaddr (** [select_source ctx ip] returns the ip that should be put in the source field of a packet destined to [ip]. *) -val handle : now:time -> random:(int -> Cstruct.t) -> context -> Cstruct.t -> +val handle : now:time -> random:(int -> string) -> context -> Cstruct.t -> context * (Macaddr.t * int * (Cstruct.t -> int)) list * event list (** [handle ~now ~random ctx buf] handles an incoming ipv6 packet. It returns [ctx', bufs, evs] where [ctx'] is the updated context, [bufs] is a list of diff --git a/src/stack-direct/dune b/src/stack-direct/dune index f0f32983..9096c8d6 100644 --- a/src/stack-direct/dune +++ b/src/stack-direct/dune @@ -3,5 +3,5 @@ (public_name tcpip.stack-direct) (instrumentation (backend bisect_ppx)) - (libraries logs ipaddr lwt fmt mirage-time mirage-random mirage-net ethernet - arp.mirage tcpip.icmpv4 tcpip.udp tcpip.tcp)) + (libraries logs ipaddr lwt fmt mirage-time mirage-crypto-rng-mirage mirage-net + ethernet arp.mirage tcpip.icmpv4 tcpip.udp tcpip.tcp)) diff --git a/src/stack-direct/tcpip_stack_direct.ml b/src/stack-direct/tcpip_stack_direct.ml index fd9e4968..2f78cbcc 100644 --- a/src/stack-direct/tcpip_stack_direct.ml +++ b/src/stack-direct/tcpip_stack_direct.ml @@ -147,7 +147,7 @@ end module MakeV4V6 (Time : Mirage_time.S) - (Random : Mirage_random.S) + (Random : Mirage_crypto_rng_mirage.S) (Netif : Mirage_net.S) (Eth : Ethernet.S) (Arpv4 : Arp.S) diff --git a/src/stack-direct/tcpip_stack_direct.mli b/src/stack-direct/tcpip_stack_direct.mli index e2b4d634..adddeb32 100644 --- a/src/stack-direct/tcpip_stack_direct.mli +++ b/src/stack-direct/tcpip_stack_direct.mli @@ -24,7 +24,7 @@ end module MakeV4V6 (Time : Mirage_time.S) - (Random : Mirage_random.S) + (Random : Mirage_crypto_rng_mirage.S) (Netif : Mirage_net.S) (Ethernet : Ethernet.S) (Arpv4 : Arp.S) diff --git a/src/tcp/dune b/src/tcp/dune index 8bf6ad9d..e4c28692 100644 --- a/src/tcp/dune +++ b/src/tcp/dune @@ -4,5 +4,5 @@ (instrumentation (backend bisect_ppx)) (libraries logs ipaddr cstruct lwt-dllist tcpip.checksum - tcpip duration randomconv fmt mirage-time mirage-clock mirage-random - mirage-flow metrics)) + tcpip duration randomconv fmt mirage-time mirage-clock + mirage-crypto-rng-mirage mirage-flow metrics)) diff --git a/src/tcp/flow.ml b/src/tcp/flow.ml index a1ccf9d5..0382d589 100644 --- a/src/tcp/flow.ml +++ b/src/tcp/flow.ml @@ -20,7 +20,7 @@ open Lwt.Infix let src = Logs.Src.create "tcp.pcb" ~doc:"Mirage TCP PCB module" module Log = (val Logs.src_log src : Logs.LOG) -module Make(Ip: Tcpip.Ip.S)(Time:Mirage_time.S)(Clock:Mirage_clock.MCLOCK)(Random:Mirage_random.S) = +module Make(Ip: Tcpip.Ip.S)(Time:Mirage_time.S)(Clock:Mirage_clock.MCLOCK)(Random:Mirage_crypto_rng_mirage.S) = struct module ACK = Ack.Immediate diff --git a/src/tcp/flow.mli b/src/tcp/flow.mli index c3c1c2b2..71281088 100644 --- a/src/tcp/flow.mli +++ b/src/tcp/flow.mli @@ -17,7 +17,7 @@ module Make (IP:Tcpip.Ip.S) (TM:Mirage_time.S) (C:Mirage_clock.MCLOCK) - (R:Mirage_random.S) : sig + (R:Mirage_crypto_rng_mirage.S) : sig include Tcpip.Tcp.S with type ipaddr = IP.ipaddr val connect : IP.t -> t Lwt.t diff --git a/src/udp/dune b/src/udp/dune index e28d9d1c..0c0ef5ec 100644 --- a/src/udp/dune +++ b/src/udp/dune @@ -3,5 +3,5 @@ (public_name tcpip.udp) (instrumentation (backend bisect_ppx)) - (libraries mirage-random logs tcpip randomconv tcpip.checksum) + (libraries mirage-crypto-rng-mirage logs tcpip randomconv tcpip.checksum) (wrapped false)) diff --git a/src/udp/udp.ml b/src/udp/udp.ml index 347b681f..17d13aa6 100644 --- a/src/udp/udp.ml +++ b/src/udp/udp.ml @@ -19,7 +19,7 @@ open Lwt.Infix let src = Logs.Src.create "udp" ~doc:"Mirage UDP" module Log = (val Logs.src_log src : Logs.LOG) -module Make (Ip : Tcpip.Ip.S) (Random : Mirage_random.S) = struct +module Make (Ip : Tcpip.Ip.S) (Random : Mirage_crypto_rng_mirage.S) = struct type ipaddr = Ip.ipaddr type callback = src:ipaddr -> dst:ipaddr -> src_port:int -> Cstruct.t -> unit Lwt.t diff --git a/src/udp/udp.mli b/src/udp/udp.mli index fc25180b..ef083d9b 100644 --- a/src/udp/udp.mli +++ b/src/udp/udp.mli @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *) -module Make (IP : Tcpip.Ip.S) (R : Mirage_random.S) : sig +module Make (IP : Tcpip.Ip.S) (R : Mirage_crypto_rng_mirage.S) : sig include Tcpip.Udp.S with type ipaddr = IP.ipaddr val connect : IP.t -> t Lwt.t end diff --git a/tcpip.opam b/tcpip.opam index 70c4403d..84d72eed 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" & < "4.0.0"} + "mirage-crypto-rng-mirage" {>= "1.0.0"} "mirage-time" {>= "2.0.0"} "ipaddr" {>= "5.6.0"} "macaddr" {>="4.0.0"} @@ -40,7 +40,7 @@ depends: [ "lwt-dllist" "logs" {>= "0.6.0"} "duration" - "randomconv" {< "0.2.0"} + "randomconv" {>= "0.2.0"} "ethernet" {>= "3.0.0"} "arp" {>= "3.0.0"} "mirage-flow" {>= "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-crypto-rng" {with-test & >= "0.11.0" & < "1.0"} + "mirage-crypto-rng" {with-test & >= "1.0.0"} "ipaddr-cstruct" "macaddr-cstruct" "lru" {>= "0.3.0"} diff --git a/test/dune b/test/dune index 56f13488..3ca1f1a9 100644 --- a/test/dune +++ b/test/dune @@ -2,7 +2,7 @@ (name test) (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 + mirage-crypto-rng-mirage arp arp.mirage ethernet tcpip.ipv4 tcpip.tcp tcpip.udp tcpip.stack-direct tcpip.icmpv4 tcpip.udpv4v6-socket tcpip.tcpv4v6-socket tcpip.icmpv4-socket tcpip.stack-socket tcpip.ipv6 ipaddr-cstruct macaddr-cstruct tcpip) diff --git a/test/test_deadlock.ml b/test/test_deadlock.ml index d7efd616..2069462a 100644 --- a/test/test_deadlock.ml +++ b/test/test_deadlock.ml @@ -79,7 +79,7 @@ let test_digest netif1 netif2 = TCPIP.make `Server netif2 >>= fun server_stack -> let send_data () = - let data = Mirage_crypto_rng.generate 100_000_000 |> Cstruct.to_string in + let data = Mirage_crypto_rng.generate 100_000_000 in let t0 = Unix.gettimeofday () in TCPIP.TCP.create_connection TCPIP.(tcp @@ tcpip server_stack) (Ipaddr.V4 TCPIP.client_ip, port) >>= function