There was an error while loading. Please reload this page.
1 parent c49a516 commit c71ec8aCopy full SHA for c71ec8a
1 file changed
Modules/_sha3/sha3module.c
@@ -114,7 +114,7 @@
114
#endif
115
116
#define SHA3_MAX_DIGESTSIZE 64 /* 64 Bytes (512 Bits) for 224 to 512 */
117
-#define SHA3_LANESIZE 96 /* ExtractLane needs an extra 96 bytes */
+#define SHA3_LANESIZE (20 * 8) /* ExtractLane needs max uint64_t[20] extra. */
118
#define SHA3_state Keccak_HashInstance
119
#define SHA3_init Keccak_HashInitialize
120
#define SHA3_process Keccak_HashUpdate
@@ -605,8 +605,7 @@ _SHAKE_digest(SHA3object *self, unsigned long digestlen, int hex)
605
/* ExtractLane needs at least SHA3_MAX_DIGESTSIZE + SHA3_LANESIZE and
606
* SHA3_LANESIZE extra space.
607
*/
608
- digest = (unsigned char*)PyMem_Malloc(SHA3_LANESIZE +
609
- ((digestlen > SHA3_MAX_DIGESTSIZE) ? digestlen : SHA3_MAX_DIGESTSIZE));
+ digest = (unsigned char*)PyMem_Malloc(digestlen + SHA3_LANESIZE);
610
if (digest == NULL) {
611
return PyErr_NoMemory();
612
}
0 commit comments