@@ -234,24 +234,24 @@ typedef struct py_hmac_hacl_api {
234
234
*
235
235
* The formal signature of this macro is:
236
236
*
237
- * (HACL_HMAC_state *, uint8_t *, uint32_t, PyObject *, (C statements))
237
+ * (HACL_HMAC_state *, uint8_t *, uint32_t, (C statements))
238
238
*/
239
239
#ifndef NDEBUG
240
240
#define Py_HMAC_HACL_UPDATE_ONCE ( \
241
241
HACL_STATE , BUF , LEN , \
242
- ALGORITHM , ERRACTION \
242
+ ERRACTION \
243
243
) \
244
244
do { \
245
245
Py_CHECK_HACL_UINT32_T_LENGTH(LEN); \
246
246
hacl_errno_t code = Py_HMAC_HACL_UPDATE_CALL(HACL_STATE, BUF, LEN); \
247
- if (_hacl_convert_errno(code, (ALGORITHM)) < 0) { \
247
+ if (_hacl_convert_errno(code) < 0) { \
248
248
ERRACTION; \
249
249
} \
250
250
} while (0)
251
251
#else
252
252
#define Py_HMAC_HACL_UPDATE_ONCE ( \
253
253
HACL_STATE , BUF , LEN , \
254
- _ALGORITHM , _ERRACTION \
254
+ _ERRACTION \
255
255
) \
256
256
do { \
257
257
(void)Py_HMAC_HACL_UPDATE_CALL(HACL_STATE, BUF, (LEN)); \
@@ -274,25 +274,25 @@ typedef struct py_hmac_hacl_api {
274
274
*
275
275
* The formal signature of this macro is:
276
276
*
277
- * (HACL_HMAC_state *, uint8_t *, C integer, PyObject *, (C statements))
277
+ * (HACL_HMAC_state *, uint8_t *, C integer, (C statements))
278
278
*/
279
279
#ifdef Py_HMAC_SSIZE_LARGER_THAN_UINT32
280
280
#define Py_HMAC_HACL_UPDATE_LOOP ( \
281
281
HACL_STATE , BUF , LEN , \
282
- ALGORITHM , ERRACTION \
282
+ ERRACTION \
283
283
) \
284
284
do { \
285
285
while ((Py_ssize_t)LEN > UINT32_MAX_AS_SSIZE_T) { \
286
286
Py_HMAC_HACL_UPDATE_ONCE(HACL_STATE, BUF, UINT32_MAX, \
287
- ALGORITHM, ERRACTION); \
287
+ ERRACTION); \
288
288
BUF += UINT32_MAX; \
289
289
LEN -= UINT32_MAX; \
290
290
} \
291
291
} while (0)
292
292
#else
293
293
#define Py_HMAC_HACL_UPDATE_LOOP ( \
294
294
HACL_STATE , BUF , LEN , \
295
- _ALGORITHM , _ERRACTION \
295
+ _ERRACTION \
296
296
)
297
297
#endif
298
298
@@ -301,17 +301,17 @@ typedef struct py_hmac_hacl_api {
301
301
*
302
302
* The formal signature of this macro is:
303
303
*
304
- * (HACL_HMAC_state *, uint8_t *, C integer, PyObject *, (C statements))
304
+ * (HACL_HMAC_state *, uint8_t *, C integer, (C statements))
305
305
*/
306
306
#define Py_HMAC_HACL_UPDATE ( \
307
307
HACL_STATE , BUF , LEN , \
308
- ALGORITHM , ERRACTION \
308
+ ERRACTION \
309
309
) \
310
310
do { \
311
311
Py_HMAC_HACL_UPDATE_LOOP(HACL_STATE, BUF, LEN, \
312
- ALGORITHM, ERRACTION); \
312
+ ERRACTION); \
313
313
Py_HMAC_HACL_UPDATE_ONCE(HACL_STATE, BUF, LEN, \
314
- ALGORITHM, ERRACTION); \
314
+ ERRACTION); \
315
315
} while (0)
316
316
317
317
/*
@@ -491,7 +491,7 @@ narrow_hmac_hash_kind(hmacmodule_state *state, HMAC_Hash_Kind kind)
491
491
* Otherwise, this sets an appropriate exception and returns -1.
492
492
*/
493
493
static int
494
- _hacl_convert_errno (hacl_errno_t code , PyObject * algorithm )
494
+ _hacl_convert_errno (hacl_errno_t code )
495
495
{
496
496
assert (PyGILState_GetThisThreadState () != NULL );
497
497
if (code == Hacl_Streaming_Types_Success ) {
@@ -501,10 +501,7 @@ _hacl_convert_errno(hacl_errno_t code, PyObject *algorithm)
501
501
PyGILState_STATE gstate = PyGILState_Ensure ();
502
502
switch (code ) {
503
503
case Hacl_Streaming_Types_InvalidAlgorithm : {
504
- // only makes sense if an algorithm is known at call time
505
- assert (algorithm != NULL );
506
- assert (PyUnicode_CheckExact (algorithm ));
507
- PyErr_Format (PyExc_ValueError , "invalid algorithm: %U" , algorithm );
504
+ PyErr_SetString (PyExc_ValueError , "invalid HACL* algorithm" );
508
505
break ;
509
506
}
510
507
case Hacl_Streaming_Types_InvalidLength : {
@@ -521,7 +518,7 @@ _hacl_convert_errno(hacl_errno_t code, PyObject *algorithm)
521
518
}
522
519
default : {
523
520
PyErr_Format (PyExc_RuntimeError ,
524
- "HACL* internal routine failed with error code: %d " ,
521
+ "HACL* internal routine failed with error code: %u " ,
525
522
code );
526
523
break ;
527
524
}
@@ -541,7 +538,7 @@ _hacl_hmac_state_new(HMAC_Hash_Kind kind, uint8_t *key, uint32_t len)
541
538
assert (kind != Py_hmac_kind_hash_unknown );
542
539
HACL_HMAC_state * state = NULL ;
543
540
hacl_errno_t retcode = Hacl_Streaming_HMAC_malloc_ (kind , key , len , & state );
544
- if (_hacl_convert_errno (retcode , NULL ) < 0 ) {
541
+ if (_hacl_convert_errno (retcode ) < 0 ) {
545
542
assert (state == NULL );
546
543
return NULL ;
547
544
}
@@ -809,13 +806,13 @@ hmac_feed_initial_data(HMACObject *self, uint8_t *msg, Py_ssize_t len)
809
806
}
810
807
811
808
if (len < HASHLIB_GIL_MINSIZE ) {
812
- Py_HMAC_HACL_UPDATE (self -> state , msg , len , self -> name , return - 1 );
809
+ Py_HMAC_HACL_UPDATE (self -> state , msg , len , return - 1 );
813
810
return 0 ;
814
811
}
815
812
816
813
int res = 0 ;
817
814
Py_BEGIN_ALLOW_THREADS
818
- Py_HMAC_HACL_UPDATE (self -> state , msg , len , self -> name , goto error );
815
+ Py_HMAC_HACL_UPDATE (self -> state , msg , len , goto error );
819
816
goto done ;
820
817
#ifndef NDEBUG
821
818
error :
@@ -983,7 +980,7 @@ hmac_update_state_with_lock(HMACObject *self, uint8_t *buf, Py_ssize_t len)
983
980
int res = 0 ;
984
981
Py_BEGIN_ALLOW_THREADS
985
982
PyMutex_Lock (& self -> mutex ); // unconditionally acquire a lock
986
- Py_HMAC_HACL_UPDATE (self -> state , buf , len , self -> name , goto error );
983
+ Py_HMAC_HACL_UPDATE (self -> state , buf , len , goto error );
987
984
goto done ;
988
985
#ifndef NDEBUG
989
986
error :
@@ -1010,7 +1007,7 @@ static int
1010
1007
hmac_update_state_cond_lock (HMACObject * self , uint8_t * buf , Py_ssize_t len )
1011
1008
{
1012
1009
ENTER_HASHLIB (self ); // conditionally acquire a lock
1013
- Py_HMAC_HACL_UPDATE (self -> state , buf , len , self -> name , goto error );
1010
+ Py_HMAC_HACL_UPDATE (self -> state , buf , len , goto error );
1014
1011
LEAVE_HASHLIB (self );
1015
1012
return 0 ;
1016
1013
@@ -1081,7 +1078,7 @@ hmac_digest_compute_cond_lock(HMACObject *self, uint8_t *digest)
1081
1078
rc == Hacl_Streaming_Types_Success ||
1082
1079
rc == Hacl_Streaming_Types_OutOfMemory
1083
1080
);
1084
- return _hacl_convert_errno (rc , NULL );
1081
+ return _hacl_convert_errno (rc );
1085
1082
}
1086
1083
1087
1084
/*[clinic input]
0 commit comments