@@ -1889,6 +1889,7 @@ _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key,
18891889 }
18901890 assert (evp != NULL );
18911891 is_xof = PY_EVP_MD_xof (evp );
1892+
18921893 Py_BEGIN_ALLOW_THREADS
18931894 result = EVP_Q_mac (
18941895 NULL , OSSL_MAC_NAME_HMAC , NULL , NULL ,
@@ -1905,10 +1906,9 @@ _hashlib_hmac_singleshot_impl(PyObject *module, Py_buffer *key,
19051906 if (evp == NULL ) {
19061907 return NULL ;
19071908 }
1908-
19091909 is_xof = PY_EVP_MD_xof (evp );
1910+
19101911 Py_BEGIN_ALLOW_THREADS
1911- is_xof = PY_EVP_MD_xof (evp );
19121912 result = HMAC (
19131913 evp ,
19141914 (const void * )key -> buf , (int )key -> len ,
@@ -2079,6 +2079,7 @@ hashlib_HMAC_CTX_new_from_digestmod(_hashlibstate *state,
20792079 * nid = EVP_MD_nid (md );
20802080 is_xof = PY_EVP_MD_xof (md );
20812081 PY_EVP_MD_free (md );
2082+
20822083 /*
20832084 * OpenSSL is responsible for managing the EVP_MAC object's ref. count
20842085 * by calling EVP_MAC_up_ref() and EVP_MAC_free() in EVP_MAC_CTX_new()
@@ -2099,18 +2100,19 @@ hashlib_HMAC_CTX_new_from_digestmod(_hashlibstate *state,
20992100 );
21002101#else
21012102 assert (nid == NULL );
2102- md = get_openssl_evp_md (module , digestmod , Py_ht_mac );
2103+ md = get_openssl_evp_md (state , digestmod , Py_ht_mac );
21032104 if (md == NULL ) {
21042105 return NULL ;
21052106 }
2107+ is_xof = PY_EVP_MD_xof (md );
2108+
21062109 ctx = py_openssl_wrapper_HMAC_CTX_new ();
21072110 if (ctx == NULL ) {
21082111 PY_EVP_MD_free (md );
2109- goto error ;
2112+ return NULL ;
21102113 }
21112114
21122115 r = HMAC_Init_ex (ctx , key -> buf , (int )key -> len , md , NULL /* impl */ );
2113- is_xof = PY_EVP_MD_xof (md );
21142116 PY_EVP_MD_free (md );
21152117#endif
21162118 if (r == 0 ) {
0 commit comments