ELinks 0.18.0
md5.c File Reference

MD5 implementation (RFC 1321) More...

#include <string.h>
#include "elinks.h"
#include "util/md5.h"
Include dependency graph for md5.c:

Macros

#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))
 
#define MD5STEP(f, w, x, y, z, data, s)    ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
 This is the central step in the MD5 algorithm.
 

Functions

static void transform_md5 (uint32_t buf[4], uint32_t const in[16])
 The core of the MD5 algorithm, this alters an existing MD5 hash to reflect the addition of 16 longwords of new data.
 
static void reverse_md5_bytes (unsigned char *buf, unsigned int longs)
 Swap the bytes of each uint32_t, if necessary.
 
unsigned char * digest_md5 (const char *data, unsigned long length, md5_digest_bin_T digest)
 Digest the passed data with the given length and stores the MD5 digest in the digest parameter.
 

Detailed Description

MD5 implementation (RFC 1321)

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.

This code was slightly modified to fit into Samba by abart.nosp@m.let@.nosp@m.samba.nosp@m..org Jun 2001 and to fit the cifs vfs by Steve French sfren.nosp@m.ch@u.nosp@m.s.ibm.nosp@m..com. Grabbed from linux-2.6.9 one November afternoon 2004 and ELinksified' by jonas.

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.

Macro Definition Documentation

◆ F1

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

◆ F2

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

◆ F3

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

◆ F4

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

◆ MD5STEP

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

This is the central step in the MD5 algorithm.

Function Documentation

◆ digest_md5()

unsigned char * digest_md5 ( const char * data,
unsigned long length,
md5_digest_bin_T digest )

Digest the passed data with the given length and stores the MD5 digest in the digest parameter.

◆ reverse_md5_bytes()

static void reverse_md5_bytes ( unsigned char * buf,
unsigned int longs )
static

Swap the bytes of each uint32_t, if necessary.

This code is harmless on little-endian machines.

Todo
FIXME: Optimize it away on little-endian machines.

◆ transform_md5()

static void transform_md5 ( uint32_t buf[4],
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.

md5_update() blocks the data and converts bytes into longwords for this routine.