Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7707f6f

Browse files
committed
Issue #16234: Modify sha3's block_size method to return NotImplemented.
This makes the sha3 types unusable from the hmac module. HMAC-SHA3 hasn't been specified yet.
1 parent 11dc6c3 commit 7707f6f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Modules/_sha3/sha3module.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
#include "keccak/KeccakF-1600-opt32.c"
141141
#endif
142142

143-
#define SHA3_BLOCKSIZE 200 /* 1600 bits */
143+
/* #define SHA3_BLOCKSIZE 200 // 1600 bits */
144144
#define SHA3_MAX_DIGESTSIZE 64 /* 512 bits */
145145
#define SHA3_state hashState
146146
#define SHA3_init Init
@@ -367,7 +367,11 @@ static PyMethodDef SHA3_methods[] = {
367367
static PyObject *
368368
SHA3_get_block_size(SHA3object *self, void *closure)
369369
{
370-
return PyLong_FromLong(SHA3_BLOCKSIZE);
370+
/* HMAC-SHA3 hasn't been specified yet and no official test vectors are
371+
* available. Thus block_size returns NotImplemented to prevent people
372+
* from using SHA3 with the hmac module.
373+
*/
374+
Py_RETURN_NOTIMPLEMENTED;
371375
}
372376

373377
static PyObject *

0 commit comments

Comments
 (0)