Main Page   Modules   Data Structures   File List   Data Fields   Globals   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.

Data Structures

union  _mendian
struct  DIGEST_CTX_s
 MD5/SHA1 digest private data. More...


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 DPRINTF(_a)
#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')

Typedefs

typedef unsigned int uint32
typedef unsigned char byte

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)

Variables

int _ie = 0x44332211
union _mendian_endian


Detailed Description

Definition in file digest.c.


Define Documentation

#define DPRINTF( _a )
 

Value:

Referenced by SHA1Transform(), and rpmDigestInit().

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

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

Definition at line 357 of file digest.c.

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

Definition at line 358 of file digest.c.

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

Definition at line 359 of file digest.c.

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

Definition at line 360 of file digest.c.

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

Definition at line 461 of file digest.c.

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

Definition at line 462 of file digest.c.

#define K1   0x5A827999L
 

The SHA Mysterious Constants.

Definition at line 73 of file digest.c.

#define K2   0x6ED9EBA1L
 

Definition at line 74 of file digest.c.

#define K3   0x8F1BBCDCL
 

Definition at line 75 of file digest.c.

#define K4   0xCA62C1D6L
 

Definition at line 76 of file digest.c.

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

Value:

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

Definition at line 363 of file digest.c.

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

32-bit rotate left - kludged with shifts.

Definition at line 81 of file digest.c.

#define expand( W, i )
 

Value:

                      ( 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 100 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 64 of file digest.c.

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

Definition at line 65 of file digest.c.

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

Definition at line 67 of file digest.c.

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

Definition at line 68 of file digest.c.

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

Value:

    ( 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 122 of file digest.c.

Referenced by SHA1Transform().


Typedef Documentation

typedef unsigned char byte
 

Definition at line 11 of file digest.c.

typedef unsigned int uint32
 

Definition at line 10 of file digest.c.


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 372 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 141 of file digest.c.

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

Definition at line 471 of file digest.c.

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


Variable Documentation

union _mendian * _endian [static]
 

int _ie = 0x44332211 [static]
 

Definition at line 454 of file digest.c.


Generated at Thu Sep 6 11:32:36 2001 for rpm by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001