diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2024-10-30 10:09:30 +0000 |
---|---|---|
committer | Daniel P. Berrangé <berrange@redhat.com> | 2024-11-05 18:37:18 +0000 |
commit | a7e42752324a264439bef28da3ee3e2563cf0e16 (patch) | |
tree | 53690aa6f6563d24c815b1b7dd4bf3de9c56d6e9 /crypto | |
parent | bbd40a0e316bb06e1320d71fa3be7e2f3d62c7a9 (diff) |
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é <philmd@linaro.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/hash-gcrypt.c | 2 | ||||
-rw-r--r-- | crypto/hmac-gcrypt.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/crypto/hash-gcrypt.c b/crypto/hash-gcrypt.c index 476b748195..af61c4e75d 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 090fe01c1e..5273086eb9 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; |