From 54cd451fa138c94801a02b091ecf5425290b1ac3 Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Sun, 27 Sep 2015 17:20:27 +0900 Subject: [PATCH 1/8] doc: fix crypto.randomBytes fix description about crypto.randomBytes --- doc/api/crypto.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 093b600871e34c..038d69f801d503 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -660,9 +660,9 @@ Generates cryptographically strong pseudo-random data. Usage: } NOTE: This will block if there is insufficient entropy, although it should -normally never take longer than a few milliseconds. The only time when this -may conceivably block is right after boot, when the whole system is still -low on entropy. +normally never take longer than a few milliseconds. +Under normal circumstances, the only error thrown from this is from RAND_bytes(), which throws when it doesn't have enough entropy. +However, with CheckEntropy, this will block until the system has enough entropy for the OpenSSL pool. ## Class: Certificate From 0d0154d4fcb2588a1afe7e9e7af0e1dbf9c2e57c Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Sun, 27 Sep 2015 17:58:51 +0900 Subject: [PATCH 2/8] doc: update examples about crypto.randomBytes remove outdated examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 038d69f801d503..89eba315c8a659 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -650,19 +650,10 @@ Generates cryptographically strong pseudo-random data. Usage: console.log('Have %d bytes of random data: %s', buf.length, buf); }); - // sync - try { - var buf = crypto.randomBytes(256); - console.log('Have %d bytes of random data: %s', buf.length, buf); - } catch (ex) { - // handle error - // most likely, entropy sources are drained - } - NOTE: This will block if there is insufficient entropy, although it should -normally never take longer than a few milliseconds. -Under normal circumstances, the only error thrown from this is from RAND_bytes(), which throws when it doesn't have enough entropy. -However, with CheckEntropy, this will block until the system has enough entropy for the OpenSSL pool. +normally never take longer than a few milliseconds. The only time when this +may conceivably block is right after boot, when the whole system is still +low on entropy. ## Class: Certificate From a8af4f3f5f8aacfbe2ce8ed612230fd9312dd0de Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Sun, 27 Sep 2015 20:48:12 +0900 Subject: [PATCH 3/8] doc: update examples about crypto.randomBytes fix outdated examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 89eba315c8a659..b55972e67183cf 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -650,6 +650,10 @@ Generates cryptographically strong pseudo-random data. Usage: console.log('Have %d bytes of random data: %s', buf.length, buf); }); + // sync + var buf = crypto.randomBytes(256); + console.log('Have %d bytes of random data: %s', buf.length, buf); + NOTE: This will block if there is insufficient entropy, although it should normally never take longer than a few milliseconds. The only time when this may conceivably block is right after boot, when the whole system is still From 69b5fb97f0856df35e5f49c62af4df6f788509df Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Mon, 28 Sep 2015 00:24:25 +0900 Subject: [PATCH 4/8] doc: remove outdated `try/catch`statements in sync The code shows that it throws on a lack of entropy, but the note below says that it does not. Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index b55972e67183cf..952d6688051f9a 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -651,6 +651,7 @@ Generates cryptographically strong pseudo-random data. Usage: }); // sync + // Implementation of handling erros is required. var buf = crypto.randomBytes(256); console.log('Have %d bytes of random data: %s', buf.length, buf); From 77047ddb26899c4123675087e45793f9353f1ac3 Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Mon, 28 Sep 2015 00:31:15 +0900 Subject: [PATCH 5/8] doc: remove outdated 'try/catch' statement in sync The code shows that it throws on a lack of entropy, but the note below says that it does not. Remove outdated try/catchstatements in sync examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 952d6688051f9a..2c62dd328a4f94 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -651,7 +651,7 @@ Generates cryptographically strong pseudo-random data. Usage: }); // sync - // Implementation of handling erros is required. + // Implementation of handling erros is recommended. var buf = crypto.randomBytes(256); console.log('Have %d bytes of random data: %s', buf.length, buf); From c723c46a787db82a298aa5040e721da22edf8c87 Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Mon, 28 Sep 2015 00:34:30 +0900 Subject: [PATCH 6/8] doc: remove outdated 'try/catch' statement in sync The code shows that it throws on a lack of entropy, but the note below says that it does not. Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 2c62dd328a4f94..9675bdfdacd084 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -651,7 +651,7 @@ Generates cryptographically strong pseudo-random data. Usage: }); // sync - // Implementation of handling erros is recommended. + // Implementation of handling errors is recommended. var buf = crypto.randomBytes(256); console.log('Have %d bytes of random data: %s', buf.length, buf); From 879fa25445ff93a1a2663342aab8e4a9f96c7a9d Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Mon, 28 Sep 2015 03:50:10 +0900 Subject: [PATCH 7/8] doc: remove outdated 'try/catch' statement in sync The code shows that it throws on a lack of entropy, but the note below says that it does not. Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear --- doc/api/crypto.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index 9675bdfdacd084..b55972e67183cf 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -651,7 +651,6 @@ Generates cryptographically strong pseudo-random data. Usage: }); // sync - // Implementation of handling errors is recommended. var buf = crypto.randomBytes(256); console.log('Have %d bytes of random data: %s', buf.length, buf); From 25cf161d23641168bfcdbb6f821533b40d99e41c Mon Sep 17 00:00:00 2001 From: Minwoo Jung Date: Tue, 29 Sep 2015 13:35:45 +0900 Subject: [PATCH 8/8] doc: fix outdated 'try/catch' statement in sync The code shows that it throws on a lack of entropy, but the note below says that it does not. Remove outdated try/catchstatements in sync examples about crypto.randomBytes to make it clear. In addition, use `const` instead of `var` for constant variable. --- doc/api/crypto.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index b55972e67183cf..0379179de3593c 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -651,7 +651,7 @@ Generates cryptographically strong pseudo-random data. Usage: }); // sync - var buf = crypto.randomBytes(256); + const buf = crypto.randomBytes(256); console.log('Have %d bytes of random data: %s', buf.length, buf); NOTE: This will block if there is insufficient entropy, although it should