VERSION: Disable GIT_SNAPSHOT for the 4.15.6 release.
[Samba.git] / wscript_configure_system_gnutls
blob4cdd61f79bba4233d6eb8f2d430079aa3dd0d873
1 from waflib import Options
2 import os
4 def parse_version(v):
5     return tuple(map(int, (v.split("."))))
7 gnutls_min_required_version = "3.4.7"
9 gnutls_required_version = gnutls_min_required_version
11 conf.CHECK_CFG(package='gnutls',
12                args=('"gnutls >= %s" --cflags --libs' % gnutls_required_version),
13                      msg='Checking for GnuTLS >= %s' % gnutls_required_version,
14                      mandatory=True)
16 gnutls_version_str = conf.cmd_and_log(conf.env.PKGCONFIG + ['--modversion', 'gnutls']).strip()
17 gnutls_version = parse_version(gnutls_version_str)
19 # Define gnutls as a system library
20 conf.SET_TARGET_TYPE('gnutls', 'SYSLIB')
22 # Check for gnutls_pkcs7_get_embedded_data_oid (>= 3.5.5) required by libmscat
23 conf.CHECK_FUNCS_IN('gnutls_pkcs7_get_embedded_data_oid', 'gnutls')
25 # Check for gnutls_set_default_priority_append (>= 3.6.3)
26 conf.CHECK_FUNCS_IN('gnutls_set_default_priority_append', 'gnutls')
28 # Check for gnutls_aead_cipher_encryptv2
30 # This is available since version 3.6.10, but 3.6.10 has a bug which got fixed
31 # in 3.6.11, see:
33 #     https://gitlab.com/gnutls/gnutls/-/merge_requests/1085
35 # 3.6.10 - 3.6.14 have a severe memory leak with AES-CCM
36 #     https://gitlab.com/gnutls/gnutls/-/merge_requests/1278
37 if (gnutls_version > parse_version('3.6.10')):
38     if conf.CHECK_FUNCS_IN('gnutls_aead_cipher_encryptv2', 'gnutls'):
39         conf.DEFINE('ALLOW_GNUTLS_AEAD_CIPHER_ENCRYPTV2_AES_GCM', 1)
40         if (gnutls_version > parse_version('3.6.14')):
41             conf.DEFINE('ALLOW_GNUTLS_AEAD_CIPHER_ENCRYPTV2_AES_CCM', 1)
43 if (gnutls_version < parse_version('3.5.2')):
44     conf.DEFINE('HAVE_GNUTLS_AEAD_CIPHER_DECRYPT_PTEXT_LEN_BUG', 1)
46 # Check if gnutls has fips mode support
47 # gnutls_fips140_mode_enabled() is available since 3.3.0
48 fragment = '''
49 #include <gnutls/gnutls.h>
50 #include <stdlib.h>
52 int main(void)
54     unsigned int ok;
56     ok = gnutls_fips140_mode_enabled();
58     return !ok;
60 '''
62 os.environ['GNUTLS_FORCE_FIPS_MODE'] = '1'
63 conf.CHECK_CODE(fragment,
64                 'HAVE_GNUTLS_FIPS_MODE_SUPPORTED',
65                 execute=True,
66                 addmain=False,
67                 add_headers=False,
68                 lib='gnutls',
69                 msg='Checking for gnutls fips mode support')
70 del os.environ['GNUTLS_FORCE_FIPS_MODE']
72 if conf.CHECK_VALUEOF('GNUTLS_CIPHER_AES_128_CFB8', headers='gnutls/gnutls.h'):
73     conf.DEFINE('HAVE_GNUTLS_AES_CFB8', 1)
74 else:
75     Logs.warn('No gnutls support for AES CFB8')
77 if conf.CHECK_VALUEOF('GNUTLS_MAC_AES_CMAC_128', headers='gnutls/gnutls.h'):
78     conf.DEFINE('HAVE_GNUTLS_AES_CMAC', 1)
79 else:
80     Logs.warn('No gnutls support for AES CMAC')