diff options
-rw-r--r-- | cryptography/hazmat/bindings/openssl/osrand_engine.py | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/cryptography/hazmat/bindings/openssl/osrand_engine.py b/cryptography/hazmat/bindings/openssl/osrand_engine.py index 2313a61f..4163668b 100644 --- a/cryptography/hazmat/bindings/openssl/osrand_engine.py +++ b/cryptography/hazmat/bindings/openssl/osrand_engine.py @@ -48,20 +48,13 @@ static int osrandom_init(ENGINE *e) { } static int osrandom_rand_bytes(unsigned char *buffer, int size) { - size_t chunk; - if (hCryptProv == 0) { return 0; } - while (size > 0) { - chunk = size; - if (!CryptGenRandom(hCryptProv, (DWORD)chunk, buffer)) { - ERR_put_error(ERR_LIB_RAND, 0, ERR_R_RAND_LIB, "osrandom.py", 0); - return 0; - } - buffer += chunk; - size -= chunk; + if (!CryptGenRandom(hCryptProv, (DWORD)size, buffer)) { + ERR_put_error(ERR_LIB_RAND, 0, ERR_R_RAND_LIB, "osrandom.py", 0); + return 0; } return 1; } |