From 033dfe1225387c7ecf7dd147e8a0c379a9c84c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Sat, 17 Aug 2013 12:35:43 +0200 Subject: [PATCH] More code cleanup --- attic/crypto.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/attic/crypto.py b/attic/crypto.py index 368ca5030..daac6cec8 100644 --- a/attic/crypto.py +++ b/attic/crypto.py @@ -17,6 +17,8 @@ libcrypto.PKCS5_PBKDF2_HMAC.argtypes = (c_char_p, c_int, c_char_p, c_int, c_int, libcrypto.EVP_sha256.restype = c_void_p libcrypto.AES_set_encrypt_key.argtypes = (c_char_p, c_int, c_char_p) libcrypto.AES_ctr128_encrypt.argtypes = (c_char_p, c_char_p, c_int, c_char_p, c_char_p, c_char_p, POINTER(c_uint)) +libcrypto.RAND_bytes.argtypes = (c_char_p, c_int) +libcrypto.RAND_bytes.restype = c_int _int = struct.Struct('>I') _long = struct.Struct('>Q') @@ -46,7 +48,7 @@ def get_random_bytes(n): """Return n cryptographically strong pseudo-random bytes """ buf = create_string_buffer(n) - if not libcrypto.RAND_bytes(buf, n): + if libcrypto.RAND_bytes(buf, n) < 1: raise Exception('RAND_bytes failed') return buf.raw