diff --git a/README.md b/README.md index b1e8c85f..60c346f0 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Recent significant changes to the library XXX 2018: +* Problem with BLAKE2s and BLAKE2b HMAC mode when the data was zero-length. * KeyRing for storing key pairs and other key material in EEPROM or Flash. * Add better functions to Curve25519 and Ed25519 for generating key pairs. * Noise and NoiseLink protocols. diff --git a/libraries/Crypto/BLAKE2b.cpp b/libraries/Crypto/BLAKE2b.cpp index 7352ec06..d19f7353 100644 --- a/libraries/Crypto/BLAKE2b.cpp +++ b/libraries/Crypto/BLAKE2b.cpp @@ -240,7 +240,7 @@ void BLAKE2b::resetHMAC(const void *key, size_t keyLen) { formatHMACKey(state.m, key, keyLen, 0x36); state.lengthLow += 128; - processChunk(0); + state.chunkSize = 128; } void BLAKE2b::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen) @@ -249,7 +249,7 @@ void BLAKE2b::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t ha finalize(temp, sizeof(temp)); formatHMACKey(state.m, key, keyLen, 0x5C); state.lengthLow += 128; - processChunk(0); + state.chunkSize = 128; update(temp, sizeof(temp)); finalize(hash, hashLen); clean(temp); diff --git a/libraries/Crypto/BLAKE2s.cpp b/libraries/Crypto/BLAKE2s.cpp index a707ff7e..2a548538 100644 --- a/libraries/Crypto/BLAKE2s.cpp +++ b/libraries/Crypto/BLAKE2s.cpp @@ -234,7 +234,7 @@ void BLAKE2s::resetHMAC(const void *key, size_t keyLen) { formatHMACKey(state.m, key, keyLen, 0x36); state.length += 64; - processChunk(0); + state.chunkSize = 64; } void BLAKE2s::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen) @@ -243,7 +243,7 @@ void BLAKE2s::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t ha finalize(temp, sizeof(temp)); formatHMACKey(state.m, key, keyLen, 0x5C); state.length += 64; - processChunk(0); + state.chunkSize = 64; update(temp, sizeof(temp)); finalize(hash, hashLen); clean(temp);