su_md5.c File Reference


Detailed Description

MD5 Implementation.

To compute the message digest of a chunk of bytes, declare an su_md5_t context structure, pass it to su_md5_init(), call su_md5_update() as needed on buffers full of bytes, and then call su_md5_digest(), which will fill a supplied 16-byte array with the current digest.

Note:
This code was modified in 1997 by Jim Kingdon of Cyclic Software to not require an integer type which is exactly 32 bits. This work draws on the changes for the same purpose by Tatu Ylonen <ylo@cs.hut.fi> as part of SSH, but since I didn't actually use that code, there is no copyright issue. I hereby disclaim copyright in any changes I have made; this code remains in the public domain.

Regarding su_* namespace: this avoids potential conflicts with libraries such as some versions of Kerberos. No particular need to worry about whether the system supplies an MD5 library, as this file is only about 3k of object code.

#include <string.h>
#include "sofia-sip/su_md5.h"

Include dependency graph for su_md5.c:


Functions

void su_md5_init (su_md5_t *ctx)
 Initialize MD5 context.
void su_md5_deinit (su_md5_t *context)
 Clear MD5 context.
void su_md5_update (su_md5_t *ctx, void const *b, unsigned len)
 Update MD5 context.
void su_md5_iupdate (su_md5_t *ctx, void const *b, unsigned len)
 Update MD5 context.
void su_md5_strupdate (su_md5_t *ctx, char const *s)
 Update MD5 context with contents of string.
void su_md5_str0update (su_md5_t *ctx, char const *s)
 Update MD5 context with contents of string, including final NUL.
void su_md5_striupdate (su_md5_t *ctx, char const *s)
 Update MD5 context with contents of case-independent string.
void su_md5_stri0update (su_md5_t *ctx, char const *s)
 Update MD5 context with contents of case-independent string, including final NUL.
void su_md5_digest (su_md5_t const *context, uint8_t digest[16])
 Generate digest.

Function Documentation

void su_md5_deinit ( su_md5_t context  ) 

Clear MD5 context.

The function su_md5_deinit() clears MD5 context.

Parameters:
context Pointer to MD5 context structure.

void su_md5_digest ( su_md5_t const *  context,
uint8_t  digest[16] 
)

Generate digest.

Final wrapup. Pad message to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first), then concatenate message with its length (measured in bits) as 64-byte big-endian integer.

Parameters:
context Pointer to context structure
digest Digest array to be filled

void su_md5_init ( su_md5_t ctx  ) 

Initialize MD5 context.

Start MD5 accumulation. Set bit count to 0 and buffer to mysterious initialization constants.

Parameters:
ctx Pointer to context structure.

void su_md5_iupdate ( su_md5_t ctx,
void const *  b,
unsigned  len 
)

Update MD5 context.

The function su_md5_iupdate() updates context to reflect the concatenation of another buffer full of case-independent characters.

Parameters:
ctx Pointer to context structure
b Pointer to data
len Length of b as bytes

void su_md5_str0update ( su_md5_t ctx,
char const *  s 
)

Update MD5 context with contents of string, including final NUL.

The function su_md5_str0update() updates context to reflect the concatenation of NUL-terminated string, including the final NUL.

Parameters:
ctx Pointer to context structure
s Pointer to string

void su_md5_stri0update ( su_md5_t ctx,
char const *  s 
)

Update MD5 context with contents of case-independent string, including final NUL.

The function su_md5_stri0update() updates context to reflect the concatenation of NUL-terminated string, including the final NUL.

Parameters:
ctx Pointer to context structure
s Pointer to string

void su_md5_striupdate ( su_md5_t ctx,
char const *  s 
)

Update MD5 context with contents of case-independent string.

The function su_md5_striupdate() updates context to reflect the concatenation of NUL-terminated string.

Parameters:
ctx Pointer to context structure
s Pointer to string

void su_md5_strupdate ( su_md5_t ctx,
char const *  s 
)

Update MD5 context with contents of string.

The function su_md5_strupdate() updates context to reflect the concatenation of NUL-terminated string.

Parameters:
ctx Pointer to context structure
s Pointer to string

void su_md5_update ( su_md5_t ctx,
void const *  b,
unsigned  len 
)

Update MD5 context.

Update context to reflect the concatenation of another buffer full of bytes.

Parameters:
ctx Pointer to context structure
b Pointer to data
len Length of b as bytes


Sofia-SIP 1.12.1 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.