Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit e6f7fd69 authored by Stephane Glondu's avatar Stephane Glondu

Simplify LwtRandom

parent f441fb36
......@@ -27,26 +27,18 @@ open Web_serializable_j
let spool_dir = ref "."
let make_rng = Lwt_preemptive.detach (fun () ->
pseudo_rng (random_string secure_rng 16)
)
module type LWT_RANDOM = Signatures.RANDOM with type 'a t = 'a Lwt.t
module type LWT_RNG = sig
val rng : rng Lwt.t
end
module MakeLwtRandom (X : LWT_RNG) = struct
module LwtRandom = struct
type 'a t = 'a Lwt.t
let return = Lwt.return
let bind = Lwt.bind
let fail = Lwt.fail
let prng = lazy (pseudo_rng (random_string secure_rng 16))
let random q =
let size = Z.bit_length q / 8 + 1 in
let%lwt rng = X.rng in
let%lwt rng = Lwt_preemptive.detach Lazy.force prng in
let r = random_string rng size in
return Z.(of_bits r mod q)
......
......@@ -19,21 +19,12 @@
(* <http://www.gnu.org/licenses/>. *)
(**************************************************************************)
open Signatures
open Web_serializable_t
val spool_dir : string ref
val make_rng : unit -> Platform.rng Lwt.t
(** Create a pseudo random number generator initialized by a 128-bit
secure random seed. *)
module type LWT_RANDOM = Signatures.RANDOM with type 'a t = 'a Lwt.t
module type LWT_RNG = sig
val rng : Platform.rng Lwt.t
end
module MakeLwtRandom (X : LWT_RNG) : LWT_RANDOM
module LwtRandom : RANDOM with type 'a t = 'a Lwt.t
(** Lwt-compatible random number generation. *)
type error =
......
......@@ -39,8 +39,6 @@ module PString = String
open Eliom_service
open Eliom_registration
module LwtRandom = MakeLwtRandom (struct let rng = make_rng () end)
(* Table with elections in setup mode. *)
let election_stable = Ocsipersist.open_table "site_setup"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment