From a094a36fa8518889f46a704a55b4cfe7efec1ef7 Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Sat, 28 Jan 2017 15:55:42 +0100 Subject: [PATCH] Update random.py Realized that `ffi.string()` could truncate the output on null bytes. --- wrapper/python/wolfcrypt/wolfcrypt/random.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wrapper/python/wolfcrypt/wolfcrypt/random.py b/wrapper/python/wolfcrypt/wolfcrypt/random.py index eebebc41f..e034f5c58 100644 --- a/wrapper/python/wolfcrypt/wolfcrypt/random.py +++ b/wrapper/python/wolfcrypt/wolfcrypt/random.py @@ -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)[:]