Merge pull request #1197 from alex/whoops

Fixed accidental use of the global backend name
diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py
index 77f1bf4..d22db1d 100644
--- a/cryptography/hazmat/backends/commoncrypto/backend.py
+++ b/cryptography/hazmat/backends/commoncrypto/backend.py
@@ -238,16 +238,15 @@
                 " 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 @@
             )
 
         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 @@
         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 @@
             )
 
         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 @@
         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 cfd1078..4991177 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -912,7 +912,7 @@
         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)