Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f02471

Browse files
authored
Fix handling very large pointer values (32-bit) (pyca#8602)
1 parent 9091c36 commit 0f02471

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/cryptography/hazmat/backends/openssl/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ def _evp_pkey_to_private_key(
650650
return _X448PrivateKey(self, evp_pkey)
651651
elif key_type == self._lib.EVP_PKEY_X25519:
652652
return rust_openssl.x25519.private_key_from_ptr(
653-
int(self._ffi.cast("intptr_t", evp_pkey))
653+
int(self._ffi.cast("uintptr_t", evp_pkey))
654654
)
655655
elif key_type == getattr(self._lib, "EVP_PKEY_ED448", None):
656656
# EVP_PKEY_ED448 is not present in CRYPTOGRAPHY_IS_LIBRESSL
@@ -709,7 +709,7 @@ def _evp_pkey_to_public_key(self, evp_pkey) -> PublicKeyTypes:
709709
return _X448PublicKey(self, evp_pkey)
710710
elif key_type == self._lib.EVP_PKEY_X25519:
711711
return rust_openssl.x25519.public_key_from_ptr(
712-
int(self._ffi.cast("intptr_t", evp_pkey))
712+
int(self._ffi.cast("uintptr_t", evp_pkey))
713713
)
714714
elif key_type == getattr(self._lib, "EVP_PKEY_ED448", None):
715715
# EVP_PKEY_ED448 is not present in CRYPTOGRAPHY_IS_LIBRESSL

src/cryptography/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _extract_buffer_length(obj: typing.Any) -> typing.Tuple[int, int]:
4646
from cryptography.hazmat.bindings._rust import _openssl
4747

4848
buf = _openssl.ffi.from_buffer(obj)
49-
return int(_openssl.ffi.cast("intptr_t", buf)), len(buf)
49+
return int(_openssl.ffi.cast("uintptr_t", buf)), len(buf)
5050

5151

5252
class InterfaceNotImplemented(Exception):

0 commit comments

Comments
 (0)