/home/dko/projects/mobilec/trunk/src/security/xyssl-0.7/library/md4.c File Reference

#include <string.h>
#include <stdio.h>
#include "xyssl/md4.h"

Go to the source code of this file.

Defines

#define _CRT_SECURE_NO_DEPRECATE   1
#define GET_UINT32_LE(n, b, i)
#define PUT_UINT32_LE(n, b, i)
#define S(x, n)   ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
#define F(x, y, z)   ((x & y) | ((~x) & z))
#define P(a, b, c, d, x, s)   { a += F(b,c,d) + x; a = S(a,s); }
#define F(x, y, z)   ((x & y) | (x & z) | (y & z))
#define P(a, b, c, d, x, s)   { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); }
#define F(x, y, z)   (x ^ y ^ z)
#define P(a, b, c, d, x, s)   { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); }

Functions

void md4_starts (md4_context *ctx)
 MD4 context setup.
static void md4_process (md4_context *ctx, unsigned char data[64])
void md4_update (md4_context *ctx, unsigned char *input, int ilen)
 MD4 process buffer.
void md4_finish (md4_context *ctx, unsigned char *output)
 MD4 final digest.
void md4 (unsigned char *input, int ilen, unsigned char *output)
 Output = MD4( input buffer ).
int md4_file (char *path, unsigned char *output)
 Output = MD4( file contents ).
void md4_hmac_starts (md4_context *ctx, unsigned char *key, int keylen)
 MD4 HMAC context setup.
void md4_hmac_update (md4_context *ctx, unsigned char *input, int ilen)
 MD4 HMAC process buffer.
void md4_hmac_finish (md4_context *ctx, unsigned char *output)
 MD4 HMAC final digest.
void md4_hmac (unsigned char *key, int keylen, unsigned char *input, int ilen, unsigned char *output)
 Output = HMAC-MD4( hmac key, input buffer ).
int md4_self_test (int verbose)
 Checkup routine.

Variables

static const unsigned char md4_padding [64]
static const char _md4_src [] = "_md4_src"


Define Documentation

#define _CRT_SECURE_NO_DEPRECATE   1

Definition at line 28 of file md4.c.

#define F ( x,
y,
 )     (x ^ y ^ z)

#define F ( x,
y,
 )     ((x & y) | (x & z) | (y & z))

#define F ( x,
y,
 )     ((x & y) | ((~x) & z))

Referenced by sha2_process(), and sha4_process().

#define GET_UINT32_LE ( n,
b,
 ) 

Value:

{                                                       \
    (n) = ( (unsigned long) (b)[(i)    ]       )        \
        | ( (unsigned long) (b)[(i) + 1] <<  8 )        \
        | ( (unsigned long) (b)[(i) + 2] << 16 )        \
        | ( (unsigned long) (b)[(i) + 3] << 24 );       \
}

Definition at line 40 of file md4.c.

Referenced by md4_process(), and md5_process().

#define P ( a,
b,
c,
d,
x,
 )     { a += F(b,c,d) + x + 0x6ED9EBA1; a = S(a,s); }

#define P ( a,
b,
c,
d,
x,
 )     { a += F(b,c,d) + x + 0x5A827999; a = S(a,s); }

#define P ( a,
b,
c,
d,
x,
 )     { a += F(b,c,d) + x; a = S(a,s); }

Referenced by main(), md4_process(), md5_process(), sha1_process(), sha2_process(), and sha4_process().

#define PUT_UINT32_LE ( n,
b,
 ) 

Value:

{                                                       \
    (b)[(i)    ] = (unsigned char) ( (n)       );       \
    (b)[(i) + 1] = (unsigned char) ( (n) >>  8 );       \
    (b)[(i) + 2] = (unsigned char) ( (n) >> 16 );       \
    (b)[(i) + 3] = (unsigned char) ( (n) >> 24 );       \
}

Definition at line 50 of file md4.c.

Referenced by md4_finish(), and md5_finish().

#define S ( x,
 )     ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))


Function Documentation

void md4 ( unsigned char *  input,
int  ilen,
unsigned char *  output 
)

Output = MD4( input buffer ).

Parameters:
input buffer holding the data
ilen length of the input data
output MD4 checksum result

Definition at line 259 of file md4.c.

References md4_finish(), md4_starts(), and md4_update().

Referenced by main(), and x509_hash().

int md4_file ( char *  path,
unsigned char *  output 
)

Output = MD4( file contents ).

Parameters:
path input file name
output MD4 checksum result
Returns:
0 if successful, 1 if fopen failed, or 2 if fread failed

Definition at line 274 of file md4.c.

References f, md4_finish(), md4_starts(), and md4_update().

void md4_finish ( md4_context ctx,
unsigned char *  output 
)

MD4 final digest.

Parameters:
ctx MD4 context
output MD4 checksum result

Definition at line 231 of file md4.c.

References md4_padding, md4_update(), PUT_UINT32_LE, md4_context::state, and md4_context::total.

Referenced by md4(), md4_file(), and md4_hmac_finish().

void md4_hmac ( unsigned char *  key,
int  keylen,
unsigned char *  input,
int  ilen,
unsigned char *  output 
)

Output = HMAC-MD4( hmac key, input buffer ).

Parameters:
key HMAC secret key
keylen length of the HMAC key
input buffer holding the data
ilen length of the input data
output HMAC-MD4 result

Definition at line 354 of file md4.c.

References md4_hmac_finish(), md4_hmac_starts(), and md4_hmac_update().

void md4_hmac_finish ( md4_context ctx,
unsigned char *  output 
)

MD4 HMAC final digest.

Parameters:
ctx HMAC context
output MD4 HMAC checksum result

Definition at line 338 of file md4.c.

References md4_finish(), md4_starts(), md4_update(), and md4_context::opad.

Referenced by md4_hmac().

void md4_hmac_starts ( md4_context ctx,
unsigned char *  key,
int  keylen 
)

MD4 HMAC context setup.

Parameters:
ctx HMAC context to be initialized
key HMAC secret key
keylen length of the HMAC key

Definition at line 306 of file md4.c.

References md4_context::ipad, md4_starts(), md4_update(), and md4_context::opad.

Referenced by md4_hmac().

void md4_hmac_update ( md4_context ctx,
unsigned char *  input,
int  ilen 
)

MD4 HMAC process buffer.

Parameters:
ctx HMAC context
input buffer holding the data
ilen length of the input data

Definition at line 329 of file md4.c.

References md4_update().

Referenced by md4_hmac().

static void md4_process ( md4_context ctx,
unsigned char  data[64] 
) [static]

Definition at line 73 of file md4.c.

References GET_UINT32_LE, P, and md4_context::state.

Referenced by md4_update().

int md4_self_test ( int  verbose  ) 

Checkup routine.

Returns:
0 if successful, or 1 if the test failed

Definition at line 435 of file md4.c.

Referenced by main().

void md4_starts ( md4_context ctx  ) 

MD4 context setup.

Parameters:
ctx context to be initialized

Definition at line 62 of file md4.c.

References md4_context::state, and md4_context::total.

Referenced by md4(), md4_file(), md4_hmac_finish(), and md4_hmac_starts().

void md4_update ( md4_context ctx,
unsigned char *  input,
int  ilen 
)

MD4 process buffer.

Parameters:
ctx MD4 context
input buffer holding the data
ilen length of the input data

Definition at line 179 of file md4.c.

References md4_context::buffer, md4_process(), and md4_context::total.

Referenced by md4(), md4_file(), md4_finish(), md4_hmac_finish(), md4_hmac_starts(), and md4_hmac_update().


Variable Documentation

const char _md4_src[] = "_md4_src" [static]

Definition at line 367 of file md4.c.

const unsigned char md4_padding[64] [static]

Initial value:

{
 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}

Definition at line 220 of file md4.c.

Referenced by md4_finish().


Generated on Fri May 16 14:49:56 2008 for Mobile-C by  doxygen 1.5.4