Ordo
0.3.4
Symmetric Cryptography Library
|
Module. More...
Go to the source code of this file.
Functions | |
ORDO_PUBLIC int | os_random (void *out, size_t len) |
ORDO_PUBLIC int | os_secure_random (void *out, size_t len) |
Module.
Exposes the OS CSPRNG (Cryptographically Secure PseudoRandom Number Generator) interface, which is basically a cross-platform wrapper to the OS-provided entropy pool. To learn more about how it is implemented, go to the source code or find out what facilities your operating system provides for entropy gathering.
ORDO_PUBLIC int os_random | ( | void * | out, |
size_t | len | ||
) |
Generates cryptographically secure pseudorandom numbers.
[out] | out | The destination buffer. |
[in] | len | The number of bytes to generate. |
ORDO_SUCCESS
on success, else an error code.ORDO_FAIL
error message, and any data in the buffer should be discarded as indeterminate. ORDO_PUBLIC int os_secure_random | ( | void * | out, |
size_t | len | ||
) |
Generates cryptographically secure pseudorandom numbers, the function will make a best effort attempt to access the operating system entropy pool and so, ideally, should return exactly len
bytes of entropy, whereas the os_random()
function need only return enough entropy for the output stream to be computationally indistinguishable from a non-random stream. However, keep in mind that this function is not required to behave as such.
[out] | out | The destination buffer. |
[in] | len | The number of bytes to generate. |
ORDO_SUCCESS
on success, else an error code.os_random()
(there is no way to know whether this feature is available, this is by design).