Revision 1539fc67ec7cd1f092967452d8ae47d170ca149b authored by Jonathan Protzenko on 24 April 2020, 23:18:32 UTC, committed by Jonathan Protzenko on 24 April 2020, 23:18:32 UTC
1 parent 56130dc
Raw File
Randomness.rst
Randomness
-----------------

HACL* is equipped with a randomness function implemented with
platform dependant code for Unix and Windows.

.. literalinclude:: ../dist/portable-gcc-compatible/Lib_RandomBuffer_System.h
    :language: c
    :start-after: SNIPPET_START: Lib_RandomBuffer_System_randombytes
    :end-before: SNIPPET_END: Lib_RandomBuffer_System_randombytes

It takes a pointer to a memory location and a number of random bytes
to be written from that location. Beware of not asking for more bytes
than owned.

Internally, ``read_random_bytes`` is implemented using
``CryptGenRandom`` for Microsoft Windows and using ``/dev/urandom``
for Unix platforms.

.. warning:: This file is handwritten and is part of the TCB, hence it
             should be minimally reviewed before being used.
back to top