mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
735f3d7dde
The initial implementation of gnutls_aead_cipher_decrypt() had a bug and used: *ptext_len = ctext_len; instead of: *ptext_len = ctext_len - tag_size; This got fixed with gnutls 3.5.2. As we only require gnutls 3.4.7 we need to cope with this... BUG: https://bugzilla.samba.org/show_bug.cgi?id=14968 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Feb 2 18:29:08 UTC 2022 on sn-devel-184
85 lines
2.7 KiB
Plaintext
85 lines
2.7 KiB
Plaintext
from waflib import Options
|
|
import os
|
|
|
|
def parse_version(v):
|
|
return tuple(map(int, (v.split("."))))
|
|
|
|
gnutls_min_required_version = "3.4.7"
|
|
|
|
conf.CHECK_FUNCS('getrandom', headers='sys/random.h')
|
|
if not conf.CONFIG_SET('HAVE_GETRANDOM'):
|
|
gnutls_min_required_version = "3.7.2"
|
|
|
|
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)
|
|
|
|
gnutls_version_str = conf.cmd_and_log(conf.env.PKGCONFIG + ['--modversion', 'gnutls']).strip()
|
|
gnutls_version = parse_version(gnutls_version_str)
|
|
|
|
# Define gnutls as a system library
|
|
conf.SET_TARGET_TYPE('gnutls', 'SYSLIB')
|
|
|
|
# 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')
|
|
|
|
# Check for gnutls_set_default_priority_append (>= 3.6.3)
|
|
conf.CHECK_FUNCS_IN('gnutls_set_default_priority_append', 'gnutls')
|
|
|
|
# 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
|
|
#
|
|
# 3.6.10 - 3.6.14 have a severe memory leak with AES-CCM
|
|
# https://gitlab.com/gnutls/gnutls/-/merge_requests/1278
|
|
if (gnutls_version > parse_version('3.6.10')):
|
|
if conf.CHECK_FUNCS_IN('gnutls_aead_cipher_encryptv2', 'gnutls'):
|
|
conf.DEFINE('ALLOW_GNUTLS_AEAD_CIPHER_ENCRYPTV2_AES_GCM', 1)
|
|
if (gnutls_version > parse_version('3.6.14')):
|
|
conf.DEFINE('ALLOW_GNUTLS_AEAD_CIPHER_ENCRYPTV2_AES_CCM', 1)
|
|
|
|
if (gnutls_version < parse_version('3.5.2')):
|
|
conf.DEFINE('HAVE_GNUTLS_AEAD_CIPHER_DECRYPT_PTEXT_LEN_BUG', 1)
|
|
|
|
# Check if gnutls has fips mode support
|
|
# gnutls_fips140_mode_enabled() is available since 3.3.0
|
|
fragment = '''
|
|
#include <gnutls/gnutls.h>
|
|
#include <stdlib.h>
|
|
|
|
int main(void)
|
|
{
|
|
unsigned int ok;
|
|
|
|
ok = gnutls_fips140_mode_enabled();
|
|
|
|
return !ok;
|
|
}
|
|
'''
|
|
|
|
os.environ['GNUTLS_FORCE_FIPS_MODE'] = '1'
|
|
conf.CHECK_CODE(fragment,
|
|
'HAVE_GNUTLS_FIPS_MODE_SUPPORTED',
|
|
execute=True,
|
|
addmain=False,
|
|
add_headers=False,
|
|
lib='gnutls',
|
|
msg='Checking for gnutls fips mode support')
|
|
del os.environ['GNUTLS_FORCE_FIPS_MODE']
|
|
|
|
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')
|
|
|
|
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')
|