mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2011-09-15, 13:29   #1
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

26·113 Posts
Default Intel RNG API?

Does VC++ provide any kind of API or system call that allows
one to access the hardware RNG in an Intel i3/i5/i7 processor?

Does one need the Microsoft Crypto API (CAPI) or the Next Generation
API (CNG) to do this?
R.D. Silverman is offline   Reply With Quote
Old 2011-09-15, 16:22   #2
fivemack
(loop (#_fork))
 
fivemack's Avatar
 
Feb 2006
Cambridge, England

24×5×79 Posts
Default

It looks as if CryptGenRandom from the cryptography API might do what you want ... the random number generator is only really accessible from kernel space (I've had a look at the Linux code for collecting random numbers, which does all sorts of weird PCI I/O operations).

http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx is the CryptAcquireContext call which you need to make in order to get a handle which you can pass to CryptGenRandom.
fivemack is online now   Reply With Quote
Old 2011-09-15, 16:25   #3
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

22·1,447 Posts
Default

Quote:
Originally Posted by fivemack View Post
... the random number generator is only really accessible from kernel space ...
Are you talking about the RDRAND instruction? Because that is available from user space, no special permissions required.


http://spectrum.ieee.org/computing/h...er-generator/0

Last fiddled with by retina on 2011-09-15 at 16:27 Reason: Linkies are always nice
retina is online now   Reply With Quote
Old 2011-09-15, 16:48   #4
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

161008 Posts
Default

Quote:
Originally Posted by retina View Post
Are you talking about the RDRAND instruction? Because that is available from user space, no special permissions required.


http://spectrum.ieee.org/computing/h...er-generator/0
It appears though that RDRAND is not yet available; It seems to require
the (yet to be released) Ivy Bridge processor.

What about the intrinsic:


_rdrand_u32()

Is this available under VC++? What .dll or .lib needs to be linked?
R.D. Silverman is offline   Reply With Quote
Old 2011-09-15, 17:08   #5
xilman
Bamboozled!
 
xilman's Avatar
 
"𒉺𒌌𒇷𒆷𒀭"
May 2003
Down not across

235768 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
It appears though that RDRAND is not yet available; It seems to require
the (yet to be released) Ivy Bridge processor.

What about the intrinsic:


_rdrand_u32()

Is this available under VC++? What .dll or .lib needs to be linked?
Lets step back a little.

What problem are you trying to solve?
How good, according to appropriate metrics such as speed, portability, and estimated entropy, does your RNG need to be?

Given the answers, we may be able to give more precisely targeted advice.

Paul
xilman is online now   Reply With Quote
Old 2011-09-15, 17:45   #6
R.D. Silverman
 
R.D. Silverman's Avatar
 
Nov 2003

26·113 Posts
Default

Quote:
Originally Posted by xilman View Post
Lets step back a little.

What problem are you trying to solve?
How good, according to appropriate metrics such as speed, portability, and estimated entropy, does your RNG need to be?

Given the answers, we may be able to give more precisely targeted advice.

Paul
I just want to get/sample entropy bits from the h/w RNG; Speed is not an
issue in case I need to implement a Von-Neumann unbiaser. I will make as
many calls as I need to get the require number of entropy bits. Of course
I will not use them directly as a source of randomness; they will be passed
through a non-linear filter before use.
R.D. Silverman is offline   Reply With Quote
Old 2011-09-15, 18:45   #7
fivemack
(loop (#_fork))
 
fivemack's Avatar
 
Feb 2006
Cambridge, England

24×5×79 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
What about the intrinsic:

_rdrand_u32()

Is this available under VC++? What .dll or .lib needs to be linked?
That's just a synonym for RDRAND without writing inline assembly, so again you need to wait for Ivy Bridge.
fivemack is online now   Reply With Quote
Old 2011-09-15, 18:48   #8
fivemack
(loop (#_fork))
 
fivemack's Avatar
 
Feb 2006
Cambridge, England

18B016 Posts
Default

Quote:
Originally Posted by R.D. Silverman View Post
I just want to get/sample entropy bits from the h/w RNG; Speed is not an
issue in case I need to implement a Von-Neumann unbiaser. I will make as
many calls as I need to get the require number of entropy bits. Of course
I will not use them directly as a source of randomness; they will be passed
through a non-linear filter before use.
The CryptAPI CryptGenRandom does the entropy collection (from a variety of sources) and non-linear filtering for you; why do you want to do it yourself? If you want to read the motherboard entropy source directly, you need a dedicated kernel driver; similarly if you get a USB entropy key like http://www.entropykey.co.uk/ you'd need a driver to get it to work under Windows.
fivemack is online now   Reply With Quote
Old 2011-09-15, 19:35   #9
jasonp
Tribal Bullet
 
jasonp's Avatar
 
Oct 2004

11×317 Posts
Default

Quote:
Originally Posted by fivemack View Post
The CryptAPI CryptGenRandom does the entropy collection (from a variety of sources) and non-linear filtering for you; why do you want to do it yourself?
Has the CryptoAPI generator improved since this was published?
jasonp is offline   Reply With Quote
Old 2011-09-15, 20:48   #10
Christenson
 
Christenson's Avatar
 
Dec 2010
Monticello

110101100002 Posts
Default

Quote:
Originally Posted by jasonp View Post
Has the CryptoAPI generator improved since this was published?
As of 4:45PM ET today, that server is offline....what was in it? A proof that it wasn't very high entropy at all?
Christenson is offline   Reply With Quote
Old 2011-09-15, 21:44   #11
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

2×2,963 Posts
Default

Quote:
Originally Posted by Christenson View Post
As of 4:45PM ET today, that server is offline....what was in it? A proof that it wasn't very high entropy at all?
From the Internet Archive:
Quote:
3.9 The CryptoAPI Generator
Like the SSLeay/OpenSSL generator, the CryptoAPI generator uses separate functions for mixing in entropy and for the PRNG. The entropy-mixing stage hashes polled data using SHA-1, and the PRNG stage uses the SHA-1 output to key an RC4 stream cipher, as shown in Figure 15. The polled data consists of the traditional time and process ID and a few relatively poor additional sources such as the system’s current memory and disk usage, the static data consists of the previous hash output recycled for further use [44]. Unlike PGP, the CryptoAPI preserved state doesn’t appear to be protected by a user password.
This generator is, at best, adequate. The static data isn’t password-protected like the PGP seed and the polled data doesn’t provide much entropy, particularly if the generator is seeded at system startup, which is typically the case as Windows system components make use of CryptoAPI during the boot phase. In addition no steps appear to be taken to mitigate problems such as the fact the RC4 exhibits correlations between its key and the initial bytes of its output [45][46][47] as well as having statistical weaknesses [48][49][50], resulting in the generator leaking part of its internal state in the first few bytes of PRNG output or producing some predictable output during its operation.

Last fiddled with by CRGreathouse on 2011-09-15 at 21:44
CRGreathouse is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unknown Intel fidelitas Information & Answers 4 2014-08-20 18:36
AMD vs Intel dtripp Software 3 2013-02-19 20:20
Intel NUC nucleon Hardware 2 2012-05-10 23:53
AMD or Intel mack Information & Answers 7 2009-09-13 01:48
Intel Mac? penguain NFSNET Discussion 0 2006-06-12 01:31

All times are UTC. The time now is 12:19.

Tue Oct 20 12:19:33 UTC 2020 up 40 days, 9:30, 0 users, load averages: 2.95, 3.04, 2.94

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.