Skip to content
forked from stillson/rdrand

python interface to intel hardware RNG

License

Notifications You must be signed in to change notification settings

jdb130496/rdrand

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RDRAND

A module to use Intel's hardware RNG with python's random class

Installation

pip install . after cloning the repository to a local folder (preferably, don't use - python setup.py install - as it is deprecated since Python 3.11) 

USAGE

#easy_install rdrand
#python

>>>from rdrand import RdRandom
>>>r = RdRandom()

>>>from rdrand import RdSeedom
>>>s = RdSeedom()

At this point, ``r`` and ``s`` will behave just like ``random``

``RdRandom`` is a subclass of ``random.Random``, and behaves like ``random.Random``,
 but it uses inline assembly to access the hardware RNG using the RdRand instruction. This should be
a cryptographically secure drop in replacement for ``random`` with a prediction complexity bound of O(             2^128), if the Intel random number
generator is valid. No mitigation is done to modify the output of the hardware to prevent problems wit             h Intel's implementation. Caveat Emptor.

``RdSeedom`` is a subclass of ``random.Random``, and behaves like ``random.Random``,
 but it uses inline assembly to access the hardware RNG using the RdSeed instruction. This should be
a cryptographically secure drop in replacement for ``random`` returning full entropy bits, if the Inte             l random number
generator is valid. No mitigation is done to modify the output of the hardware to prevent problems wit             h Intel's implementation. Caveat Emptor.

Also, both RdRandom and RdSeedom include the function ``r.getrandbytes(i)`` where ``i`` is a positive              int. This returns a string
of length ``i`` filled with random bytes, which is ideal for generating a key or using directly in a p             rotocol.

Please note, as with any security solution, it is possible to subvert this. Please understand the full              context before deploying. I am not liable for misuse or clever hackers.

Certain changes made in C code to make it compatible with mingw64 gcc
tool-chain for seamless installation on windows. Tested on Windows 11 using
msys2 shell.

About

python interface to intel hardware RNG

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 75.6%
  • Python 24.4%