@samitouri / QOSamiQemu / commits / 15ebb1ec8c

meson.build: re-add explicit gcrypt/nettle request check

c4b3d0074 removed the check that nettle or gcrypt were explicitly requested as the crypto library to use, breaking the --enable-nettle and --enable-gcrypt options. Re-add the logic to force usage of nettle or gcrypt for crypto operations, while still keeping gnutls for TLS. Fixes: c4b3d0074 (crypto: bump min gnutls to 3.7.5) Tested-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Luc Michel <luc.michel@amd.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Luc Michel committed Jul 10, 2026 at 15:25 UTC 15ebb1ec8c06360c0fff0719b880ad55cdfe4db2
4 files changed +14 -4
crypto/cipher.c
+1 -1
@@ -142,7 +142,7 @@ qcrypto_cipher_validate_key_length(QCryptoCipherAlgo alg,
142 #include "cipher-gcrypt.c.inc"
143 #elif defined CONFIG_NETTLE
144 #include "cipher-nettle.c.inc"
145 -#elif defined CONFIG_GNUTLS
145 +#elif defined CONFIG_GNUTLS_CRYPTO
146 #include "cipher-gnutls.c.inc"
147 #else
148 #include "cipher-stub.c.inc"
crypto/meson.build
+1 -1
@@ -38,7 +38,7 @@ if nettle.found()
38 endif
39 elif gcrypt.found()
40 crypto_ss.add(gcrypt, files('hash-gcrypt.c', 'hmac-gcrypt.c', 'pbkdf-gcrypt.c'))
41 -elif gnutls.found()
41 +elif gnutls_crypto.found()
42 crypto_ss.add(gnutls, files('hash-gnutls.c', 'hmac-gnutls.c', 'pbkdf-gnutls.c'))
43 else
44 crypto_ss.add(files('hash-glib.c', 'hmac-glib.c', 'pbkdf-stub.c'))
meson.build
+10 -1
@@ -1783,11 +1783,13 @@ if not get_option('libcbor').auto() or have_system
1783 endif
1784
1785 gnutls = not_found
1786 +gnutls_crypto = not_found
1787 gnutls_bug1717_workaround = false
1788 if get_option('gnutls').enabled() or (get_option('gnutls').auto() and have_system)
1789 gnutls = dependency('gnutls', version: '>=3.7.5',
1790 method: 'pkg-config',
1791 required: get_option('gnutls'))
1792 + gnutls_crypto = gnutls
1793
1794 #if gnutls.found() and not get_option('gnutls-bug1717-workaround').disabled()
1795 # XXX: when bug 1717 is resolved, add logic to probe for
@@ -1811,7 +1813,12 @@ if get_option('nettle').enabled() and get_option('gcrypt').enabled()
1813 error('Only one of gcrypt & nettle can be enabled')
1814 endif
1815
1814 -if not gnutls.found()
1816 +# Explicit nettle/gcrypt request, so ignore gnutls for crypto
1817 +if get_option('nettle').enabled() or get_option('gcrypt').enabled()
1818 + gnutls_crypto = not_found
1819 +endif
1820 +
1821 +if not gnutls_crypto.found()
1822 if (not get_option('gcrypt').auto() or have_system) and not get_option('nettle').enabled()
1823 gcrypt = dependency('libgcrypt', version: '>=1.9.4',
1824 required: get_option('gcrypt'))
@@ -2513,6 +2520,7 @@ config_host_data.set('CONFIG_XKBCOMMON', xkbcommon.found())
2520 config_host_data.set('CONFIG_KEYUTILS', keyutils.found())
2521 config_host_data.set('CONFIG_GETTID', has_gettid)
2522 config_host_data.set('CONFIG_GNUTLS', gnutls.found())
2523 +config_host_data.set('CONFIG_GNUTLS_CRYPTO', gnutls_crypto.found())
2524 config_host_data.set('CONFIG_GNUTLS_BUG1717_WORKAROUND', gnutls_bug1717_workaround)
2525 config_host_data.set('CONFIG_TASN1', tasn1.found())
2526 config_host_data.set('CONFIG_GCRYPT', gcrypt.found())
@@ -4865,6 +4873,7 @@ summary_info = {}
4873 summary_info += {'TLS priority': get_option('tls_priority')}
4874 summary_info += {'GNUTLS support': gnutls}
4875 if gnutls.found()
4876 + summary_info += {' GNUTLS crypto': gnutls_crypto.found()}
4877 summary_info += {' GNUTLS bug 1717 workaround': gnutls_bug1717_workaround }
4878 endif
4879 summary_info += {'libgcrypt': gcrypt}
tests/unit/test-crypto-block.c
+2 -1
@@ -31,7 +31,8 @@
31 #endif
32
33 #if (defined(_WIN32) || defined RUSAGE_THREAD) && \
34 - (defined(CONFIG_NETTLE) || defined(CONFIG_GCRYPT))
34 + (defined(CONFIG_NETTLE) || defined(CONFIG_GCRYPT) || \
35 + defined(CONFIG_GNUTLS_CRYPTO))
36 #define TEST_LUKS
37 #else
38 #undef TEST_LUKS