Skip to content

Commit

Permalink
Add code so the hash_state library works in more case.
Browse files Browse the repository at this point in the history
CPython can be compiled with OpenSSL 1.x or OpenSSL 3.x.  Before this
assumed the structure that OpenSSL 1.x was using.  The uses a crude
detection to handle either of them.
  • Loading branch information
manthey committed Nov 16, 2022
1 parent 47b024b commit bf2d3b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion girder/utility/_hash_state.py
Expand Up @@ -64,7 +64,12 @@ def _getHashStateDataPointer(hashObject):
# https://github.com/python/cpython/commit/9d9615f6782be4b1f38b47d4d56cee208c26a970
evpStruct = ctypes.cast(hashPointer[_HASHLIB_EVP_STRUCT_OFFSET],
ctypes.POINTER(ctypes.c_void_p))
stateDataPointer = ctypes.cast(evpStruct[3], ctypes.POINTER(ctypes.c_char))
if evpStruct[1] is None:
# OpenSSL 1.x
stateDataPointer = ctypes.cast(evpStruct[3], ctypes.POINTER(ctypes.c_char))
else:
# OpenSSL 3.x
stateDataPointer = ctypes.cast(evpStruct[7], ctypes.POINTER(ctypes.c_char))

assert stateDataPointer
return stateDataPointer
Expand Down

0 comments on commit bf2d3b6

Please sign in to comment.