Update random.py

Realized that `ffi.string()` could truncate the output on null bytes.
This commit is contained in:
Erik Bray 2017-01-28 15:55:42 +01:00 committed by GitHub
parent e96a720f04
commit a094a36fa8
1 changed files with 2 additions and 2 deletions

View File

@ -52,7 +52,7 @@ class Random(object):
if ret < 0:
raise WolfCryptError("RNG generate byte error (%d)" % ret)
return _ffi.string(result, 1)
return _ffi.buffer(result, 1)[:]
def bytes(self, length):
@ -65,4 +65,4 @@ class Random(object):
if ret < 0:
raise WolfCryptError("RNG generate block error (%d)" % ret)
return _ffi.string(result, length)
return _ffi.buffer(result, length)[:]