Update sysrand documentation (#17676)

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
konsumlamm 2021-04-08 19:41:43 +02:00 • committed by GitHub
commit 9f0f477552
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 20 deletions

View file

@ -272,18 +272,18 @@ Math libraries
* `random <random.html>`_ * `random <random.html>`_
Fast and tiny random number generator. Fast and tiny random number generator.
* `sysrand <sysrand.html>`_
Cryptographically secure pseudorandom number generator.
* `rationals <rationals.html>`_ * `rationals <rationals.html>`_
This module implements rational numbers and relevant mathematical operations. This module implements rational numbers and relevant mathematical operations.
* `stats <stats.html>`_ * `stats <stats.html>`_
Statistical analysis Statistical analysis.
* `sums <sums.html>`_ * `sums <sums.html>`_
Accurate summation functions. Accurate summation functions.
* `sysrand <sysrand.html>`_
Cryptographically secure pseudorandom number generator.
Internet Protocols and Support Internet Protocols and Support
------------------------------ ------------------------------

View file

@ -12,8 +12,8 @@
## therefore may not be secure. ## therefore may not be secure.
## ##
## `std/sysrand` generates random numbers from a secure source provided by the operating system. ## `std/sysrand` generates random numbers from a secure source provided by the operating system.
## It is also called Cryptographically secure pseudorandom number generator. ## It is a cryptographically secure pseudorandom number generator
## It should be unpredictable enough for cryptographic applications, ## and should be unpredictable enough for cryptographic applications,
## though its exact quality depends on the OS implementation. ## though its exact quality depends on the OS implementation.
## ##
## | Targets | Implementation | ## | Targets | Implementation |
@ -21,11 +21,11 @@
## | Windows | `BCryptGenRandom`_ | ## | Windows | `BCryptGenRandom`_ |
## | Linux | `getrandom`_ | ## | Linux | `getrandom`_ |
## | MacOSX | `getentropy`_ | ## | MacOSX | `getentropy`_ |
## | IOS | `SecRandomCopyBytes`_ | ## | iOS | `SecRandomCopyBytes`_ |
## | OpenBSD | `getentropy openbsd`_ | ## | OpenBSD | `getentropy openbsd`_ |
## | FreeBSD | `getrandom freebsd`_ | ## | FreeBSD | `getrandom freebsd`_ |
## | JS (Web Browser) | `getRandomValues`_ | ## | JS (Web Browser) | `getRandomValues`_ |
## | Nodejs | `randomFillSync`_ | ## | Node.js | `randomFillSync`_ |
## | Other Unix platforms | `/dev/urandom`_ | ## | Other Unix platforms | `/dev/urandom`_ |
## ##
## .. _BCryptGenRandom: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom ## .. _BCryptGenRandom: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
@ -195,7 +195,7 @@ elif defined(linux):
elif defined(openbsd): elif defined(openbsd):
proc getentropy(p: pointer, size: cint): cint {.importc: "getentropy", header: "<unistd.h>".} proc getentropy(p: pointer, size: cint): cint {.importc: "getentropy", header: "<unistd.h>".}
# fills a buffer with high-quality entropy, # Fills a buffer with high-quality entropy,
# which can be used as input for process-context pseudorandom generators like `arc4random`. # which can be used as input for process-context pseudorandom generators like `arc4random`.
# The maximum buffer size permitted is 256 bytes. # The maximum buffer size permitted is 256 bytes.
@ -292,7 +292,7 @@ proc urandom*(dest: var openArray[byte]): bool =
## If the call succeeds, returns `true`. ## If the call succeeds, returns `true`.
## ##
## If `dest` is empty, `urandom` immediately returns success, ## If `dest` is empty, `urandom` immediately returns success,
## without calling underlying operating system api. ## without calling the underlying operating system API.
## ##
## .. warning:: The code hasn't been audited by cryptography experts and ## .. warning:: The code hasn't been audited by cryptography experts and
## is provided as-is without guarantees. Use at your own risks. For production ## is provided as-is without guarantees. Use at your own risks. For production