From 3873dae7aacece2ec80c9a24f4885993eaa4c281 Mon Sep 17 00:00:00 2001 From: Alex Stapleton Date: Thu, 5 Mar 2015 16:15:02 +0000 Subject: Stricter asserts on _bn_to_int and _int_to_bn Helped me catch my terrible programming when working on DH --- src/cryptography/hazmat/backends/openssl/backend.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py index de653032..27d5e353 100644 --- a/src/cryptography/hazmat/backends/openssl/backend.py +++ b/src/cryptography/hazmat/backends/openssl/backend.py @@ -320,6 +320,7 @@ class Backend(object): ) def _bn_to_int(self, bn): + assert bn != self._ffi.NULL if six.PY3: # Python 3 has constant time from_bytes, so use that. @@ -346,6 +347,7 @@ class Backend(object): ownership of the object). Be sure to register it for GC if it will be discarded after use. """ + assert bn is None or bn != self._ffi.NULL if bn is None: bn = self._ffi.NULL -- cgit v1.2.3