Closed falko-strenzke closed 1 year ago
cmac seems to be affected as well.
Botan does it correctly in src/lib/mac/mac.cpp:
bool MessageAuthenticationCode::verify_mac_result(const uint8_t mac[], size_t length) {
secure_vector<uint8_t> our_mac = final();
if(our_mac.size() != length) {
return false;
}
return constant_time_compare(our_mac.data(), mac, length);
}
Reported to gcrypt-devel 2023-10-18
If there a MAC is provided to the verify function that is shorter than the regular MAC length, the verification succeeds if that shorter MAC is a matching the start of the regular MAC. This behaviour incurs the risk that an implementation issues the verification of a zero-length attacker controlled MAC that then verifies correctly.