Alex Rivera | Logout

Making use of sandy bridge's hardware true random number generator?

Asked 2011-10-26T11:13:44.130
10

I was wondering if there is a way to make use of the new hardware based true number generator found in intel's sandy bridge CPU? I read that intel's MKL (Math Kernel Library) exposes this functionality, but this requires the MKL suite and an intel complier, ending up pretty expensive.

Is there another way to employ the hardware random number generator in my C++ code? For example a nice, header only library?

Edit
Report

1 Answer

11

Intel has posted a manual, library, and code examples for the rdrand instruction at http://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide.

From the Readme:

"Because the many of compiler toolchains do not support this new instruction, this library was created to facilitate easy access to it. The idea is simple: link to a built static library and enjoy the new feature!"

There are examples of all the library calls in main.c.

I was able to compile the static library and test program in gcc on Mac OS X. The documentation states that it is also compatible with Linux and Windows.

Be aware that rdrand is actually a 128-bit pseudo-random number generator with hardware-generated entropy. (The upcoming Broadwell architecture will provide an rdseed instruction to access the true random number generator.) The details of the difference and its implications can be found under the "Long Answer" heading at http://software.intel.com/en-us/blogs/2012/11/17/the-difference-between-rdrand-and-rdseed.

answered 2013-06-28T19:53:18.353

Your Answer