summaryrefslogtreecommitdiff
path: root/lib/crypto
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-06 17:22:53 +0100
committerAndrew Bartlett <abartlet@samba.org>2019-05-21 01:18:08 +0000
commit03cbef2beff02d54063648725a71be6479886d09 (patch)
treecc413304db793b9020e4918a73cf4ad990086382 /lib/crypto
parent5b73c68cd2b90e244d9ccd449c89ad8be2845ce0 (diff)
downloadsamba-03cbef2beff02d54063648725a71be6479886d09.tar.gz
lib:crypto: Remove obsolete MD5 and HMAC MD5
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue May 21 01:18:08 UTC 2019 on sn-devel-184
Diffstat (limited to 'lib/crypto')
-rw-r--r--lib/crypto/crypto.h2
-rw-r--r--lib/crypto/hmacmd5.c117
-rw-r--r--lib/crypto/hmacmd5.h41
-rw-r--r--lib/crypto/hmacmd5test.c103
-rw-r--r--lib/crypto/md5.c251
-rw-r--r--lib/crypto/md5.h42
-rw-r--r--lib/crypto/md5test.c96
-rw-r--r--lib/crypto/wscript_build15
-rw-r--r--lib/crypto/wscript_configure9
9 files changed, 3 insertions, 673 deletions
diff --git a/lib/crypto/crypto.h b/lib/crypto/crypto.h
index 20abb13016a..12aebaecefd 100644
--- a/lib/crypto/crypto.h
+++ b/lib/crypto/crypto.h
@@ -21,8 +21,6 @@
#define _SAMBA_CRYPTO_H_
#include "../lib/crypto/md4.h"
-#include "../lib/crypto/md5.h"
-#include "../lib/crypto/hmacmd5.h"
#include "../lib/crypto/arcfour.h"
#include "../lib/crypto/aes.h"
#include "../lib/crypto/aes_cmac_128.h"
diff --git a/lib/crypto/hmacmd5.c b/lib/crypto/hmacmd5.c
deleted file mode 100644
index 882788cd2dd..00000000000
--- a/lib/crypto/hmacmd5.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- HMAC MD5 code for use in NTLMv2
- Copyright (C) Luke Kenneth Casson Leighton 1996-2000
- Copyright (C) Andrew Tridgell 1992-2000
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/* taken direct from rfc2104 implementation and modified for suitable use
- * for ntlmv2.
- */
-
-#include "replace.h"
-#include "../lib/crypto/hmacmd5.h"
-
-/***********************************************************************
- the rfc 2104 version of hmac_md5 initialisation.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Context *ctx)
-{
- int i;
- uint8_t tk[16];
-
- /* if key is longer than 64 bytes reset it to key=MD5(key) */
- if (key_len > 64)
- {
- MD5_CTX tctx;
-
- MD5Init(&tctx);
- MD5Update(&tctx, key, key_len);
- MD5Final(tk, &tctx);
-
- key = tk;
- key_len = 16;
- }
-
- /* start out by storing key in pads */
- ZERO_STRUCT(ctx->k_ipad);
- ZERO_STRUCT(ctx->k_opad);
- memcpy( ctx->k_ipad, key, key_len);
- memcpy( ctx->k_opad, key, key_len);
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++)
- {
- ctx->k_ipad[i] ^= 0x36;
- ctx->k_opad[i] ^= 0x5c;
- }
-
- MD5Init(&ctx->ctx);
- MD5Update(&ctx->ctx, ctx->k_ipad, 64);
-}
-
-/***********************************************************************
- the microsoft version of hmac_md5 initialisation.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_init_limK_to_64(const uint8_t *key, int key_len,
- HMACMD5Context *ctx)
-{
- /* if key is longer than 64 bytes truncate it */
- if (key_len > 64)
- {
- key_len = 64;
- }
-
- hmac_md5_init_rfc2104(key, key_len, ctx);
-}
-
-/***********************************************************************
- update hmac_md5 "inner" buffer
-***********************************************************************/
-_PUBLIC_ void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context *ctx)
-{
- MD5Update(&ctx->ctx, text, text_len); /* then text of datagram */
-}
-
-/***********************************************************************
- finish off hmac_md5 "inner" buffer and generate outer one.
-***********************************************************************/
-_PUBLIC_ void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx)
-{
- MD5_CTX ctx_o;
-
- MD5Final(digest, &ctx->ctx);
-
- MD5Init(&ctx_o);
- MD5Update(&ctx_o, ctx->k_opad, 64);
- MD5Update(&ctx_o, digest, 16);
- MD5Final(digest, &ctx_o);
-}
-
-/***********************************************************
- single function to calculate an HMAC MD5 digest from data.
- use the microsoft hmacmd5 init method because the key is 16 bytes.
-************************************************************/
-_PUBLIC_ void hmac_md5(const uint8_t key[16], const uint8_t *data, int data_len, uint8_t *digest)
-{
- HMACMD5Context ctx;
- hmac_md5_init_limK_to_64(key, 16, &ctx);
- if (data_len != 0)
- {
- hmac_md5_update(data, data_len, &ctx);
- }
- hmac_md5_final(digest, &ctx);
-}
diff --git a/lib/crypto/hmacmd5.h b/lib/crypto/hmacmd5.h
deleted file mode 100644
index aa43d24ff38..00000000000
--- a/lib/crypto/hmacmd5.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Interface header: HMAC MD5 code
- Copyright (C) Luke Kenneth Casson Leighton 1996-1999
- Copyright (C) Andrew Tridgell 1992-1999
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _HMAC_MD5_H
-#define _HMAC_MD5_H
-
-#include "../lib/crypto/md5.h"
-
-typedef struct
-{
- MD5_CTX ctx;
- uint8_t k_ipad[65];
- uint8_t k_opad[65];
-
-} HMACMD5Context;
-
-void hmac_md5_init_limK_to_64(const uint8_t *key, int key_len,
- HMACMD5Context *ctx);
-void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context *ctx);
-void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx);
-void hmac_md5(const uint8_t key[16], const uint8_t *data, int data_len, uint8_t *digest);
-void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Context *ctx);
-
-#endif /* _HMAC_MD5_H */
diff --git a/lib/crypto/hmacmd5test.c b/lib/crypto/hmacmd5test.c
deleted file mode 100644
index 0e749dcaf22..00000000000
--- a/lib/crypto/hmacmd5test.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- HMAC MD5 tests
- Copyright (C) Stefan Metzmacher 2006
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-#include "replace.h"
-#include "../lib/util/samba_util.h"
-#include "lib/crypto/hmacmd5.h"
-
-struct torture_context;
-bool torture_local_crypto_hmacmd5(struct torture_context *torture);
-
-static DATA_BLOB data_blob_repeat_byte(uint8_t byte, size_t length)
-{
- DATA_BLOB b = data_blob(NULL, length);
- memset(b.data, byte, length);
- return b;
-}
-
-/*
- This uses the test values from rfc 2104, 2202
-*/
-bool torture_local_crypto_hmacmd5(struct torture_context *torture)
-{
- bool ret = true;
- uint32_t i;
- struct {
- DATA_BLOB key;
- DATA_BLOB data;
- DATA_BLOB md5;
- } testarray[8];
-
- TALLOC_CTX *tctx = talloc_new(torture);
- if (!tctx) { return false; };
-
- testarray[0].key = data_blob_repeat_byte(0x0b, 16);
- testarray[0].data = data_blob_string_const("Hi There");
- testarray[0].md5 = strhex_to_data_blob(tctx, "9294727a3638bb1c13f48ef8158bfc9d");
-
- testarray[1].key = data_blob_string_const("Jefe");
- testarray[1].data = data_blob_string_const("what do ya want for nothing?");
- testarray[1].md5 = strhex_to_data_blob(tctx, "750c783e6ab0b503eaa86e310a5db738");
-
- testarray[2].key = data_blob_repeat_byte(0xaa, 16);
- testarray[2].data = data_blob_repeat_byte(0xdd, 50);
- testarray[2].md5 = strhex_to_data_blob(tctx, "56be34521d144c88dbb8c733f0e8b3f6");
-
- testarray[3].key = strhex_to_data_blob(tctx, "0102030405060708090a0b0c0d0e0f10111213141516171819");
- testarray[3].data = data_blob_repeat_byte(0xcd, 50);
- testarray[3].md5 = strhex_to_data_blob(tctx, "697eaf0aca3a3aea3a75164746ffaa79");
-
- testarray[4].key = data_blob_repeat_byte(0x0c, 16);
- testarray[4].data = data_blob_string_const("Test With Truncation");
- testarray[4].md5 = strhex_to_data_blob(tctx, "56461ef2342edc00f9bab995690efd4c");
-
- testarray[5].key = data_blob_repeat_byte(0xaa, 80);
- testarray[5].data = data_blob_string_const("Test Using Larger Than Block-Size Key - Hash Key First");
- testarray[5].md5 = strhex_to_data_blob(tctx, "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
-
- testarray[6].key = data_blob_repeat_byte(0xaa, 80);
- testarray[6].data = data_blob_string_const("Test Using Larger Than Block-Size Key "
- "and Larger Than One Block-Size Data");
- testarray[6].md5 = strhex_to_data_blob(tctx, "6f630fad67cda0ee1fb1f562db3aa53e");
-
- testarray[7].key = data_blob(NULL, 0);
-
- for (i=0; testarray[i].key.data; i++) {
- HMACMD5Context ctx;
- uint8_t md5[16];
- int e;
-
- hmac_md5_init_rfc2104(testarray[i].key.data, testarray[i].key.length, &ctx);
- hmac_md5_update(testarray[i].data.data, testarray[i].data.length, &ctx);
- hmac_md5_final(md5, &ctx);
-
- e = memcmp(testarray[i].md5.data,
- md5,
- MIN(testarray[i].md5.length, sizeof(md5)));
- if (e != 0) {
- printf("hmacmd5 test[%u]: failed\n", i);
- dump_data(0, testarray[i].key.data, testarray[i].key.length);
- dump_data(0, testarray[i].data.data, testarray[i].data.length);
- dump_data(0, testarray[i].md5.data, testarray[i].md5.length);
- dump_data(0, md5, sizeof(md5));
- ret = false;
- }
- }
- talloc_free(tctx);
- return ret;
-}
diff --git a/lib/crypto/md5.c b/lib/crypto/md5.c
deleted file mode 100644
index 352f80f5d11..00000000000
--- a/lib/crypto/md5.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest. This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-/* This code slightly modified to fit into Samba by
- abartlet@samba.org Jun 2001 */
-
-#include "replace.h"
-
-#include "md5.h"
-
-
-static void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
-
-/*
- * Note: this code is harmless on little-endian machines.
- */
-static void byteReverse(uint8_t *buf, unsigned int longs)
-{
- uint32_t t;
- do {
- t = (uint32_t) ((unsigned int) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned int) buf[1] << 8 | buf[0]);
- *(uint32_t *) buf = t;
- buf += 4;
- } while (--longs);
-}
-
-/*
- * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-_PUBLIC_ void MD5Init(MD5_CTX *ctx)
-{
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
-
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-_PUBLIC_ void MD5Update(MD5_CTX *ctx, const uint8_t *buf, size_t len)
-{
- register uint32_t t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- uint8_t *p = (uint8_t *) ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memmove(p, buf, len);
- return;
- }
- memmove(p, buf, t);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memmove(ctx->in, buf, 64);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memmove(ctx->in, buf, 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], MD5_CTX *ctx)
-{
- unsigned int count;
- uint8_t *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first char of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset(p, 0, count);
- byteReverse(ctx->in, 16);
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-
- /* Now fill the next block with 56 bytes */
- memset(ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset(p, 0, count - 8);
- }
- byteReverse(ctx->in, 14);
-
- /* Append length in bits and transform.
- * Use memcpy to avoid strict-aliasing problems.
- * This way it can be optimized.
- */
- memcpy(&ctx->in[14 * sizeof(uint32_t)], &ctx->bits[0], sizeof(uint32_t));
- memcpy(&ctx->in[15 * sizeof(uint32_t)], &ctx->bits[1], sizeof(uint32_t));
-
- MD5Transform(ctx->buf, (uint32_t *) ctx->in);
- byteReverse((uint8_t *) ctx->buf, 4);
- memmove(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
-}
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
- ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data. MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-static void MD5Transform(uint32_t buf[4], uint32_t const in[16])
-{
- register uint32_t a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
diff --git a/lib/crypto/md5.h b/lib/crypto/md5.h
deleted file mode 100644
index ec6128e86ca..00000000000
--- a/lib/crypto/md5.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef MD5_H
-#define MD5_H
-
-#ifndef HEADER_MD5_H
-/* Try to avoid clashes with OpenSSL */
-#define HEADER_MD5_H
-#endif
-
-#if defined(HAVE_BSD_MD5_H)
-/* Try to avoid clashes with BSD MD5 implementation (on linux) */
-#include <bsd/md5.h>
-
-#elif defined(HAVE_SYS_MD5_H)
-/* Try to avoid clashes with BSD MD5 implementation (on BSD) */
-#include <sys/md5.h>
-
-/* Try to use CommonCrypto on Mac as otherwise we can get MD5Final twice */
-#elif defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)
-#include <CommonCrypto/CommonDigest.h>
-
-#define MD5_CTX CC_MD5_CTX
-#define MD5Init(c) CC_MD5_Init(c)
-#define MD5Update(c,d,l) CC_MD5_Update(c,d,l)
-#define MD5Final(m, c) CC_MD5_Final((unsigned char *)m,c)
-#define MD5Context CC_MD5state_st
-
-#else
-typedef struct MD5Context {
- uint32_t buf[4];
- uint32_t bits[2];
- uint8_t in[64];
-} MD5_CTX;
-
-#define MD5_DIGEST_LENGTH 16
-
-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_*MD5_H */
-
-#endif /* !MD5_H */
diff --git a/lib/crypto/md5test.c b/lib/crypto/md5test.c
deleted file mode 100644
index 01e5cc0bfcd..00000000000
--- a/lib/crypto/md5test.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- MD5 tests
- Copyright (C) Stefan Metzmacher
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "replace.h"
-#include "../lib/util/samba_util.h"
-#include "lib/crypto/md5.h"
-
-struct torture_context;
-
-bool torture_local_crypto_md5(struct torture_context *torture);
-
-/*
- This uses the test values from rfc1321
-*/
-bool torture_local_crypto_md5(struct torture_context *torture)
-{
- bool ret = true;
- uint32_t i;
- struct {
- const char *data;
- const char *md5;
- } testarray[] = {
- {
- .data = "",
- .md5 = "d41d8cd98f00b204e9800998ecf8427e"
- },{
- .data = "a",
- .md5 = "0cc175b9c0f1b6a831c399e269772661"
- },{
- .data = "abc",
- .md5 = "900150983cd24fb0d6963f7d28e17f72"
- },{
- .data = "message digest",
- .md5 = "f96b697d7cb7938d525a2f31aaf161d0"
- },{
- .data = "abcdefghijklmnopqrstuvwxyz",
- .md5 = "c3fcd3d76192e4007dfb496cca67e13b"
- },{
- .data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789",
- .md5 = "d174ab98d277d9f5a5611c2c9f419d9f"
- },{
- .data = "123456789012345678901234567890"
- "123456789012345678901234567890"
- "12345678901234567890",
- .md5 = "57edf4a22be3c955ac49da2e2107b67a"
- }
- };
-
- for (i=0; i < ARRAY_SIZE(testarray); i++) {
- MD5_CTX ctx;
- uint8_t md5[16];
- int e;
-
- DATA_BLOB data;
- DATA_BLOB md5blob;
-
- data = data_blob_string_const(testarray[i].data);
- md5blob = strhex_to_data_blob(NULL, testarray[i].md5);
-
- MD5Init(&ctx);
- MD5Update(&ctx, data.data, data.length);
- MD5Final(md5, &ctx);
-
- e = memcmp(md5blob.data,
- md5,
- MIN(md5blob.length, sizeof(md5)));
- if (e != 0) {
- printf("md5 test[%u]: failed\n", i);
- dump_data(0, data.data, data.length);
- dump_data(0, md5blob.data, md5blob.length);
- dump_data(0, md5, sizeof(md5));
- ret = false;
- }
- talloc_free(md5blob.data);
- }
-
- return ret;
-}
diff --git a/lib/crypto/wscript_build b/lib/crypto/wscript_build
index cddd79d66af..01b70f14f77 100644
--- a/lib/crypto/wscript_build
+++ b/lib/crypto/wscript_build
@@ -1,28 +1,19 @@
#!/usr/bin/env python
-extra_source = ''
extra_deps = ''
-if bld.CONFIG_SET('HAVE_BSD_MD5_H'):
- extra_deps += ' bsd'
-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_SYS_MD5_H') and not bld.CONFIG_SET('HAVE_COMMONCRYPTO_COMMONDIGEST_H'):
- extra_source += ' md5.c'
if bld.CONFIG_SET("HAVE_AESNI_INTEL"):
extra_deps += ' aesni-intel'
bld.SAMBA_SUBSYSTEM('LIBCRYPTO',
- source='''hmacmd5.c md4.c arcfour.c
+ source='''md4.c arcfour.c
aes.c rijndael-alg-fst.c aes_cmac_128.c aes_ccm_128.c aes_gcm_128.c
- ''' + extra_source,
+ ''',
deps='talloc' + extra_deps
)
bld.SAMBA_SUBSYSTEM('TORTURE_LIBCRYPTO',
- source='''md4test.c md5test.c hmacmd5test.c
+ source='''md4test.c
aes_cmac_128_test.c aes_ccm_128_test.c aes_gcm_128_test.c
''',
autoproto='test_proto.h',
diff --git a/lib/crypto/wscript_configure b/lib/crypto/wscript_configure
index 312fd3fdad9..328ad1d2a56 100644
--- a/lib/crypto/wscript_configure
+++ b/lib/crypto/wscript_configure
@@ -2,15 +2,6 @@
from waflib import Options
from waflib import Errors, Logs
-if not conf.CHECK_FUNCS_IN('MD5Init', 'bsd', headers='bsd/md5.h',
- checklibc=True):
- conf.CHECK_FUNCS_IN('MD5Init', 'md5', headers='sys/md5.h',
- checklibc=True)
- conf.CHECK_FUNCS_IN('MD5Init', 'md', headers='sys/md5.h',
- checklibc=True)
-conf.CHECK_FUNCS_IN('CC_MD5_Init', '', headers='CommonCrypto/CommonDigest.h',
- checklibc=True)
-
if conf.CHECK_FUNCS('SHA1_Update'):
conf.DEFINE('SHA1_RENAME_NEEDED', 1)