summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto/md4
diff options
context:
space:
mode:
authorZhanna Tsitkov <tsitkova@mit.edu>2009-08-03 14:19:16 +0000
committerZhanna Tsitkov <tsitkova@mit.edu>2009-08-03 14:19:16 +0000
commit3c40c7f134b4e87baa43b0cacb435b6f96245e2f (patch)
tree2b1014db60c1d3941f17a4d00221e07cc5cece62 /src/lib/crypto/md4
parentab7ffb919b4ee5ee5bc07f987d9163202a632e6a (diff)
Crypto modularity proj: Separate files under crypto directory based on their functionality. Move Kerberos specific files into krb subdir and MIT specific - into builtin subdir. Place all tests into crypto_tests subfolder.
bigredbutton: whitespace git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22477 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto/md4')
-rw-r--r--src/lib/crypto/md4/ISSUES3
-rw-r--r--src/lib/crypto/md4/Makefile.in58
-rw-r--r--src/lib/crypto/md4/deps13
-rw-r--r--src/lib/crypto/md4/md4.c246
-rw-r--r--src/lib/crypto/md4/rsa-md4.h94
5 files changed, 0 insertions, 414 deletions
diff --git a/src/lib/crypto/md4/ISSUES b/src/lib/crypto/md4/ISSUES
deleted file mode 100644
index 1103bd87b..000000000
--- a/src/lib/crypto/md4/ISSUES
+++ /dev/null
@@ -1,3 +0,0 @@
-Issues to be addressed for src/lib/crypto/md4: -*- text -*-
-
-Assumes int is >= 32 bits.
diff --git a/src/lib/crypto/md4/Makefile.in b/src/lib/crypto/md4/Makefile.in
deleted file mode 100644
index f7d65b818..000000000
--- a/src/lib/crypto/md4/Makefile.in
+++ /dev/null
@@ -1,58 +0,0 @@
-thisconfigdir=../../..
-myfulldir=lib/crypto/md4
-mydir=lib/crypto/md4
-BUILDTOP=$(REL)..$(S)..$(S)..
-LOCALINCLUDES = -I$(srcdir)
-DEFS=
-
-##DOS##BUILDTOP = ..\..\..
-##DOS##PREFIXDIR=md4
-##DOS##OBJFILE=..\$(OUTPRE)md4.lst
-
-PROG_LIBPATH=-L$(TOPLIBD)
-PROG_RPATH=$(KRB5_LIBDIR)
-
-RUN_SETUP = @KRB5_RUN_ENV@ KRB5_CONFIG=$(SRCTOP)/config-files/krb5.conf
-
-STLIBOBJS= md4.o
-
-OBJS= $(OUTPRE)md4.$(OBJEXT)
-
-SRCS= $(srcdir)/md4.c
-
-##DOS##LIBOBJS = $(OBJS)
-
-all-unix:: all-libobjs
-
-includes:: depend
-
-depend:: $(SRCS)
-
-t_mddriver.c: $(srcdir)/../md5/t_mddriver.c
- $(CP) $(srcdir)/../md5/t_mddriver.c t_mddriver.c
-
-t_mddriver.o: t_mddriver.c
- $(CC) -DMD=4 $(ALL_CFLAGS) -c t_mddriver.c
-
-t_mddriver: t_mddriver.o md4.o $(SUPPORT_DEPLIB)
- $(CC_LINK) -o t_mddriver t_mddriver.o md4.o $(SUPPORT_LIB)
-
-$(OUTPRE)t_mddriver.obj: t_mddriver.c
- $(CC) -DMD=4 $(ALL_CFLAGS) -Fo$@ -c $**
-
-$(OUTPRE)t_mddriver.exe: $(OUTPRE)t_mddriver.obj $(OUTPRE)md4.obj
- link -out:$@ $**
-
-check-unix:: t_mddriver
- $(RUN_SETUP) $(VALGRIND) $(C)t_mddriver -x
-
-check-windows:: $(OUTPRE)t_mddriver.exe
- $(OUTPRE)$(C)t_mddriver.exe -x
-
-clean::
- $(RM) $(OUTPRE)t_mddriver$(EXEEXT) $(OUTPRE)t_mddriver.$(OBJEXT) t_mddriver.c
-
-clean-unix:: clean-libobjs
-
-@libobj_frag@
-
diff --git a/src/lib/crypto/md4/deps b/src/lib/crypto/md4/deps
deleted file mode 100644
index 775a8b446..000000000
--- a/src/lib/crypto/md4/deps
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Generated makefile dependencies follow.
-#
-md4.so md4.po $(OUTPRE)md4.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
- $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
- $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(SRCTOP)/include/k5-buf.h \
- $(SRCTOP)/include/k5-err.h $(SRCTOP)/include/k5-gmt_mktime.h \
- $(SRCTOP)/include/k5-int-pkinit.h $(SRCTOP)/include/k5-int.h \
- $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-plugin.h \
- $(SRCTOP)/include/k5-thread.h $(SRCTOP)/include/krb5.h \
- $(SRCTOP)/include/krb5/locate_plugin.h $(SRCTOP)/include/krb5/preauth_plugin.h \
- $(SRCTOP)/include/port-sockets.h $(SRCTOP)/include/socket-utils.h \
- md4.c rsa-md4.h
diff --git a/src/lib/crypto/md4/md4.c b/src/lib/crypto/md4/md4.c
deleted file mode 100644
index 7922c71ed..000000000
--- a/src/lib/crypto/md4/md4.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * lib/crypto/md4/md4.c
- */
-
-/*
- **********************************************************************
- ** md4.c **
- ** RSA Data Security, Inc. MD4 Message Digest Algorithm **
- ** Created: 2/17/90 RLR **
- ** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- ** **
- ** License to copy and use this software is granted provided that **
- ** it is identified as the "RSA Data Security, Inc. MD4 Message **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function. **
- ** **
- ** License is also granted to make and use derivative works **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD4 Message Digest Algorithm" in all **
- ** material mentioning or referencing the derived work. **
- ** **
- ** RSA Data Security, Inc. makes no representations concerning **
- ** either the merchantability of this software or the suitability **
- ** of this software for any particular purpose. It is provided "as **
- ** is" without express or implied warranty of any kind. **
- ** **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software. **
- **********************************************************************
- */
-
-#include "k5-int.h"
-#include "rsa-md4.h"
-
-/* forward declaration */
-static void Transform (krb5_ui_4 *, krb5_ui_4 *);
-
-static const unsigned char PADDING[64] = {
- 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-};
-
-/* F, G and H are basic MD4 functions: selection, majority, parity */
-#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
-#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))
-#define H(x, y, z) ((x) ^ (y) ^ (z))
-
-/* ROTATE_LEFT rotates x left n bits */
-#define ROTATE_LEFT(x, n) ((((x) << (n)) & 0xffffffff) | ((x) >> (32-(n))))
-
-/* FF, GG and HH are MD4 transformations for rounds 1, 2 and 3 */
-/* Rotation is separate from addition to prevent recomputation */
-#define FF(a, b, c, d, x, s) \
- {(a) += F ((b), (c), (d)) + (x); \
- (a) &= 0xffffffff; \
- (a) = ROTATE_LEFT ((a), (s));}
-#define GG(a, b, c, d, x, s) \
- {(a) += G ((b), (c), (d)) + (x) + 013240474631UL; \
- (a) &= 0xffffffff; \
- (a) = ROTATE_LEFT ((a), (s));}
-#define HH(a, b, c, d, x, s) \
- {(a) += H ((b), (c), (d)) + (x) + 015666365641UL; \
- (a) &= 0xffffffff; \
- (a) = ROTATE_LEFT ((a), (s));}
-
-void
-krb5_MD4Init (krb5_MD4_CTX *mdContext)
-{
- mdContext->i[0] = mdContext->i[1] = (krb5_ui_4)0;
-
- /* Load magic initialization constants.
- */
- mdContext->buf[0] = 0x67452301UL;
- mdContext->buf[1] = 0xefcdab89UL;
- mdContext->buf[2] = 0x98badcfeUL;
- mdContext->buf[3] = 0x10325476UL;
-}
-
-void
-krb5_MD4Update (krb5_MD4_CTX *mdContext, const unsigned char *inBuf, unsigned int inLen)
-{
- krb5_ui_4 in[16];
- int mdi;
- unsigned int i, ii;
-
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
- /* update number of bits */
- if ((mdContext->i[0] + ((krb5_ui_4)inLen << 3)) < mdContext->i[0])
- mdContext->i[1]++;
- mdContext->i[0] += ((krb5_ui_4)inLen << 3);
- mdContext->i[1] += ((krb5_ui_4)inLen >> 29);
-
- while (inLen--) {
- /* add new character to buffer, increment mdi */
- mdContext->in[mdi++] = *inBuf++;
-
- /* transform if necessary */
- if (mdi == 0x40) {
- for (i = 0, ii = 0; i < 16; i++, ii += 4) {
- in[i] = load_32_le(mdContext->in+ii);
- }
- Transform (mdContext->buf, in);
- mdi = 0;
- }
- }
-}
-
-void
-krb5_MD4Final (krb5_MD4_CTX *mdContext)
-{
- krb5_ui_4 in[16];
- int mdi;
- unsigned int i, ii;
- unsigned int padLen;
-
- /* save number of bits */
- in[14] = mdContext->i[0];
- in[15] = mdContext->i[1];
-
- /* compute number of bytes mod 64 */
- mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
-
- /* pad out to 56 mod 64 */
- padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
- krb5_MD4Update (mdContext, PADDING, padLen);
-
- /* append length in bits and transform */
- for (i = 0, ii = 0; i < 14; i++, ii += 4)
- in[i] = load_32_le(mdContext->in+ii);
- Transform (mdContext->buf, in);
-
-
- /* store buffer in digest */
- for (i = 0, ii = 0; i < 4; i++, ii += 4) {
- store_32_le(mdContext->buf[i], mdContext->digest+ii);
- }
-}
-
-/* Basic MD4 step. Transform buf based on in.
- */
-static void Transform (krb5_ui_4 *buf, krb5_ui_4 *in)
-{
- register krb5_ui_4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
-
-#if defined(CONFIG_SMALL) && !defined(CONFIG_SMALL_NO_CRYPTO)
- int i;
-#define ROTATE { krb5_ui_4 temp; temp = d, d = c, c = b, b = a, a = temp; }
- for (i = 0; i < 16; i++) {
- static const unsigned char round1consts[] = { 3, 7, 11, 19, };
- FF (a, b, c, d, in[i], round1consts[i%4]); ROTATE;
- }
- for (i = 0; i < 16; i++) {
- static const unsigned char round2indices[] = {
- 0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15
- };
- static const unsigned char round2consts[] = { 3, 5, 9, 13 };
- GG (a, b, c, d, in[round2indices[i]], round2consts[i%4]); ROTATE;
- }
- for (i = 0; i < 16; i++) {
- static const unsigned char round3indices[] = {
- 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
- };
- static const unsigned char round3consts[] = { 3, 9, 11, 15 };
- HH (a, b, c, d, in[round3indices[i]], round3consts[i%4]); ROTATE;
- }
-#else
- /* Round 1 */
- FF (a, b, c, d, in[ 0], 3);
- FF (d, a, b, c, in[ 1], 7);
- FF (c, d, a, b, in[ 2], 11);
- FF (b, c, d, a, in[ 3], 19);
- FF (a, b, c, d, in[ 4], 3);
- FF (d, a, b, c, in[ 5], 7);
- FF (c, d, a, b, in[ 6], 11);
- FF (b, c, d, a, in[ 7], 19);
- FF (a, b, c, d, in[ 8], 3);
- FF (d, a, b, c, in[ 9], 7);
- FF (c, d, a, b, in[10], 11);
- FF (b, c, d, a, in[11], 19);
- FF (a, b, c, d, in[12], 3);
- FF (d, a, b, c, in[13], 7);
- FF (c, d, a, b, in[14], 11);
- FF (b, c, d, a, in[15], 19);
-
- /* Round 2 */
- GG (a, b, c, d, in[ 0], 3);
- GG (d, a, b, c, in[ 4], 5);
- GG (c, d, a, b, in[ 8], 9);
- GG (b, c, d, a, in[12], 13);
- GG (a, b, c, d, in[ 1], 3);
- GG (d, a, b, c, in[ 5], 5);
- GG (c, d, a, b, in[ 9], 9);
- GG (b, c, d, a, in[13], 13);
- GG (a, b, c, d, in[ 2], 3);
- GG (d, a, b, c, in[ 6], 5);
- GG (c, d, a, b, in[10], 9);
- GG (b, c, d, a, in[14], 13);
- GG (a, b, c, d, in[ 3], 3);
- GG (d, a, b, c, in[ 7], 5);
- GG (c, d, a, b, in[11], 9);
- GG (b, c, d, a, in[15], 13);
-
- /* Round 3 */
- HH (a, b, c, d, in[ 0], 3);
- HH (d, a, b, c, in[ 8], 9);
- HH (c, d, a, b, in[ 4], 11);
- HH (b, c, d, a, in[12], 15);
- HH (a, b, c, d, in[ 2], 3);
- HH (d, a, b, c, in[10], 9);
- HH (c, d, a, b, in[ 6], 11);
- HH (b, c, d, a, in[14], 15);
- HH (a, b, c, d, in[ 1], 3);
- HH (d, a, b, c, in[ 9], 9);
- HH (c, d, a, b, in[ 5], 11);
- HH (b, c, d, a, in[13], 15);
- HH (a, b, c, d, in[ 3], 3);
- HH (d, a, b, c, in[11], 9);
- HH (c, d, a, b, in[ 7], 11);
- HH (b, c, d, a, in[15], 15);
-#endif
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
-}
-
-/*
- **********************************************************************
- ** End of md4.c **
- ******************************* (cut) ********************************
- */
diff --git a/src/lib/crypto/md4/rsa-md4.h b/src/lib/crypto/md4/rsa-md4.h
deleted file mode 100644
index d4e6f6b79..000000000
--- a/src/lib/crypto/md4/rsa-md4.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * lib/crypto/md4/rsa-md4.h
- *
- * Copyright 1991 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
- *
- * Export of this software from the United States of America may
- * require a specific license from the United States Government.
- * It is the responsibility of any person or organization contemplating
- * export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
- * distribute this software and its documentation for any purpose and
- * without fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission. Furthermore if you modify this software you must label
- * your software as modified software and not distribute it in such a
- * fashion that it might be confused with the original M.I.T. software.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose. It is provided "as is" without express
- * or implied warranty.
- *
- *
- * RSA MD4 header file, with Kerberos/STDC additions.
- */
-
-#ifndef __KRB5_RSA_MD4_H__
-#define __KRB5_RSA_MD4_H__
-
-#ifdef unicos61
-#include <sys/types.h>
-#endif /* unicos61 */
-
-/* 16 u_char's in the digest */
-#define RSA_MD4_CKSUM_LENGTH 16
-/* des blocksize is 8, so this works nicely... */
-#define OLD_RSA_MD4_DES_CKSUM_LENGTH 16
-#define NEW_RSA_MD4_DES_CKSUM_LENGTH 24
-#define RSA_MD4_DES_CONFOUND_LENGTH 8
-
-/*
- **********************************************************************
- ** md4.h -- Header file for implementation of MD4 **
- ** RSA Data Security, Inc. MD4 Message Digest Algorithm **
- ** Created: 2/17/90 RLR **
- ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
- **********************************************************************
- */
-
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- ** **
- ** License to copy and use this software is granted provided that **
- ** it is identified as the "RSA Data Security, Inc. MD4 Message **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function. **
- ** **
- ** License is also granted to make and use derivative works **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD4 Message Digest Algorithm" in all **
- ** material mentioning or referencing the derived work. **
- ** **
- ** RSA Data Security, Inc. makes no representations concerning **
- ** either the merchantability of this software or the suitability **
- ** of this software for any particular purpose. It is provided "as **
- ** is" without express or implied warranty of any kind. **
- ** **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software. **
- **********************************************************************
- */
-
-/* Data structure for MD4 (Message Digest) computation */
-typedef struct {
- krb5_ui_4 i[2]; /* number of _bits_ handled mod 2^64 */
- krb5_ui_4 buf[4]; /* scratch buffer */
- unsigned char in[64]; /* input buffer */
- unsigned char digest[16]; /* actual digest after MD4Final call */
-} krb5_MD4_CTX;
-
-extern void krb5_MD4Init(krb5_MD4_CTX *);
-extern void krb5_MD4Update(krb5_MD4_CTX *, const unsigned char *, unsigned int);
-extern void krb5_MD4Final(krb5_MD4_CTX *);
-
-/*
- **********************************************************************
- ** End of md4.h **
- ******************************* (cut) ********************************
- */
-#endif /* __KRB5_RSA_MD4_H__ */