diff options
author | Christian Heimes <christian@python.org> | 2016-09-08 13:04:38 (GMT) |
---|---|---|
committer | Christian Heimes <christian@python.org> | 2016-09-08 13:04:38 (GMT) |
commit | c71ec8aef37f8a72d1dc3237b127f15a32ba0997 (patch) | |
tree | a70901515aa44ecc433ee753a800204c24380e7d | |
parent | c49a516ae987bc5b5c2a363a16365b3d863d7c2c (diff) | |
download | cpython-c71ec8aef37f8a72d1dc3237b127f15a32ba0997.zip cpython-c71ec8aef37f8a72d1dc3237b127f15a32ba0997.tar.gz cpython-c71ec8aef37f8a72d1dc3237b127f15a32ba0997.tar.bz2 |
sha3: let's keep it simple and always allocate enough extra space for uint64_t[20].
-rw-r--r-- | Modules/_sha3/sha3module.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index 8d7eff4..04ac631 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -114,7 +114,7 @@ #endif #define SHA3_MAX_DIGESTSIZE 64 /* 64 Bytes (512 Bits) for 224 to 512 */ -#define SHA3_LANESIZE 96 /* ExtractLane needs an extra 96 bytes */ +#define SHA3_LANESIZE (20 * 8) /* ExtractLane needs max uint64_t[20] extra. */ #define SHA3_state Keccak_HashInstance #define SHA3_init Keccak_HashInitialize #define SHA3_process Keccak_HashUpdate @@ -605,8 +605,7 @@ _SHAKE_digest(SHA3object *self, unsigned long digestlen, int hex) /* ExtractLane needs at least SHA3_MAX_DIGESTSIZE + SHA3_LANESIZE and * SHA3_LANESIZE extra space. */ - digest = (unsigned char*)PyMem_Malloc(SHA3_LANESIZE + - ((digestlen > SHA3_MAX_DIGESTSIZE) ? digestlen : SHA3_MAX_DIGESTSIZE)); + digest = (unsigned char*)PyMem_Malloc(digestlen + SHA3_LANESIZE); if (digest == NULL) { return PyErr_NoMemory(); } |