Skip to main content

Python interface to Intel hardware rng

Project description

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

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 with 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 Intel random number generator is valid. No mitigation is done to modify the output of the hardware to prevent problems with Intel’s implementation. Caveat Emptor.

Also, both RdRandom and RdSeedom include the function r.getrandombytes(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 protocol.

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.

Works with 32 and 64 bit builds of python.

Works with python2 and python3.

planned for version 1.5: whitening added, written in python

Planned for version 2: whitening added, backwards compatible with 1.5, but written in C.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rdrand-1.4.9.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file rdrand-1.4.9.tar.gz.

File metadata

  • Download URL: rdrand-1.4.9.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rdrand-1.4.9.tar.gz
Algorithm Hash digest
SHA256 73bc61247ad7785abf524e7413169624a3e8da0b4aa2baa4f34fb02e6cbd3674
MD5 45fce9f6bf1f1288b5dfe984dd335bbe
BLAKE2b-256 10470c170c417a4668ad3e1e4b83544190312e23e703fd9963e53add71e18675

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page