md5.c File Reference

MD5 message-digest algorithm - RSA Data Security, Inc. More...

#include <string.h>
#include "md5.h"

Include dependency graph for md5.c:

Go to the source code of this file.

Defines

#define F(x, y, z)   (((x) & (y)) | ((~x) & (z)))
#define FF(a, b, c, d, x, s, ac)
#define G(x, y, z)   (((x) & (z)) | ((y) & (~z)))
#define GG(a, b, c, d, x, s, ac)
#define H(x, y, z)   ((x) ^ (y) ^ (z))
#define HH(a, b, c, d, x, s, ac)
#define I(x, y, z)   ((y) ^ ((x) | (~z)))
#define II(a, b, c, d, x, s, ac)
#define ROTATE_LEFT(x, n)   (((x) << (n)) | ((x) >> (32-(n))))
#define S11   7
#define S12   12
#define S13   17
#define S14   22
#define S21   5
#define S22   9
#define S23   14
#define S24   20
#define S31   4
#define S32   11
#define S33   16
#define S34   23
#define S41   6
#define S42   10
#define S43   15
#define S44   21

Functions

static void Decode (unsigned int *output, unsigned char *input, unsigned int len)
 Decodes input (unsigned char) into output (unsigned int).
static void Encode (unsigned char *output, unsigned int *input, unsigned int len)
 Encodes input (unsigned int) into output (unsigned char).
void MD5Init (MD5_CTX *context)
 MD5 initialization. Begins an MD5 operation, writing a new context.
static void MD5Transform (unsigned int state[4], unsigned char block[64])
 MD5 basic transformation. Transforms state based on block.
void U_MD5Final (unsigned char digest[16], MD5_CTX *context)
 MD5 finalization.
void U_MD5Update (MD5_CTX *context, unsigned char *input, unsigned int inputLen)
 MD5 block update operation.

Variables

static unsigned char PADDING [64]


Detailed Description

MD5 message-digest algorithm - RSA Data Security, Inc.

Definition in file md5.c.


Define Documentation

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

Definition at line 70 of file md5.c.

#define FF ( a,
b,
c,
d,
x,
s,
ac   ) 

Value:

{ \
   (a) += F ((b), (c), (d)) + (x) + (unsigned int)(ac); \
   (a) = ROTATE_LEFT ((a), (s)); \
   (a) += (b); \
}

Definition at line 84 of file md5.c.

Referenced by MD5Transform().

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

Definition at line 71 of file md5.c.

#define GG ( a,
b,
c,
d,
x,
s,
ac   ) 

Value:

{ \
   (a) += G ((b), (c), (d)) + (x) + (unsigned int)(ac); \
   (a) = ROTATE_LEFT ((a), (s)); \
   (a) += (b); \
}

Definition at line 89 of file md5.c.

Referenced by MD5Transform().

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

Definition at line 72 of file md5.c.

Referenced by new_htable().

#define HH ( a,
b,
c,
d,
x,
s,
ac   ) 

Value:

{ \
   (a) += H ((b), (c), (d)) + (x) + (unsigned int)(ac); \
   (a) = ROTATE_LEFT ((a), (s)); \
   (a) += (b); \
}

Definition at line 94 of file md5.c.

Referenced by MD5Transform().

#define I ( x,
y,
 )     ((y) ^ ((x) | (~z)))

Definition at line 73 of file md5.c.

#define II ( a,
b,
c,
d,
x,
s,
ac   ) 

Value:

{ \
   (a) += I ((b), (c), (d)) + (x) + (unsigned int)(ac); \
   (a) = ROTATE_LEFT ((a), (s)); \
   (a) += (b); \
}

Definition at line 99 of file md5.c.

Referenced by MD5Transform().

#define ROTATE_LEFT ( x,
 )     (((x) << (n)) | ((x) >> (32-(n))))

ROTATE_LEFT rotates x left n bits

Definition at line 77 of file md5.c.

#define S11   7

Definition at line 39 of file md5.c.

Referenced by MD5Transform().

#define S12   12

Definition at line 40 of file md5.c.

Referenced by MD5Transform().

#define S13   17

Definition at line 41 of file md5.c.

Referenced by MD5Transform().

#define S14   22

Definition at line 42 of file md5.c.

Referenced by MD5Transform().

#define S21   5

Definition at line 43 of file md5.c.

Referenced by MD5Transform().

#define S22   9

Definition at line 44 of file md5.c.

Referenced by MD5Transform().

#define S23   14

Definition at line 45 of file md5.c.

Referenced by MD5Transform().

#define S24   20

Definition at line 46 of file md5.c.

Referenced by MD5Transform().

#define S31   4

Definition at line 47 of file md5.c.

Referenced by MD5Transform().

#define S32   11

Definition at line 48 of file md5.c.

Referenced by MD5Transform().

#define S33   16

Definition at line 49 of file md5.c.

Referenced by MD5Transform().

#define S34   23

Definition at line 50 of file md5.c.

Referenced by MD5Transform().

#define S41   6

Definition at line 51 of file md5.c.

Referenced by MD5Transform().

#define S42   10

Definition at line 52 of file md5.c.

Referenced by MD5Transform().

#define S43   15

Definition at line 53 of file md5.c.

Referenced by MD5Transform().

#define S44   21

Definition at line 54 of file md5.c.

Referenced by MD5Transform().


Function Documentation

static void Decode ( unsigned int *  output,
unsigned char *  input,
unsigned int  len 
) [static]

Decodes input (unsigned char) into output (unsigned int).

Note:
Assumes len is a multiple of 4.
Parameters:
output output character
input input
len length

Definition at line 315 of file md5.c.

Referenced by MD5Transform().

static void Encode ( unsigned char *  output,
unsigned int *  input,
unsigned int  len 
) [static]

Encodes input (unsigned int) into output (unsigned char).

Note:
Assumes len is a multiple of 4.
Parameters:
output output character
input input
len length

Definition at line 295 of file md5.c.

Referenced by U_MD5Final().

void MD5Init ( MD5_CTX context  ) 

MD5 initialization. Begins an MD5 operation, writing a new context.

Parameters:
context MD5 context

Definition at line 110 of file md5.c.

References MD5_CTX::count, and MD5_CTX::state.

Referenced by calc_HA1(), calc_nonce(), calc_response(), compute_md5(), hash(), MD5File(), MD5StringArray(), uac_calc_HA1(), uac_calc_HA2(), and uac_calc_response().

static void MD5Transform ( unsigned int  state[4],
unsigned char  block[64] 
) [static]

MD5 basic transformation. Transforms state based on block.

Parameters:
state transformed state
block input block

Definition at line 200 of file md5.c.

References Decode(), FF, GG, HH, II, S11, S12, S13, S14, S21, S22, S23, S24, S31, S32, S33, S34, S41, S42, S43, and S44.

Referenced by U_MD5Update().

void U_MD5Final ( unsigned char  digest[16],
MD5_CTX context 
)

MD5 finalization.

MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context.

Parameters:
digest message digest
context MD5 context

Definition at line 171 of file md5.c.

References MD5_CTX::count, Encode(), PADDING, MD5_CTX::state, and U_MD5Update().

Referenced by calc_nonce(), compute_md5(), MD5File(), MD5Final(), and MD5StringArray().

void U_MD5Update ( MD5_CTX context,
unsigned char *  input,
unsigned int  inputLen 
)

MD5 block update operation.

MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context.

Parameters:
context MD5 context
input input block
inputLen length of input block

Definition at line 131 of file md5.c.

References MD5_CTX::buffer, MD5_CTX::count, MD5Transform(), and MD5_CTX::state.

Referenced by MD5File(), MD5Update(), and U_MD5Final().


Variable Documentation

unsigned char 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 62 of file md5.c.

Referenced by U_MD5Final().


Generated on Wed May 23 18:00:41 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6