2018-10-10 15:20:11 +03:00
from waflib import Options
2020-01-24 18:34:42 +03:00
def parse_version(v):
return tuple(map(int, (v.split("."))))
2019-08-15 05:25:41 +03:00
gnutls_min_required_version = "3.4.7"
2018-10-10 15:20:11 +03:00
gnutls_required_version = gnutls_min_required_version
conf.CHECK_CFG(package='gnutls',
args=('"gnutls >= %s" --cflags --libs' % gnutls_required_version),
msg='Checking for GnuTLS >= %s' % gnutls_required_version,
mandatory=True)
2020-01-24 18:34:42 +03:00
gnutls_version = conf.cmd_and_log(conf.env.PKGCONFIG + ['--modversion', 'gnutls']).strip()
2018-10-10 15:20:11 +03:00
# Define gnutls as a system library
conf.SET_TARGET_TYPE('gnutls', 'SYSLIB')
2018-10-10 15:38:24 +03:00
# Check for gnutls_pkcs7_get_embedded_data_oid (>= 3.5.5) required by libmscat
conf.CHECK_FUNCS_IN('gnutls_pkcs7_get_embedded_data_oid', 'gnutls')
2020-06-15 12:50:16 +03:00
# Check for gnutls_set_default_priority_append (>= 3.6.3)
conf.CHECK_FUNCS_IN('gnutls_set_default_priority_append', 'gnutls')
2020-01-24 18:34:42 +03:00
# Check for gnutls_aead_cipher_encryptv2
#
# This is available since version 3.6.10, but 3.6.10 has a bug which got fixed
# in 3.6.11, see:
#
# https://gitlab.com/gnutls/gnutls/-/merge_requests/1085
2020-09-10 12:34:50 +03:00
#
# 3.6.10 - 3.6.14 have a severe memory leak with AES-CCM
# https://gitlab.com/gnutls/gnutls/-/merge_requests/1278
if (parse_version(gnutls_version) > parse_version('3.6.14')):
2020-01-24 18:34:42 +03:00
conf.CHECK_FUNCS_IN('gnutls_aead_cipher_encryptv2', 'gnutls')
2019-08-23 09:40:00 +03:00
2020-03-12 09:13:00 +03:00
# Check if we have support for crypto policies
if conf.CHECK_FUNCS_IN('gnutls_get_system_config_file', 'gnutls'):
conf.DEFINE('HAVE_GNUTLS_CRYPTO_POLICIES', 1)
2019-03-01 19:35:02 +03:00
if conf.CHECK_VALUEOF('GNUTLS_CIPHER_AES_128_CFB8', headers='gnutls/gnutls.h'):
conf.DEFINE('HAVE_GNUTLS_AES_CFB8', 1)
else:
Logs.warn('No gnutls support for AES CFB8')
2019-02-27 16:40:07 +03:00
if conf.CHECK_VALUEOF('GNUTLS_MAC_AES_CMAC_128', headers='gnutls/gnutls.h'):
conf.DEFINE('HAVE_GNUTLS_AES_CMAC', 1)
else:
Logs.warn('No gnutls support for AES CMAC')