mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-06-20 03:44:15 +08:00
fix: use constant-time comparisons for auth tags
This commit is contained in:
@@ -216,7 +216,7 @@ int sm4_ccm_decrypt(const SM4_KEY *sm4_key, const uint8_t *iv, size_t ivlen,
|
||||
|
||||
// diff from encrypt
|
||||
gmssl_memxor(mac, mac, block, taglen);
|
||||
if (memcmp(mac, tag, taglen) != 0) {
|
||||
if (gmssl_secure_memcmp(mac, tag, taglen) != 0) {
|
||||
error_print();
|
||||
gmssl_secure_clear(&mac_ctx, sizeof(mac_ctx));
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user