Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

rpmio/digest.c File Reference

More...

#include "system.h"
#include "rpmio_internal.h"
#include "debug.h"

Go to the source code of this file.

Compounds

union  _mendian
struct  DIGEST_CTX_s

Defines

#define f1(x,y,z)    ( z ^ ( x & ( y ^ z ) ) )
 The SHA f()-functions. More...

#define f2(x,y,z)    ( x ^ y ^ z )
#define f3(x,y,z)    ( ( x & y ) | ( z & ( x | y ) ) )
#define f4(x,y,z)    ( x ^ y ^ z )
#define K1   0x5A827999L
 The SHA Mysterious Constants. More...

#define K2   0x6ED9EBA1L
#define K3   0x8F1BBCDCL
#define K4   0xCA62C1D6L
#define ROTL(n,X)    ( ( (X) << (n) ) | ( (X) >> ( 32 - (n) ) ) )
 32-bit rotate left - kludged with shifts. More...

#define expand(W,i)
 The initial expanding function. More...

#define subRound(a, b, c, d, e, f, k, data)
 The prototype SHA sub-round. More...

#define F1(x, y, z)    (z ^ (x & (y ^ z)))
 The four core functions used in MD5 - F1 is optimized somewhat. More...

#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)
 The central step in the MD5 algorithm. More...

#define IS_BIG_ENDIAN()    (_endian->b[0] == '\x44')
#define IS_LITTLE_ENDIAN()    (_endian->b[0] == '\x11')

Functions

void SHA1Transform (DIGEST_CTX ctx)
 The core of the SHA algorithm. More...

void MD5Transform (DIGEST_CTX ctx)
 The core of the MD5 algorithm. More...

void byteReverse (byte *buf, unsigned nbytes)
DIGEST_CTX rpmDigestInit (rpmDigestFlags flags)
void rpmDigestUpdate (DIGEST_CTX ctx, const void * data, size_t len)
void rpmDigestFinal ( DIGEST_CTX ctx, void ** datap, size_t *lenp, int asAscii)


Detailed Description

Definition in file digest.c.


Define Documentation

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

The four core functions used in MD5 - F1 is optimized somewhat.

Definition at line 261 of file digest.c.

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

Definition at line 262 of file digest.c.

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

Definition at line 263 of file digest.c.

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

Definition at line 264 of file digest.c.

#define IS_BIG_ENDIAN( )   (_endian->b[0] == '\x44')
 

Definition at line 360 of file digest.c.

#define IS_LITTLE_ENDIAN( )   (_endian->b[0] == '\x11')
 

Definition at line 361 of file digest.c.

#define K1   0x5A827999L
 

The SHA Mysterious Constants.

Definition at line 69 of file digest.c.

#define K2   0x6ED9EBA1L
 

Definition at line 70 of file digest.c.

#define K3   0x8F1BBCDCL
 

Definition at line 71 of file digest.c.

#define K4   0xCA62C1D6L
 

Definition at line 72 of file digest.c.

#define MD5STEP( f, w, x, y, z, data, s )
 

Initializer:

\
        ( w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x )
The central step in the MD5 algorithm.

Definition at line 267 of file digest.c.

#define ROTL( n, X )   ( ( (X) << (n) ) | ( (X) >> ( 32 - (n) ) ) )
 

32-bit rotate left - kludged with shifts.

Definition at line 77 of file digest.c.

#define expand( W, i )
 

Initializer:

( W[ i & 15 ] = \
                      ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \
                                 W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) )
The initial expanding function.

The hash function is defined over an 80-word expanded input array W, where the first 16 are copies of the input data, and the remaining 64 are defined by

 *      W[ i ] = W[ i - 16 ] ^ W[ i - 14 ] ^ W[ i - 8 ] ^ W[ i - 3 ]
 * 

This implementation generates these values on the fly in a circular buffer - thanks to Colin Plumb, colin@nyx10.cs.du.edu for this optimization.

The updated SHA changes the expanding function by adding a rotate of 1 bit. Thanks to Jim Gillogly, jim@rand.org, and an anonymous contributor for this information

Definition at line 96 of file digest.c.

Referenced by SHA1Transform().

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

The SHA f()-functions.

The f1 and f3 functions can be optimized to save one boolean operation each - thanks to Rich Schroeppel, rcs@cs.arizona.edu for discovering this.

Definition at line 60 of file digest.c.

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

Definition at line 61 of file digest.c.

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

Definition at line 63 of file digest.c.

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

Definition at line 64 of file digest.c.

#define subRound( a, b, c, d, e, f, k, data )
 

Initializer:

\
    ( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
The prototype SHA sub-round.

The fundamental sub-round is:

 *      a' = e + ROTL( 5, a ) + f( b, c, d ) + k + data;
 *      b' = a;
 *      c' = ROTL( 30, b );
 *      d' = c;
 *      e' = d;
 * 

but this is implemented by unrolling the loop 5 times and renaming the variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration. This code is then replicated 20 times for each of the 4 functions, using the next 20 values from the W[] array each time.

Definition at line 118 of file digest.c.

Referenced by SHA1Transform().


Function Documentation

void MD5Transform ( DIGEST_CTX ctx ) [static]
 

The core of the MD5 algorithm.

Update MD5 context with next 64 bytes of plain text.

Parameters:
private   MD5 private data

Definition at line 276 of file digest.c.

void SHA1Transform ( DIGEST_CTX ctx ) [static]
 

The core of the SHA algorithm.

This alters an existing SHA hash to reflect the addition of 16 longwords of new data.

Parameters:
private   SHA private data

Definition at line 137 of file digest.c.

void byteReverse ( byte * buf,
unsigned nbytes ) [static]
 

Definition at line 369 of file digest.c.

Referenced by rpmDigestFinal(), rpmDigestUpdate(), rpmMD5Final(), and rpmMD5Update().


Generated at Sun Apr 8 18:43:05 2001 for rpm by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000