2
0
Jonas Borgström 12 жил өмнө
parent
commit
033dfe1225
1 өөрчлөгдсөн 3 нэмэгдсэн , 1 устгасан
  1. 3 1
      attic/crypto.py

+ 3 - 1
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