mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25003: On Solaris 11.3 or newer, os.urandom() now uses the getrandom()
function instead of the getentropy() function. The getentropy() function is blocking to generate very good quality entropy, os.urandom() doesn't need such high-quality entropy.
This commit is contained in:
parent
87bddbac9d
commit
bae2d6203f
6 changed files with 118 additions and 27 deletions
|
@ -1226,13 +1226,15 @@ class URandomTests(unittest.TestCase):
|
|||
self.assertNotEqual(data1, data2)
|
||||
|
||||
|
||||
HAVE_GETENTROPY = (sysconfig.get_config_var('HAVE_GETENTROPY') == 1)
|
||||
HAVE_GETRANDOM = (sysconfig.get_config_var('HAVE_GETRANDOM_SYSCALL') == 1)
|
||||
# os.urandom() doesn't use a file descriptor when it is implemented with the
|
||||
# getentropy() function, the getrandom() function or the getrandom() syscall
|
||||
OS_URANDOM_DONT_USE_FD = (
|
||||
sysconfig.get_config_var('HAVE_GETENTROPY') == 1
|
||||
or sysconfig.get_config_var('HAVE_GETRANDOM') == 1
|
||||
or sysconfig.get_config_var('HAVE_GETRANDOM_SYSCALL') == 1)
|
||||
|
||||
@unittest.skipIf(HAVE_GETENTROPY,
|
||||
"getentropy() does not use a file descriptor")
|
||||
@unittest.skipIf(HAVE_GETRANDOM,
|
||||
"getrandom() does not use a file descriptor")
|
||||
@unittest.skipIf(OS_URANDOM_DONT_USE_FD ,
|
||||
"os.random() does not use a file descriptor")
|
||||
class URandomFDTests(unittest.TestCase):
|
||||
@unittest.skipUnless(resource, "test requires the resource module")
|
||||
def test_urandom_failure(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue