md4.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
*/
/*
**********************************************************************
** 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 **
**********************************************************************
*/
#include <k5-int.h>
#include <rsa-md4.h>
/* forward declaration */
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 */
/* 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
{
/* Load magic initialization constants.
*/
}
void
const unsigned char *inBuf;
unsigned int inLen;
{
int mdi;
unsigned int i, ii;
/* compute number of bytes mod 64 */
/* update number of bits */
mdContext->i[1]++;
while (inLen--) {
/* add new character to buffer, increment mdi */
/* transform if necessary */
if (mdi == 0x40) {
mdi = 0;
}
}
}
void
{
int mdi;
unsigned int i, ii;
unsigned int padLen;
/* save number of bits */
/* compute number of bytes mod 64 */
/* pad out to 56 mod 64 */
/* append length in bits and transform */
/* store buffer in digest */
}
}
/* Basic MD4 step. Transform buf based on in.
*/
{
/* Round 1 */
/* Round 2 */
/* Round 3 */
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
/*
**********************************************************************
** End of md4.c **
******************************* (cut) ********************************
*/