Issue #12049: Add RAND_bytes() and RAND_pseudo_bytes() functions to the ssl

module.
This commit is contained in:
Victor Stinner 2011-05-24 12:05:19 +02:00
parent b7b1930fe3
commit 99c8b16143
6 changed files with 106 additions and 4 deletions

View file

@ -102,6 +102,14 @@ class BasicSocketTests(unittest.TestCase):
sys.stdout.write("\n RAND_status is %d (%s)\n"
% (v, (v and "sufficient randomness") or
"insufficient randomness"))
data, is_cryptographic = ssl.RAND_pseudo_bytes(16)
self.assertEqual(len(data), 16)
self.assertEqual(is_cryptographic, v == 1)
if v:
data = ssl.RAND_bytes(16)
self.assertEqual(len(data), 16)
try:
ssl.RAND_egd(1)
except TypeError: