From: Daniel P. Berrangé Date: Wed, 30 Oct 2024 10:09:30 +0000 (+0000) Subject: crypto: perform runtime check for hash/hmac support in gcrypt X-Git-Tag: v9.2.0-rc0~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a7e42752324a264439bef28da3ee3e2563cf0e16;p=thirdparty%2Fqemu.git crypto: perform runtime check for hash/hmac support in gcrypt gcrypto has the ability to dynamically disable hash/hmac algorithms at runtime, so QEMU must perform a runtime check. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Daniel P. Berrangé --- diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 476b7481951..af61c4e75da 100644 --- a/crypto/hash-gcrypt.c +++ b/crypto/hash-gcrypt.c @@ -43,7 +43,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) && qcrypto_hash_alg_map[alg] != GCRY_MD_NONE) { - return true; + return gcry_md_test_algo(qcrypto_hash_alg_map[alg]) == 0; } return false; } diff --git a/crypto/hmac-gcrypt.c b/crypto/hmac-gcrypt.c index 090fe01c1e0..5273086eb9a 100644 --- a/crypto/hmac-gcrypt.c +++ b/crypto/hmac-gcrypt.c @@ -40,7 +40,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgo alg) { if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) && qcrypto_hmac_alg_map[alg] != GCRY_MAC_NONE) { - return true; + return gcry_mac_test_algo(qcrypto_hmac_alg_map[alg]) == 0; } return false;