Skip to content

Commit

Permalink
Backport fix for 40.0.1 (#8603)
Browse files Browse the repository at this point in the history
* Fix handling very large pointer values (32-bit) (#8602)

* Changelog and backport fo 40.0.1
  • Loading branch information
alex authored Mar 25, 2023
1 parent 45e3771 commit 9dd0b26
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
Changelog
=========

.. _v40-0-1:

40.0.1 - 2023-03-24
~~~~~~~~~~~~~~~~~~~

* Fixed a bug where certain operations would fail if an object happened to be
in the top-half of the memory-space. This only impacted 32-bit systems.

.. _v40-0-0:

40.0.0 - 2023-03-24
~~~~~~~~~~~~~~~~~~~


* **BACKWARDS INCOMPATIBLE:** As announced in the 39.0.0 changelog, the way
``cryptography`` links OpenSSL has changed. This only impacts users who
build ``cryptography`` from source (i.e., not from a ``wheel``), and
Expand Down
4 changes: 2 additions & 2 deletions src/cryptography/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"__copyright__",
]

__version__ = "40.0.0"
__version__ = "40.0.1"

__author__ = "The Python Cryptographic Authority and individual contributors"
__copyright__ = f"Copyright 2013-2022 {__author__}"
__copyright__ = f"Copyright 2013-2023 {__author__}"
4 changes: 2 additions & 2 deletions src/cryptography/hazmat/backends/openssl/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def _evp_pkey_to_private_key(
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
Expand Down Expand Up @@ -771,7 +771,7 @@ def _evp_pkey_to_public_key(self, evp_pkey) -> PublicKeyTypes:
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
Expand Down
2 changes: 1 addition & 1 deletion src/cryptography/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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):
Expand Down
2 changes: 1 addition & 1 deletion vectors/cryptography_vectors/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"__version__",
]

__version__ = "40.0.0"
__version__ = "40.0.1"

0 comments on commit 9dd0b26

Please sign in to comment.