5

Python's random.SystemRandom provides cryptographic-quality pseudorandom numbers. What platforms is it supported on? Most importantly, are there any platforms that it is not supported on, and if so, which ones? Can anyone provide any information about how portable it is?

D.W.
  • 3,382
  • 7
  • 44
  • 110

1 Answers1

4

From http://docs.python.org/library/random.html

The random module also provides the SystemRandom class which uses the system function os.urandom() to generate random numbers from sources provided by the operating system.

From http://docs.python.org/library/os.html#os.urandom

This function returns random bytes from an OS-specific randomness source. The returned data should be unpredictable enough for cryptographic applications, though its exact quality depends on the OS implementation. On a UNIX-like system this will query /dev/urandom, and on Windows it will use CryptGenRandom. If a randomness source is not found, NotImplementedError will be raised.

tylerl
  • 30,197
  • 13
  • 80
  • 113
  • 2
    And on VMS, it uses OpenSSL's RAND_pseudo_bytes, as you can see by reading [the source](http://svn.python.org/view/python/branches/release32-maint/Modules/posixmodule.c?view=markup). – Nemo Jun 02 '11 at 19:30
  • @tylerl, yeah, I already read the docs, and I already knew it is supported on Windows and on Unix platforms that have /dev/urandom. But again, I'm most interested in knowing which platforms it is *not* supported on, as mentioned in the original question. – D.W. Jun 03 '11 at 00:31
  • I could just sense you are using VMS – Nemo Jun 03 '11 at 00:55
  • @Nemo: And what does OpenSSL's RAND_psuedo_bytes use on VMS? – President James K. Polk Jun 03 '11 at 01:02
  • 1
    @GregS: Don't tell me it uses Python's os.urandom !?!? – Nemo Jun 03 '11 at 01:17
  • @Nemo: I don't know, I'm asking you! – President James K. Polk Jun 03 '11 at 10:28
  • 1
    From what I understand, RAND_psuedo_bytes is similar to /dev/urandom on linux, as it uses an acquired entropy pool for true randomness, but re-uses entropy to avoid blocking. – tylerl Jun 03 '11 at 14:54