1524bc
From e2d47f1a730131017b7d4d71713a174da6cb270c Mon Sep 17 00:00:00 2001
1524bc
From: Andreas Schneider <asn@samba.org>
1524bc
Date: Fri, 15 Mar 2019 14:54:13 +0100
1524bc
Subject: [PATCH 103/187] lib:crypto: Prepare not to build AES or AES-CMAC if
1524bc
 we use GnuTLS support it
1524bc
1524bc
Samba will soon require GnuTLS >= 3.4.7.
1524bc
1524bc
Signed-off-by: Andreas Schneider <asn@samba.org>
1524bc
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
1524bc
1524bc
Adjusted by Andrew Bartlett from an earlier more comprehensive patch by Andreas
1524bc
1524bc
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
1524bc
(cherry picked from commit 1f6104f09a30cf3816fd5a580ce1b4be5b94848c)
1524bc
---
1524bc
 lib/crypto/wscript_build      | 52 ++++++++++++++++++++++++++++-------
1524bc
 source4/torture/local/local.c |  3 ++
1524bc
 2 files changed, 45 insertions(+), 10 deletions(-)
1524bc
1524bc
diff --git a/lib/crypto/wscript_build b/lib/crypto/wscript_build
1524bc
index a26c10b627b..9a7c715754d 100644
1524bc
--- a/lib/crypto/wscript_build
1524bc
+++ b/lib/crypto/wscript_build
1524bc
@@ -20,27 +20,59 @@ bld.SAMBA_SUBSYSTEM('LIBCRYPTO_RC4',
1524bc
                     deps='talloc',
1524bc
                     enabled=not bld.CONFIG_SET('HAVE_GNUTLS_3_4_7'))
1524bc
 
1524bc
+bld.SAMBA_SUBSYSTEM('LIBCRYPTO_AES_CCM',
1524bc
+                    source='aes_ccm_128.c',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
+bld.SAMBA_SUBSYSTEM('LIBCRYPTO_AES_GCM',
1524bc
+                    source='aes_gcm_128.c',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
+bld.SAMBA_SUBSYSTEM('LIBCRYPTO_AES',
1524bc
+                    source='aes.c rijndael-alg-fst.c',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
+bld.SAMBA_SUBSYSTEM('LIBCRYPTO_AES_CMAC',
1524bc
+                    source='aes_cmac_128.c',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
 bld.SAMBA_SUBSYSTEM('LIBCRYPTO',
1524bc
         source='''
1524bc
                md4.c
1524bc
-               aes.c
1524bc
-               rijndael-alg-fst.c
1524bc
-               aes_cmac_128.c
1524bc
-               aes_ccm_128.c
1524bc
-               aes_gcm_128.c
1524bc
                ''',
1524bc
         deps='''
1524bc
              talloc
1524bc
              LIBCRYPTO_RC4
1524bc
+             LIBCRYPTO_AES
1524bc
+             LIBCRYPTO_AES_CCM
1524bc
+             LIBCRYPTO_AES_GCM
1524bc
+             LIBCRYPTO_AES_CMAC
1524bc
              ''' + extra_deps)
1524bc
 
1524bc
+bld.SAMBA_SUBSYSTEM('TORTURE_LIBCRYPTO_AES_CCM',
1524bc
+                    source='aes_ccm_128_test.c',
1524bc
+                    autoproto='aes_ccm_test_proto.h',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
+bld.SAMBA_SUBSYSTEM('TORTURE_LIBCRYPTO_AES_GCM',
1524bc
+                    source='aes_gcm_128_test.c',
1524bc
+                    autoproto='aes_gcm_test_proto.h',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
+bld.SAMBA_SUBSYSTEM('TORTURE_LIBCRYPTO_AES_CMAC',
1524bc
+                    source='aes_cmac_128_test.c',
1524bc
+                    autoproto='aes_cmac_test_proto.h',
1524bc
+                    deps='talloc')
1524bc
+
1524bc
 bld.SAMBA_SUBSYSTEM('TORTURE_LIBCRYPTO',
1524bc
-        source='''md4test.c
1524bc
-            aes_cmac_128_test.c aes_ccm_128_test.c aes_gcm_128_test.c
1524bc
-        ''',
1524bc
+        source='md4test.c',
1524bc
         autoproto='test_proto.h',
1524bc
-        deps='LIBCRYPTO'
1524bc
-        )
1524bc
+        deps='''
1524bc
+             LIBCRYPTO
1524bc
+             TORTURE_LIBCRYPTO_AES_CCM
1524bc
+             TORTURE_LIBCRYPTO_AES_GCM
1524bc
+             TORTURE_LIBCRYPTO_AES_CMAC
1524bc
+             ''')
1524bc
 
1524bc
 bld.SAMBA_PYTHON('python_crypto',
1524bc
                  source='py_crypto.c',
1524bc
diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c
1524bc
index acd88772ab7..fa4061c108b 100644
1524bc
--- a/source4/torture/local/local.c
1524bc
+++ b/source4/torture/local/local.c
1524bc
@@ -23,6 +23,9 @@
1524bc
 #include "torture/ndr/proto.h"
1524bc
 #include "torture/auth/proto.h"
1524bc
 #include "../lib/crypto/test_proto.h"
1524bc
+#include "../lib/crypto/aes_ccm_test_proto.h"
1524bc
+#include "../lib/crypto/aes_gcm_test_proto.h"
1524bc
+#include "../lib/crypto/aes_cmac_test_proto.h"
1524bc
 #include "lib/registry/tests/proto.h"
1524bc
 #include "lib/replace/replace-testsuite.h"
1524bc
 
1524bc
-- 
1524bc
2.23.0
1524bc