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