Skip to content

Commit a7e4275

Browse files
committed
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é <[email protected]> Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent bbd40a0 commit a7e4275

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

crypto/hash-gcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ gboolean qcrypto_hash_supports(QCryptoHashAlgo alg)
4343
{
4444
if (alg < G_N_ELEMENTS(qcrypto_hash_alg_map) &&
4545
qcrypto_hash_alg_map[alg] != GCRY_MD_NONE) {
46-
return true;
46+
return gcry_md_test_algo(qcrypto_hash_alg_map[alg]) == 0;
4747
}
4848
return false;
4949
}

crypto/hmac-gcrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool qcrypto_hmac_supports(QCryptoHashAlgo alg)
4040
{
4141
if (alg < G_N_ELEMENTS(qcrypto_hmac_alg_map) &&
4242
qcrypto_hmac_alg_map[alg] != GCRY_MAC_NONE) {
43-
return true;
43+
return gcry_mac_test_algo(qcrypto_hmac_alg_map[alg]) == 0;
4444
}
4545

4646
return false;

0 commit comments

Comments
 (0)