From d07008a0562d1f83dcab144fdec9fd920deb2b96 Mon Sep 17 00:00:00 2001 From: Guilherme Andrade Date: Sun, 12 Mar 2017 17:20:00 +0000 Subject: Support generation of strong random numbers --- lib/crypto/doc/src/crypto.xml | 46 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'lib/crypto/doc') diff --git a/lib/crypto/doc/src/crypto.xml b/lib/crypto/doc/src/crypto.xml index d0deaceaaf..0697f6a202 100644 --- a/lib/crypto/doc/src/crypto.xml +++ b/lib/crypto/doc/src/crypto.xml @@ -658,10 +658,13 @@

Set the seed for PRNG to the given binary. This calls the - RAND_seed function from openssl. Only use this if the system - you are running on does not have enough "randomness" built in. - Normally this is when - strong_rand_bytes/1 returns low_entropy

+ RAND_seed function from openssl. Only use this if the system + you are running on does not have enough "randomness" built in. + Normally this is when either + strong_rand_bytes/1, + strong_rand_uniform/0 or + strong_rand_uniform/1 + throws low_entropy

@@ -728,6 +731,41 @@ failed due to lack of secure "randomness".

+ + + strong_rand_uniform() -> X + Generate a random floating point number between 0.0 and 1.0 + + X = float() + + +

Generates a random floating pointer number uniformly distributed + in the value range + Uses a cryptographically secure prng seeded and periodically mixed with operating system + provided entropy. By default this is the BN_rand_range method from OpenSSL.

+

May throw exception low_entropy in case the random generator + failed due to lack of secure "randomness".

+

The generated values shall present no more than 51 bits of effective entropy.

+
+
+ + + strong_rand_uniform(N) -> X + Generate a random positive integer between 1 and N + + N = pos_integer() + X = 1..N + + +

Generates a a random positive integer uniformly distributed + in the value range + Uses a cryptographically secure prng seeded and periodically mixed with operating system + provided entropy. By default this is the BN_rand_range method from OpenSSL.

+

May throw exception low_entropy in case the random generator + failed due to lack of secure "randomness".

+
+
+ stream_init(Type, Key) -> State -- cgit v1.2.3