aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/bindings
diff options
context:
space:
mode:
authorGlyph <glyph@twistedmatrix.com>2015-06-29 17:21:02 -0700
committerGlyph <glyph@twistedmatrix.com>2015-06-29 17:21:02 -0700
commit7c3e7a83f06b0ff8f0c27a4486eaa6448ba6485e (patch)
tree962ac84e3f48134555fa2399971fe32328393d60 /tests/hazmat/bindings
parentb7c6aafe2eb8c9684e5ffd69380e0f831c430fd9 (diff)
downloadcryptography-7c3e7a83f06b0ff8f0c27a4486eaa6448ba6485e.tar.gz
cryptography-7c3e7a83f06b0ff8f0c27a4486eaa6448ba6485e.tar.bz2
cryptography-7c3e7a83f06b0ff8f0c27a4486eaa6448ba6485e.zip
the output of RAND_bytes is os.urandom's result
Diffstat (limited to 'tests/hazmat/bindings')
-rw-r--r--tests/hazmat/bindings/test_openssl.py14
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()