aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_openssl.py
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2014-04-19 08:33:13 +0100
committerAlex Stapleton <alexs@prol.etari.at>2014-04-20 09:28:19 +0100
commit5823e85cbb74f5c5109a984fa88d18868b168a1c (patch)
tree8235d5788259d10dcc213c88b401aaed6703d71a /tests/hazmat/backends/test_openssl.py
parent9fa31c6353af3ab32edd6f6988725886d0e2aa4c (diff)
downloadcryptography-5823e85cbb74f5c5109a984fa88d18868b168a1c.tar.gz
cryptography-5823e85cbb74f5c5109a984fa88d18868b168a1c.tar.bz2
cryptography-5823e85cbb74f5c5109a984fa88d18868b168a1c.zip
Inplace mode for _int_to_bn
Mostly useful for working with (EC)?DSA_SIG right now
Diffstat (limited to 'tests/hazmat/backends/test_openssl.py')
-rw-r--r--tests/hazmat/backends/test_openssl.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index 4f682f66..43d28c33 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -233,6 +233,25 @@ class TestOpenSSLRandomEngine(object):
e = backend._lib.ENGINE_get_default_RAND()
assert e == backend._ffi.NULL
+ def test_int_to_bn(self):
+ value = (2 ** 4242) - 4242
+ bn = backend._int_to_bn(value)
+ assert bn != backend._ffi.NULL
+ bn = backend._ffi.gc(bn, backend._lib.BN_free)
+
+ assert bn
+ assert backend._bn_to_int(bn) == value
+
+ def test_int_to_bn_inplace(self):
+ value = (2 ** 4242) - 4242
+ bn_ptr = backend._lib.BN_new()
+ assert bn_ptr != backend._ffi.NULL
+ bn_ptr = backend._ffi.gc(bn_ptr, backend._lib.BN_free)
+ bn = backend._int_to_bn(value, bn_ptr)
+
+ assert bn == bn_ptr
+ assert backend._bn_to_int(bn_ptr) == value
+
class TestOpenSSLRSA(object):
@pytest.mark.skipif(