summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-24 15:44:34 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-24 15:44:34 +0200
commit2413a7200623855b93946d44bcdb949e2dc170a0 (patch)
tree064f1cef83edb2cb3f2b7b3487cdf93b36fad82b
parent5709ded3ef75c48f807273eaa36bb0522e7f7b46 (diff)
downloadsamba-2413a7200623855b93946d44bcdb949e2dc170a0.tar.gz
samba-2413a7200623855b93946d44bcdb949e2dc170a0.tar.bz2
samba-2413a7200623855b93946d44bcdb949e2dc170a0.zip
Use shared copy of hmac5 implementation.
-rw-r--r--lib/crypto/hmacmd5.c2
-rw-r--r--lib/crypto/hmacmd5.h1
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/hmacmd5.h29
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/proto.h10
-rw-r--r--source3/lib/hmacmd5.c135
7 files changed, 4 insertions, 177 deletions
diff --git a/lib/crypto/hmacmd5.c b/lib/crypto/hmacmd5.c
index 3a9ec38a27..0c8d1ab598 100644
--- a/lib/crypto/hmacmd5.c
+++ b/lib/crypto/hmacmd5.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-#include "lib/crypto/crypto.h"
+#include "../lib/crypto/hmacmd5.h"
/***********************************************************************
the rfc 2104 version of hmac_md5 initialisation.
diff --git a/lib/crypto/hmacmd5.h b/lib/crypto/hmacmd5.h
index 5769737fcd..d649906bb4 100644
--- a/lib/crypto/hmacmd5.h
+++ b/lib/crypto/hmacmd5.h
@@ -19,6 +19,7 @@
*/
#ifndef _HMAC_MD5_H
+#define _HMAC_MD5_H
typedef struct
{
diff --git a/source3/Makefile.in b/source3/Makefile.in
index eb9f206298..20adeeb222 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -328,7 +328,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) \
lib/substitute.o lib/fsusage.o lib/dbwrap_util.o \
lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o libsmb/smb_signing.o \
- ../lib/crypto/md5.o lib/hmacmd5.o lib/arc4.o lib/iconv.o \
+ ../lib/crypto/md5.o ../lib/crypto/hmacmd5.o lib/arc4.o lib/iconv.o \
lib/pam_errors.o intl/lang_tdb.o lib/conn_tdb.o \
lib/adt_tree.o lib/gencache.o \
lib/module.o lib/events.o lib/ldap_escape.o @CHARSET_STATIC@ \
diff --git a/source3/include/hmacmd5.h b/source3/include/hmacmd5.h
deleted file mode 100644
index ae588fb889..0000000000
--- a/source3/include/hmacmd5.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Interface header: Scheduler service
- 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
-
-typedef struct {
- struct MD5Context ctx;
- unsigned char k_ipad[65];
- unsigned char k_opad[65];
-} HMACMD5Context;
-
-#endif /* _HMAC_MD5_H */
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 5543475488..de50eab8c5 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -687,7 +687,7 @@ typedef char fstring[FSTRING_LEN];
#include "msdfs.h"
#include "rap.h"
#include "../lib/crypto/md5.h"
-#include "hmacmd5.h"
+#include "../lib/crypto/hmacmd5.h"
#include "ntlmssp.h"
#include "auth.h"
#include "ntdomain.h"
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d572a0c254..a5f43aad4c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -596,16 +596,6 @@ void set_need_random_reseed(void);
void generate_random_buffer( unsigned char *out, int len);
char *generate_random_str(size_t len);
-/* The following definitions come from lib/hmacmd5.c */
-
-void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context *ctx);
-void hmac_md5_init_limK_to_64(const unsigned char* key, int key_len,
- HMACMD5Context *ctx);
-void hmac_md5_update(const unsigned char *text, int text_len, HMACMD5Context *ctx);
-void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx);
-void hmac_md5( unsigned char key[16], const unsigned char *data, int data_len,
- unsigned char *digest);
-
/* The following definitions come from lib/iconv.c */
NTSTATUS smb_register_charset(struct charset_functions *funcs) ;
diff --git a/source3/lib/hmacmd5.c b/source3/lib/hmacmd5.c
deleted file mode 100644
index 86db3aa236..0000000000
--- a/source3/lib/hmacmd5.c
+++ /dev/null
@@ -1,135 +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 "includes.h"
-
-/***********************************************************************
- the rfc 2104 version of hmac_md5 initialisation.
-***********************************************************************/
-
-void hmac_md5_init_rfc2104(const unsigned char *key, int key_len, HMACMD5Context *ctx)
-{
- int i;
- unsigned char tk[16];
-
- /* if key is longer than 64 bytes reset it to key=MD5(key) */
- if (key_len > 64) {
- struct MD5Context 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.
-***********************************************************************/
-
-void hmac_md5_init_limK_to_64(const unsigned char* key, int key_len,
- HMACMD5Context *ctx)
-{
- int i;
-
- /* if key is longer than 64 bytes truncate it */
- if (key_len > 64) {
- key_len = 64;
- }
-
- /* 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);
-}
-
-/***********************************************************************
- update hmac_md5 "inner" buffer
-***********************************************************************/
-
-void hmac_md5_update(const unsigned char *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.
-***********************************************************************/
-void hmac_md5_final(unsigned char *digest, HMACMD5Context *ctx)
-
-{
- struct MD5Context 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.
-************************************************************/
-
-void hmac_md5( unsigned char key[16], const unsigned char *data, int data_len,
- unsigned char *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);
-}
-