@@ -61,7 +61,7 @@ class _sha3.shake_256 "SHA3object *" "&SHAKE256type"
6161typedef struct {
6262 PyObject_HEAD
6363 HASHLIB_MUTEX_API
64- Hacl_Hash_SHA3_state_t * hash_state ;
64+ Hacl_Hash_SHA3_state_t * state ;
6565} SHA3object ;
6666
6767#define _SHA3object_CAST (op ) ((SHA3object *)(op))
@@ -132,29 +132,29 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data_obj, int usedforsecurity,
132132 assert (state != NULL );
133133
134134 if (type == state -> sha3_224_type ) {
135- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_224 );
135+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_224 );
136136 }
137137 else if (type == state -> sha3_256_type ) {
138- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_256 );
138+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_256 );
139139 }
140140 else if (type == state -> sha3_384_type ) {
141- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_384 );
141+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_384 );
142142 }
143143 else if (type == state -> sha3_512_type ) {
144- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_512 );
144+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_SHA3_512 );
145145 }
146146 else if (type == state -> shake_128_type ) {
147- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_Shake128 );
147+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_Shake128 );
148148 }
149149 else if (type == state -> shake_256_type ) {
150- self -> hash_state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_Shake256 );
150+ self -> state = Hacl_Hash_SHA3_malloc (Spec_Hash_Definitions_Shake256 );
151151 }
152152 else {
153153 PyErr_BadInternalCall ();
154154 goto error ;
155155 }
156156
157- if (self -> hash_state == NULL ) {
157+ if (self -> state == NULL ) {
158158 (void )PyErr_NoMemory ();
159159 goto error ;
160160 }
@@ -165,11 +165,11 @@ py_sha3_new_impl(PyTypeObject *type, PyObject *data_obj, int usedforsecurity,
165165 /* We do not initialize self->lock here as this is the constructor
166166 * where it is not yet possible to have concurrent access. */
167167 Py_BEGIN_ALLOW_THREADS
168- sha3_update (self -> hash_state , buf .buf , buf .len );
168+ sha3_update (self -> state , buf .buf , buf .len );
169169 Py_END_ALLOW_THREADS
170170 }
171171 else {
172- sha3_update (self -> hash_state , buf .buf , buf .len );
172+ sha3_update (self -> state , buf .buf , buf .len );
173173 }
174174 }
175175
@@ -194,9 +194,9 @@ static int
194194SHA3_clear (PyObject * op )
195195{
196196 SHA3object * self = _SHA3object_CAST (op );
197- if (self -> hash_state != NULL ) {
198- Hacl_Hash_SHA3_free (self -> hash_state );
199- self -> hash_state = NULL ;
197+ if (self -> state != NULL ) {
198+ Hacl_Hash_SHA3_free (self -> state );
199+ self -> state = NULL ;
200200 }
201201 return 0 ;
202202}
@@ -237,9 +237,9 @@ _sha3_sha3_224_copy_impl(SHA3object *self)
237237 return NULL ;
238238 }
239239 ENTER_HASHLIB (self );
240- newobj -> hash_state = Hacl_Hash_SHA3_copy (self -> hash_state );
240+ newobj -> state = Hacl_Hash_SHA3_copy (self -> state );
241241 LEAVE_HASHLIB (self );
242- if (newobj -> hash_state == NULL ) {
242+ if (newobj -> state == NULL ) {
243243 Py_DECREF (newobj );
244244 return PyErr_NoMemory ();
245245 }
@@ -261,10 +261,10 @@ _sha3_sha3_224_digest_impl(SHA3object *self)
261261 // This function errors out if the algorithm is SHAKE. Here, we know this
262262 // not to be the case, and therefore do not perform error checking.
263263 ENTER_HASHLIB (self );
264- (void )Hacl_Hash_SHA3_digest (self -> hash_state , digest );
264+ (void )Hacl_Hash_SHA3_digest (self -> state , digest );
265265 LEAVE_HASHLIB (self );
266266 return PyBytes_FromStringAndSize ((const char * )digest ,
267- Hacl_Hash_SHA3_hash_len (self -> hash_state ));
267+ Hacl_Hash_SHA3_hash_len (self -> state ));
268268}
269269
270270
@@ -280,10 +280,10 @@ _sha3_sha3_224_hexdigest_impl(SHA3object *self)
280280{
281281 unsigned char digest [SHA3_MAX_DIGESTSIZE ];
282282 ENTER_HASHLIB (self );
283- (void )Hacl_Hash_SHA3_digest (self -> hash_state , digest );
283+ (void )Hacl_Hash_SHA3_digest (self -> state , digest );
284284 LEAVE_HASHLIB (self );
285285 return _Py_strhex ((const char * )digest ,
286- Hacl_Hash_SHA3_hash_len (self -> hash_state ));
286+ Hacl_Hash_SHA3_hash_len (self -> state ));
287287}
288288
289289
@@ -310,11 +310,11 @@ _sha3_sha3_224_update_impl(SHA3object *self, PyObject *data)
310310 if (self -> use_mutex ) {
311311 Py_BEGIN_ALLOW_THREADS
312312 PyMutex_Lock (& self -> mutex );
313- sha3_update (self -> hash_state , buf .buf , buf .len );
313+ sha3_update (self -> state , buf .buf , buf .len );
314314 PyMutex_Unlock (& self -> mutex );
315315 Py_END_ALLOW_THREADS
316316 } else {
317- sha3_update (self -> hash_state , buf .buf , buf .len );
317+ sha3_update (self -> state , buf .buf , buf .len );
318318 }
319319
320320 PyBuffer_Release (& buf );
@@ -335,7 +335,7 @@ static PyObject *
335335SHA3_get_block_size (PyObject * op , void * Py_UNUSED (closure ))
336336{
337337 SHA3object * self = _SHA3object_CAST (op );
338- uint32_t rate = Hacl_Hash_SHA3_block_len (self -> hash_state );
338+ uint32_t rate = Hacl_Hash_SHA3_block_len (self -> state );
339339 return PyLong_FromLong (rate );
340340}
341341
@@ -372,18 +372,18 @@ SHA3_get_digest_size(PyObject *op, void *Py_UNUSED(closure))
372372{
373373 // Preserving previous behavior: variable-length algorithms return 0
374374 SHA3object * self = _SHA3object_CAST (op );
375- if (Hacl_Hash_SHA3_is_shake (self -> hash_state ))
375+ if (Hacl_Hash_SHA3_is_shake (self -> state ))
376376 return PyLong_FromLong (0 );
377377 else
378- return PyLong_FromLong (Hacl_Hash_SHA3_hash_len (self -> hash_state ));
378+ return PyLong_FromLong (Hacl_Hash_SHA3_hash_len (self -> state ));
379379}
380380
381381
382382static PyObject *
383383SHA3_get_capacity_bits (PyObject * op , void * Py_UNUSED (closure ))
384384{
385385 SHA3object * self = _SHA3object_CAST (op );
386- uint32_t rate = Hacl_Hash_SHA3_block_len (self -> hash_state ) * 8 ;
386+ uint32_t rate = Hacl_Hash_SHA3_block_len (self -> state ) * 8 ;
387387 assert (rate <= 1600 );
388388 int capacity = 1600 - rate ;
389389 return PyLong_FromLong (capacity );
@@ -394,7 +394,7 @@ static PyObject *
394394SHA3_get_rate_bits (PyObject * op , void * Py_UNUSED (closure ))
395395{
396396 SHA3object * self = _SHA3object_CAST (op );
397- uint32_t rate = Hacl_Hash_SHA3_block_len (self -> hash_state ) * 8 ;
397+ uint32_t rate = Hacl_Hash_SHA3_block_len (self -> state ) * 8 ;
398398 return PyLong_FromLong (rate );
399399}
400400
@@ -491,7 +491,7 @@ _SHAKE_digest(PyObject *op, unsigned long digestlen, int hex)
491491 * - the output length is zero -- we follow the existing behavior and return
492492 * an empty digest, without raising an error */
493493 if (digestlen > 0 ) {
494- (void )Hacl_Hash_SHA3_squeeze (self -> hash_state , digest , digestlen );
494+ (void )Hacl_Hash_SHA3_squeeze (self -> state , digest , digestlen );
495495 }
496496 if (hex ) {
497497 result = _Py_strhex ((const char * )digest , digestlen );
0 commit comments