From d76aa47f9797b9bfa02e1f22b593f1c16a3edc13 Mon Sep 17 00:00:00 2001 From: Alex Stapleton Date: Sun, 18 Jan 2015 17:15:47 +0000 Subject: Move around bits of the EC test suite to work around awful PyPy bug --- src/cryptography/hazmat/backends/openssl/backend.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index 34efdce9..75d7e32f 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -985,9 +985,6 @@ class Backend(object): "Invalid EC key. Both x and y must be non-negative." ) - bn_x = self._int_to_bn(x) - bn_y = self._int_to_bn(y) - set_func, get_func, group = ( self._ec_key_determine_group_get_set_funcs(ctx) ) @@ -996,6 +993,9 @@ class Backend(object): assert point != self._ffi.NULL point = self._ffi.gc(point, self._lib.EC_POINT_free) + bn_x = self._int_to_bn(x) + bn_y = self._int_to_bn(y) + with self._tmp_bn_ctx() as bn_ctx: check_x = self._lib.BN_CTX_get(bn_ctx) check_y = self._lib.BN_CTX_get(bn_ctx) @@ -1006,8 +1006,10 @@ class Backend(object): res = get_func(group, point, check_x, check_y, bn_ctx) assert res == 1 - assert self._lib.BN_cmp(bn_x, check_x) == 0 - assert self._lib.BN_cmp(bn_y, check_y) == 0 + res = self._lib.BN_cmp(bn_x, check_x) + assert res == 0 + res = self._lib.BN_cmp(bn_y, check_y) + assert res == 0 res = self._lib.EC_KEY_set_public_key(ctx, point) assert res == 1 -- cgit v1.2.3