md5.c File Reference

#include "config.h"
#include <isc/assertions.h>
#include <isc/md5.h>
#include <isc/platform.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>

Go to the source code of this file.

Defines

#define MD5STEP(f, w, x, y, z, in, s)   (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
#define F1(x, y, z)   (z ^ (x & (y ^ z)))
#define F2(x, y, z)   F1(z, x, y)
#define F3(x, y, z)   (x ^ y ^ z)
#define F4(x, y, z)   (y ^ (x | ~z))

Functions

static void byteSwap (isc_uint32_t *buf, unsigned words)
void isc_md5_init (isc_md5_t *ctx)
void isc_md5_invalidate (isc_md5_t *ctx)
static void transform (isc_uint32_t buf[4], isc_uint32_t const in[16])
void isc_md5_update (isc_md5_t *ctx, const unsigned char *buf, unsigned int len)
void isc_md5_final (isc_md5_t *ctx, unsigned char *digest)


Detailed Description

This code implements the MD5 message-digest algorithm. The algorithm is due to Ron Rivest. This code was written by Colin Plumb in 1993, no copyright is claimed. This code is in the public domain; do with it what you wish.

Equivalent code is available from RSA Data Security, Inc. This code has been tested against that, and is equivalent, except that you don't need to include two pages of legalese with every copy.

To compute the message digest of a chunk of bytes, declare an MD5Context structure, pass it to MD5Init, call MD5Update as needed on buffers full of bytes, and then call MD5Final, which will fill a supplied 16-byte array with the digest.

Definition in file md5.c.


Define Documentation

#define F1 ( x,
y,
 )     (z ^ (x & (y ^ z)))

The four core functions - F1 is optimized somewhat

Definition at line 157 of file md5.c.

Referenced by transform().

#define F2 ( x,
y,
 )     F1(z, x, y)

The four core functions - F1 is optimized somewhat

Definition at line 158 of file md5.c.

Referenced by transform().

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

The four core functions - F1 is optimized somewhat

Definition at line 159 of file md5.c.

Referenced by transform().

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

The four core functions - F1 is optimized somewhat

Definition at line 160 of file md5.c.

Referenced by transform().

#define MD5STEP ( f,
w,
x,
y,
z,
in,
s   )     (w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)

This is the central step in the MD5 algorithm.

Definition at line 164 of file md5.c.

Referenced by transform().


Function Documentation

static void byteSwap ( isc_uint32_t buf,
unsigned  words 
) [static]

Definition at line 122 of file md5.c.

Referenced by isc_md5_final(), and isc_md5_update().

void isc_md5_init ( isc_md5_t ctx  ) 

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

Definition at line 138 of file md5.c.

References isc_md5_t::buf, and isc_md5_t::bytes.

Referenced by ATF_TC_BODY(), compute_secret(), hmacmd5_fromdns(), isc_hmacmd5_init(), and isc_hmacmd5_sign().

void isc_md5_invalidate ( isc_md5_t ctx  ) 

Definition at line 149 of file md5.c.

Referenced by isc_hmacmd5_invalidate().

static void transform ( isc_uint32_t  buf[4],
isc_uint32_t const   in[16] 
) [static]

The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data. MD5Update blocks the data and converts bytes into longwords for this routine.

Definition at line 173 of file md5.c.

References F1, F2, F3, F4, and MD5STEP.

Referenced by isc_md5_final(), isc_md5_update(), and isc_sha1_update().

void isc_md5_update ( isc_md5_t ctx,
const unsigned char *  buf,
unsigned int  len 
)

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

Definition at line 260 of file md5.c.

References isc_md5_t::buf, isc_md5_t::bytes, byteSwap(), isc_md5_t::in, and transform().

Referenced by ATF_TC_BODY(), compute_secret(), hmacmd5_fromdns(), isc_hmacmd5_init(), isc_hmacmd5_sign(), and isc_hmacmd5_update().

void isc_md5_final ( isc_md5_t ctx,
unsigned char *  digest 
)

Final wrapup - pad to 64-byte boundary with the bit pattern 1 0* (64-bit count of bits processed, MSB-first)

Definition at line 299 of file md5.c.

References isc_md5_t::buf, isc_md5_t::bytes, byteSwap(), isc_md5_t::in, and transform().

Referenced by ATF_TC_BODY(), compute_secret(), hmacmd5_fromdns(), isc_hmacmd5_init(), and isc_hmacmd5_sign().


Generated on Tue Apr 28 17:41:18 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha