summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2023-03-24 20:51:14 -0400
committerGitHub <noreply@github.com>2023-03-25 00:51:14 +0000
commit0f0247198decdaa4c26fbdf85534ae3929f4fef6 (patch)
tree60047a7680c9ac03204678bb9dd667b98316d219
parent9091c369476a59edbac7c373a936341cb6daf1b0 (diff)
downloadcryptography-0f0247198decdaa4c26fbdf85534ae3929f4fef6.tar.gz
Fix handling very large pointer values (32-bit) (#8602)
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py4
-rw-r--r--src/cryptography/utils.py2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index facdb48a0..587656369 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -650,7 +650,7 @@ class Backend:
return _X448PrivateKey(self, evp_pkey)
elif key_type == self._lib.EVP_PKEY_X25519:
return rust_openssl.x25519.private_key_from_ptr(
- int(self._ffi.cast("intptr_t", evp_pkey))
+ int(self._ffi.cast("uintptr_t", evp_pkey))
)
elif key_type == getattr(self._lib, "EVP_PKEY_ED448", None):
# EVP_PKEY_ED448 is not present in CRYPTOGRAPHY_IS_LIBRESSL
@@ -709,7 +709,7 @@ class Backend:
return _X448PublicKey(self, evp_pkey)
elif key_type == self._lib.EVP_PKEY_X25519:
return rust_openssl.x25519.public_key_from_ptr(
- int(self._ffi.cast("intptr_t", evp_pkey))
+ int(self._ffi.cast("uintptr_t", evp_pkey))
)
elif key_type == getattr(self._lib, "EVP_PKEY_ED448", None):
# EVP_PKEY_ED448 is not present in CRYPTOGRAPHY_IS_LIBRESSL
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
index da4067a8e..9beea653e 100644
--- a/src/cryptography/utils.py
+++ b/src/cryptography/utils.py
@@ -46,7 +46,7 @@ def _extract_buffer_length(obj: typing.Any) -> typing.Tuple[int, int]:
from cryptography.hazmat.bindings._rust import _openssl
buf = _openssl.ffi.from_buffer(obj)
- return int(_openssl.ffi.cast("intptr_t", buf)), len(buf)
+ return int(_openssl.ffi.cast("uintptr_t", buf)), len(buf)
class InterfaceNotImplemented(Exception):