Skip to content

Commit 1943192

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/hashlib/evp-mac-134531
2 parents 36628f2 + 588d9fb commit 1943192

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:mod:`hashlib`: improve exception messages when a hash algorithm is not
2+
recognized, blocked by the current security policy or incompatible with
3+
the desired operation (for instance, using HMAC with SHAKE).
4+
Patch by Bénédikt Tran.

Modules/_hashopenssl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ raise_unsupported_algorithm_impl(PyObject *exc_type,
518518
{
519519
// Since OpenSSL 3.0, if the algorithm is not supported or fetching fails,
520520
// the reason lacks the algorithm name.
521-
int errcode = ERR_peek_last_error();
522-
switch (ERR_GET_REASON(errcode)) {
521+
int errcode = ERR_peek_last_error(), reason_id;
522+
switch (reason_id = ERR_GET_REASON(errcode)) {
523523
case ERR_R_UNSUPPORTED: {
524524
PyObject *text = PyUnicode_FromFormat(fallback_format, format_arg);
525525
if (text != NULL) {
@@ -1915,6 +1915,7 @@ _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key,
19151915

19161916
is_xof = PY_EVP_MD_xof(evp);
19171917
Py_BEGIN_ALLOW_THREADS
1918+
is_xof = PY_EVP_MD_xof(evp);
19181919
result = HMAC(
19191920
evp,
19201921
(const void *)key->buf, (int)key->len,

0 commit comments

Comments
 (0)