aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-29 16:02:37 -0600
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-06-29 16:02:37 -0600
commit929d85c1e7dab8fe560004b46a5fcde203d5d0e0 (patch)
tree17baa00feace84f9c684059112628927e2e627d0
parent923920765bd93f0e07730e618b2acedcda432b90 (diff)
parent985676e7cc2276195b7dce355e340a9880150f0b (diff)
downloadcryptography-929d85c1e7dab8fe560004b46a5fcde203d5d0e0.tar.gz
cryptography-929d85c1e7dab8fe560004b46a5fcde203d5d0e0.tar.bz2
cryptography-929d85c1e7dab8fe560004b46a5fcde203d5d0e0.zip
Merge pull request #1197 from alex/whoops
Fixed accidental use of the global backend name
-rw-r--r--cryptography/hazmat/backends/commoncrypto/backend.py30
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py2
2 files changed, 16 insertions, 16 deletions
diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py
index 77f1bf4d..d22db1da 100644
--- a/cryptography/hazmat/backends/commoncrypto/backend.py
+++ b/cryptography/hazmat/backends/commoncrypto/backend.py
@@ -238,16 +238,15 @@ class Backend(object):
" Code: {0}.".format(response)
)
-
-def _release_cipher_ctx(ctx):
- """
- Called by the garbage collector and used to safely dereference and
- release the context.
- """
- if ctx[0] != backend._ffi.NULL:
- res = backend._lib.CCCryptorRelease(ctx[0])
- backend._check_response(res)
- ctx[0] = backend._ffi.NULL
+ def _release_cipher_ctx(self, ctx):
+ """
+ Called by the garbage collector and used to safely dereference and
+ release the context.
+ """
+ if ctx[0] != self._ffi.NULL:
+ res = self._lib.CCCryptorRelease(ctx[0])
+ self._check_response(res)
+ ctx[0] = self._ffi.NULL
@utils.register_interface(interfaces.CipherContext)
@@ -285,7 +284,7 @@ class _CipherContext(object):
)
ctx = self._backend._ffi.new("CCCryptorRef *")
- ctx = self._backend._ffi.gc(ctx, _release_cipher_ctx)
+ ctx = self._backend._ffi.gc(ctx, self._backend._release_cipher_ctx)
if isinstance(mode, interfaces.ModeWithInitializationVector):
iv_nonce = mode.initialization_vector
@@ -333,7 +332,7 @@ class _CipherContext(object):
res = self._backend._lib.CCCryptorFinal(
self._ctx[0], buf, len(buf), outlen)
self._backend._check_response(res)
- _release_cipher_ctx(self._ctx)
+ self._backend._release_cipher_ctx(self._ctx)
return self._backend._ffi.buffer(buf)[:outlen[0]]
@@ -359,7 +358,7 @@ class _GCMCipherContext(object):
)
ctx = self._backend._ffi.new("CCCryptorRef *")
- ctx = self._backend._ffi.gc(ctx, _release_cipher_ctx)
+ ctx = self._backend._ffi.gc(ctx, self._backend._release_cipher_ctx)
self._ctx = ctx
@@ -394,9 +393,10 @@ class _GCMCipherContext(object):
tag_size = self._cipher.block_size // 8
tag_buf = self._backend._ffi.new("unsigned char[]", tag_size)
tag_len = self._backend._ffi.new("size_t *", tag_size)
- res = backend._lib.CCCryptorGCMFinal(self._ctx[0], tag_buf, tag_len)
+ res = self._backend._lib.CCCryptorGCMFinal(
+ self._ctx[0], tag_buf, tag_len)
self._backend._check_response(res)
- _release_cipher_ctx(self._ctx)
+ self._backend._release_cipher_ctx(self._ctx)
self._tag = self._backend._ffi.buffer(tag_buf)[:]
if (self._operation == self._backend._lib.kCCDecrypt and
not constant_time.bytes_eq(
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index cfd1078b..4991177a 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -912,7 +912,7 @@ class Backend(object):
Generate a new private key on the named curve.
"""
- if backend.elliptic_curve_supported(curve):
+ if self.elliptic_curve_supported(curve):
curve_nid = self._elliptic_curve_to_nid(curve)
ctx = self._lib.EC_KEY_new_by_curve_name(curve_nid)