diff options
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/bindings/test_openssl.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py index 75a8e3f1..207fece9 100644 --- a/tests/hazmat/bindings/test_openssl.py +++ b/tests/hazmat/bindings/test_openssl.py @@ -4,6 +4,8 @@ from __future__ import absolute_import, division, print_function +import os + import pytest from cryptography.hazmat.bindings.openssl.binding import Binding @@ -92,6 +94,18 @@ class TestOpenSSL(object): with pytest.raises(RuntimeError): b._register_osrandom_engine() + def test_actual_osrandom_bytes(self, monkeypatch): + sample_data = (b"\x01\x02\x03\x04" * 4) + length = len(sample_data) + def notrandom(size): + assert size == length + return sample_data + monkeypatch.setattr(os, "urandom", notrandom) + b = Binding() + buf = b.ffi.new("char[]", length) + b.lib.RAND_bytes(buf, length) + assert b.ffi.buffer(buf)[0:length] == sample_data + def test_ssl_ctx_options(self): # Test that we're properly handling 32-bit unsigned on all platforms. b = Binding() |