summaryrefslogtreecommitdiff
path: root/lib/crypto
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2013-06-08 15:48:40 +1000
committerJeremy Allison <jra@samba.org>2013-06-19 21:32:36 +0200
commitfc13489c91e790ff8952aff1e7db1e6189894e30 (patch)
treeb36ce2a6e54a0141fecdc2b0561050259bb19c2c /lib/crypto
parent5c4772ec1d562a4547391e1dd4956c43e3d635a7 (diff)
downloadsamba-fc13489c91e790ff8952aff1e7db1e6189894e30.tar.gz
samba-fc13489c91e790ff8952aff1e7db1e6189894e30.tar.bz2
samba-fc13489c91e790ff8952aff1e7db1e6189894e30.zip
build: Build with system md5.h on OpenIndiana
This changes (again...) our system md5 detection to cope with how OpenIndiana does md5. I'm becoming increasingly convinced this isn't worth our while (we should have just done samba_md5...), but for now this change seems to work on FreeBSD, OpenIndiana and Linux with libbsd. This needs us to rename struct MD5Context -> MD5_CTX, but we provide a config.h define to rename the type bad if MD5_CTX does not exist (it does however exist in the md5.h from libbsd). Andrew Bartlett Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Jun 19 21:32:36 CEST 2013 on sn-devel-104
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/hmacmd5.c4
-rw-r--r--lib/crypto/hmacmd5.h2
-rw-r--r--lib/crypto/md5.c6
-rw-r--r--lib/crypto/md5test.c2
-rw-r--r--lib/crypto/wscript_build2
-rw-r--r--lib/crypto/wscript_configure1
6 files changed, 9 insertions, 8 deletions
diff --git a/lib/crypto/hmacmd5.c b/lib/crypto/hmacmd5.c
index cfbd428014..882788cd2d 100644
--- a/lib/crypto/hmacmd5.c
+++ b/lib/crypto/hmacmd5.c
@@ -36,7 +36,7 @@ _PUBLIC_ void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Cont
/* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64)
{
- struct MD5Context tctx;
+ MD5_CTX tctx;
MD5Init(&tctx);
MD5Update(&tctx, key, key_len);
@@ -91,7 +91,7 @@ _PUBLIC_ void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context
***********************************************************************/
_PUBLIC_ void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx)
{
- struct MD5Context ctx_o;
+ MD5_CTX ctx_o;
MD5Final(digest, &ctx->ctx);
diff --git a/lib/crypto/hmacmd5.h b/lib/crypto/hmacmd5.h
index 91b8ca586c..aa43d24ff3 100644
--- a/lib/crypto/hmacmd5.h
+++ b/lib/crypto/hmacmd5.h
@@ -25,7 +25,7 @@
typedef struct
{
- struct MD5Context ctx;
+ MD5_CTX ctx;
uint8_t k_ipad[65];
uint8_t k_opad[65];
diff --git a/lib/crypto/md5.c b/lib/crypto/md5.c
index 032474478e..b834c912df 100644
--- a/lib/crypto/md5.c
+++ b/lib/crypto/md5.c
@@ -43,7 +43,7 @@ static void byteReverse(uint8_t *buf, unsigned int longs)
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
* initialization constants.
*/
-_PUBLIC_ void MD5Init(struct MD5Context *ctx)
+_PUBLIC_ void MD5Init(MD5_CTX *ctx)
{
ctx->buf[0] = 0x67452301;
ctx->buf[1] = 0xefcdab89;
@@ -58,7 +58,7 @@ _PUBLIC_ void MD5Init(struct MD5Context *ctx)
* Update context to reflect the concatenation of another buffer full
* of bytes.
*/
-_PUBLIC_ void MD5Update(struct MD5Context *ctx, const uint8_t *buf, size_t len)
+_PUBLIC_ void MD5Update(MD5_CTX *ctx, const uint8_t *buf, size_t len)
{
register uint32_t t;
@@ -106,7 +106,7 @@ _PUBLIC_ void MD5Update(struct MD5Context *ctx, const uint8_t *buf, size_t len)
* Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
-_PUBLIC_ void MD5Final(uint8_t digest[16], struct MD5Context *ctx)
+_PUBLIC_ void MD5Final(uint8_t digest[16], MD5_CTX *ctx)
{
unsigned int count;
uint8_t *p;
diff --git a/lib/crypto/md5test.c b/lib/crypto/md5test.c
index 38626c39bc..f58e131b02 100644
--- a/lib/crypto/md5test.c
+++ b/lib/crypto/md5test.c
@@ -65,7 +65,7 @@ bool torture_local_crypto_md5(struct torture_context *torture)
};
for (i=0; i < ARRAY_SIZE(testarray); i++) {
- struct MD5Context ctx;
+ MD5_CTX ctx;
uint8_t md5[16];
int e;
diff --git a/lib/crypto/wscript_build b/lib/crypto/wscript_build
index e056f653fb..a1f29aed5d 100644
--- a/lib/crypto/wscript_build
+++ b/lib/crypto/wscript_build
@@ -8,7 +8,7 @@ elif bld.CONFIG_SET('HAVE_SYS_MD5_H') and bld.CONFIG_SET('HAVE_LIBMD5'):
extra_deps += ' md5'
elif bld.CONFIG_SET('HAVE_SYS_MD5_H') and bld.CONFIG_SET('HAVE_LIBMD'):
extra_deps += ' md'
-elif not bld.CONFIG_SET('HAVE_COMMONCRYPTO_COMMONDIGEST_H'):
+elif not bld.CONFIG_SET('HAVE_SYS_MD5_H') and not bld.CONFIG_SET('HAVE_COMMONCRYPTO_COMMONDIGEST_H'):
extra_source += ' md5.c'
bld.SAMBA_SUBSYSTEM('LIBCRYPTO',
diff --git a/lib/crypto/wscript_configure b/lib/crypto/wscript_configure
index 21ec566b6b..b7a012f6cf 100644
--- a/lib/crypto/wscript_configure
+++ b/lib/crypto/wscript_configure
@@ -4,5 +4,6 @@ if not conf.CHECK_FUNCS_IN('MD5Init', 'bsd', headers='bsd/md5.h',
checklibc=True)
conf.CHECK_FUNCS_IN('MD5Init', 'md', headers='sys/md5.h',
checklibc=True)
+ conf.CHECK_TYPE('MD5_CTX', 'struct MD5Context', headers='sys/md5.h')
conf.CHECK_FUNCS_IN('CC_MD5_Init', '', headers='CommonCrypto/CommonDigest.h',
checklibc=True)