crypto: Use libbsd md5 header, if available.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 6 Feb 2012 16:47:25 +0000 (17:47 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 7 Feb 2012 00:11:08 +0000 (01:11 +0100)
lib/crypto/md5.h
lib/crypto/wscript_build
lib/crypto/wscript_configure [new file with mode: 0644]
wscript

index e61c27a..bcdf50c 100644 (file)
@@ -1,10 +1,15 @@
 #ifndef MD5_H
 #define MD5_H
+
 #ifndef HEADER_MD5_H
 /* Try to avoid clashes with OpenSSL */
 #define HEADER_MD5_H 
 #endif
 
+#ifdef HAVE_BSD_MD5_H
+/* Try to avoid clashes with BSD MD5 implementation */
+#include <bsd/md5.h>
+#else
 typedef struct MD5Context {
        uint32_t buf[4];
        uint32_t bits[2];
@@ -17,5 +22,6 @@ void MD5Init(MD5_CTX *context);
 void MD5Update(MD5_CTX *context, const uint8_t *buf,
               size_t len);
 void MD5Final(uint8_t digest[MD5_DIGEST_LENGTH], MD5_CTX *context);
+#endif /* HAVE_BSD_MD5_H */
 
 #endif /* !MD5_H */
index 7bc4eb7..6ad1cad 100644 (file)
@@ -1,8 +1,15 @@
 #!/usr/bin/env python
 
+extra_source = ''
+extra_deps = ''
+if bld.CONFIG_SET('HAVE_BSD_MD5_H'):
+       extra_deps += ' bsd'
+else:
+       extra_source += ' md5.c'
+
 bld.SAMBA_SUBSYSTEM('LIBCRYPTO',
-       source='crc32.c md5.c hmacmd5.c md4.c arcfour.c sha256.c hmacsha256.c aes.c rijndael-alg-fst.c',
-       deps='talloc'
+       source='crc32.c hmacmd5.c md4.c arcfour.c sha256.c hmacsha256.c aes.c rijndael-alg-fst.c' + extra_source,
+       deps='talloc' + extra_deps
        )
 
 
diff --git a/lib/crypto/wscript_configure b/lib/crypto/wscript_configure
new file mode 100644 (file)
index 0000000..77d21e9
--- /dev/null
@@ -0,0 +1,2 @@
+conf.CHECK_FUNCS_IN('MD5Init', 'bsd', headers='bsd/md5.h',
+    checklibc=True)
diff --git a/wscript b/wscript
index 18daaac..9db278c 100755 (executable)
--- a/wscript
+++ b/wscript
@@ -97,6 +97,7 @@ def configure(conf):
     conf.RECURSE('lib/popt')
     conf.RECURSE('lib/subunit/c')
     conf.RECURSE('libcli/smbreadline')
+    conf.RECURSE('lib/crypto')
     conf.RECURSE('pidl')
     conf.RECURSE('selftest')
     conf.RECURSE('source3')