Bläddra i källkod

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>
Daniel P. Berrangé 9 månader sedan
förälder
incheckning
a7e4275232
2 ändrade filer med 2 tillägg och 2 borttagningar
  1. 1 1
      crypto/hash-gcrypt.c
  2. 1 1
      crypto/hmac-gcrypt.c

+ 1 - 1
crypto/hash-gcrypt.c

@@ -43,7 +43,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgo alg)
 {
 {
     if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) &&
     if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) &&
         qcrypto_hash_alg_map[alg] != GCRY_MD_NONE) {
         qcrypto_hash_alg_map[alg] != GCRY_MD_NONE) {
-        return true;
+        return gcry_md_test_algo(qcrypto_hash_alg_map[alg]) == 0;
     }
     }
     return false;
     return false;
 }
 }

+ 1 - 1
crypto/hmac-gcrypt.c

@@ -40,7 +40,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgo alg)
 {
 {
     if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) &&
     if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) &&
         qcrypto_hmac_alg_map[alg] != GCRY_MAC_NONE) {
         qcrypto_hmac_alg_map[alg] != GCRY_MAC_NONE) {
-        return true;
+        return gcry_mac_test_algo(qcrypto_hmac_alg_map[alg]) == 0;
     }
     }
 
 
     return false;
     return false;