Python 3.10: unbreak _hashlib build

The build was broken in the update to 3.10.2 due to the upstream commit
3ce6945f5f
This seems to have escaped notice of the maintainers because the build
system only whines and carries on instead of failing (although this was
also visible in the PLIST). Avoid use of undefined short names and NIDs
and do not use an inexistent flag.

ok sthen
This commit is contained in:
tb 2022-04-29 03:34:57 +00:00
parent 618399e44d
commit 98e25b6c8d
3 changed files with 34 additions and 1 deletions

View File

@ -8,6 +8,6 @@ SHARED_LIBS = python3.10 0.0
VERSION_SPEC = >=3.10,<3.11
PORTROACH = limit:^3\.10
REVISION = 0
REVISION = 1
.include <bsd.port.mk>

View File

@ -13,3 +13,35 @@ Index: Modules/_hashopenssl.c
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#define PY_EVP_MD EVP_MD
#define PY_EVP_MD_fetch(algorithm, properties) EVP_MD_fetch(NULL, algorithm, properties)
@@ -119,6 +114,7 @@ static const py_hashentry_t py_hashes[] = {
PY_HASH_ENTRY(Py_hash_sha256, "SHA256", SN_sha256, NID_sha256),
PY_HASH_ENTRY(Py_hash_sha384, "SHA384", SN_sha384, NID_sha384),
PY_HASH_ENTRY(Py_hash_sha512, "SHA512", SN_sha512, NID_sha512),
+#if !defined(LIBRESSL_VERSION_NUMBER)
/* truncated sha2 */
PY_HASH_ENTRY(Py_hash_sha512_224, "SHA512_224", SN_sha512_224, NID_sha512_224),
PY_HASH_ENTRY(Py_hash_sha512_256, "SHA512_256", SN_sha512_256, NID_sha512_256),
@@ -133,6 +129,7 @@ static const py_hashentry_t py_hashes[] = {
/* blake2 digest */
PY_HASH_ENTRY(Py_hash_blake2s, "blake2s256", SN_blake2s256, NID_blake2s256),
PY_HASH_ENTRY(Py_hash_blake2b, "blake2b512", SN_blake2b512, NID_blake2b512),
+#endif
PY_HASH_ENTRY(NULL, NULL, NULL, 0),
};
@@ -873,11 +870,15 @@ py_evp_fromname(PyObject *module, const char *digestna
goto exit;
}
+#if defined(LIBRESSL_VERSION_NUMBER)
+ type = get_hashlib_state(module)->EVPtype;
+#else
if ((EVP_MD_flags(digest) & EVP_MD_FLAG_XOF) == EVP_MD_FLAG_XOF) {
type = get_hashlib_state(module)->EVPXOFtype;
} else {
type = get_hashlib_state(module)->EVPtype;
}
+#endif
self = newEVPobject(type);
if (self == NULL) {

View File

@ -2031,6 +2031,7 @@ lib/python3.10/lib-dynload/
@so lib/python3.10/lib-dynload/_dbm.cpython-310.so
@so lib/python3.10/lib-dynload/_decimal.cpython-310.so
@so lib/python3.10/lib-dynload/_elementtree.cpython-310.so
@so lib/python3.10/lib-dynload/_hashlib.cpython-310.so
@so lib/python3.10/lib-dynload/_heapq.cpython-310.so
@so lib/python3.10/lib-dynload/_json.cpython-310.so
@so lib/python3.10/lib-dynload/_lsprof.cpython-310.so