@@ -123,14 +123,6 @@ MD5Type_copy_impl(MD5object *self, PyTypeObject *cls)
123123 return (PyObject * )newobj ;
124124}
125125
126- static void
127- md5_digest_compute_with_lock (MD5object * self , uint8_t * digest )
128- {
129- HASHLIB_ACQUIRE_LOCK (self );
130- Hacl_Hash_MD5_digest (self -> hash_state , digest );
131- HASHLIB_RELEASE_LOCK (self );
132- }
133-
134126/*[clinic input]
135127MD5Type.digest
136128
@@ -142,7 +134,9 @@ MD5Type_digest_impl(MD5object *self)
142134/*[clinic end generated code: output=eb691dc4190a07ec input=bc0c4397c2994be6]*/
143135{
144136 uint8_t digest [MD5_DIGESTSIZE ];
145- md5_digest_compute_with_lock (self , digest );
137+ HASHLIB_ACQUIRE_LOCK (self );
138+ Hacl_Hash_MD5_digest (self -> hash_state , digest );
139+ HASHLIB_RELEASE_LOCK (self );
146140 return PyBytes_FromStringAndSize ((const char * )digest , MD5_DIGESTSIZE );
147141}
148142
@@ -157,7 +151,9 @@ MD5Type_hexdigest_impl(MD5object *self)
157151/*[clinic end generated code: output=17badced1f3ac932 input=b60b19de644798dd]*/
158152{
159153 uint8_t digest [MD5_DIGESTSIZE ];
160- md5_digest_compute_with_lock (self , digest );
154+ HASHLIB_ACQUIRE_LOCK (self );
155+ Hacl_Hash_MD5_digest (self -> hash_state , digest );
156+ HASHLIB_RELEASE_LOCK (self );
161157 return _Py_strhex ((const char * )digest , MD5_DIGESTSIZE );
162158}
163159
@@ -197,13 +193,11 @@ MD5Type_update_impl(MD5object *self, PyObject *obj)
197193{
198194 Py_buffer buf ;
199195 GET_BUFFER_VIEW_OR_ERROUT (obj , & buf );
200- if (buf .len > 0 ) {
201- Py_BEGIN_ALLOW_THREADS
202- HASHLIB_ACQUIRE_LOCK (self );
203- _hacl_md5_state_update (self -> hash_state , buf .buf , buf .len );
204- HASHLIB_RELEASE_LOCK (self );
205- Py_END_ALLOW_THREADS
206- }
196+ Py_BEGIN_ALLOW_THREADS
197+ HASHLIB_ACQUIRE_LOCK (self );
198+ _hacl_md5_state_update (self -> hash_state , buf .buf , buf .len );
199+ HASHLIB_RELEASE_LOCK (self );
200+ Py_END_ALLOW_THREADS
207201 PyBuffer_Release (& buf );
208202 Py_RETURN_NONE ;
209203}
0 commit comments