diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 543a05fe2ad3..967d69c79707 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -11,6 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import threading + import pytest from cryptography import utils @@ -97,3 +99,28 @@ def test_handle_unknown_error(self): backend.lib.EVP_F_EVP_DECRYPTFINAL_EX, 0 ) + + def test_threads(self): + b = Backend() + + def randloop(): + s = b.ffi.new("char[]", 16) + sb = b.ffi.buffer(s) + sb[:] = b"\0" * 16 + + for i in range(300000): + b.lib.RAND_seed(s, 16) + + threads = [] + for x in range(3): + t = threading.Thread(target=randloop) + t.daemon = True + t.start() + + threads.append(t) + + while threads: + for t in threads: + t.join(0.1) + if not t.isAlive(): + threads.remove(t)