Skip to content

Commit b1854e9

Browse files
ushitora-anqouvbmithr
authored andcommitted
use mirage-crypto-rng as csprng
1 parent a5d7cb0 commit b1854e9

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

Diff for: core/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
(name websocket)
33
(public_name websocket)
44
(modules sha1 websocket)
5-
(libraries astring base64 ocplib-endian conduit cohttp))
5+
(libraries astring base64 ocplib-endian conduit cohttp mirage-crypto-rng))

Diff for: core/websocket.ml

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ let b64_encoded_sha1sum s = Base64.encode_exn (Sha1.sha_1 s)
2121
let websocket_uuid = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
2222

2323
module Rng = struct
24-
let init ?(state = Random.get_state ()) () len =
25-
String.v ~len (fun _ -> Char.of_byte (Random.State.bits state land 0xFF))
24+
let init () len = Mirage_crypto_rng.generate len |> Cstruct.to_string
2625
end
2726

2827
module Frame = struct

Diff for: core/websocket.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ val upgrade_present : Cohttp.Header.t -> bool
2222
exception Protocol_error of string
2323

2424
module Rng : sig
25-
val init : ?state:Random.State.t -> unit -> int -> string
25+
val init : unit -> int -> string
2626
(** [init ?state ()] is a function that returns a string of random
2727
bytes of length equal to its argument. *)
2828
end

Diff for: dune-project

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
(conduit (>= 5.1.0))
3434
(cohttp (>= 5.0.0))
3535
(ocplib-endian (>= 1.0))
36-
(astring (>= 0.8.3))))
36+
(astring (>= 0.8.3))
37+
mirage-crypto-rng))
3738

3839
(package
3940
(name websocket-async)

Diff for: websocket.opam

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ depends: [
3030
"cohttp" {>= "5.0.0"}
3131
"ocplib-endian" {>= "1.0"}
3232
"astring" {>= "0.8.3"}
33+
"mirage-crypto-rng"
3334
"odoc" {with-doc}
3435
]
3536
build: [

0 commit comments

Comments
 (0)