Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
e6f7fd69
Commit
e6f7fd69
authored
Apr 10, 2017
by
Stephane Glondu
Browse files
Simplify LwtRandom
parent
f441fb36
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/web/web_common.ml
View file @
e6f7fd69
...
...
@@ -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
p
rng
in
let
r
=
random_string
rng
size
in
return
Z
.(
of_bits
r
mod
q
)
...
...
src/web/web_common.mli
View file @
e6f7fd69
...
...
@@ -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
=
...
...
src/web/web_site.ml
View file @
e6f7fd69
...
...
@@ -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"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment