RIPEMD160() -- SSLeay 0.9.0b -- January 1999

NAME

RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final, RIPEMD160, RIPEMD160_Transform -- RIPEMD160 message digest algorithm

SYNOPSIS

#include "ripemd.h"

void RIPEMD160_Init(c)
RIPEMD160_CTX *c;

void RIPEMD160_Update(c)
RIPEMD160_CTX *c;
unsigned char *data;
unsigned long len);

void RIPEMD160_Final(c)
unsigned char *md;
RIPEMD160_CTX *c;

unsigned char *RIPEMD160(d, n, md)
unsigned long n;
unsigned char *d, *md;

void RIPEMD160_Transform(c, data)
RIPEMD160_CTX *c;
unsigned char *data;

DESCRIPTION

RIPEMD160 is a message digest algorithm that can be used to condense an arbitrary length message down to a 20 byte hash. These functions all take an RIPEMD160_CTX which contains the following:

typedef struct RIPEMD160state_st
        {
        unsigned long A,B,C,D,E;
        unsigned long Nl,Nh;
        unsigned long data[RIPEMD160_LBLOCK];
        int num;
        } RIPEMD160_CTX;

Since RIPEMD160 processes data in 20-byte blocks, the data subfield is used to keep 'leftover' data from one RIPEMD160_Update to the next, buffering it until the last of it is used with padding as needed during the RIPEMD160_Final call. The num subfield contains the length of data.

RIPEMD160_Init() expects the caller to pass a pointer to a previously allocated RIPEMD160_CTX structure. It then initializes subfields Nl, Nh, and num to 0, and sets the others to predefined values (A=RIPEMD160_A, and so on).

RIPEMD160_Update() expects len bytes of data to be hashed; the results are stored in the RIPEMD160_CTX c.

RIPEMD160_Final() provides a message digest of the data digested with RIPEMD160_Update(). The message digest is put in the md array and is RIPEMD160_DIGEST_LENGTH (20) bytes long. All subfields of the RIPEMD160_CTX c are set to zero before the routine returns.

RIPEMD160() is a convenience routine that calls RIPEMD160_Init(), RIPEMD160_Update() and then RIPEMD160_Final(). d should be a pointer to the data to be hashed and n should be the length in bytes of that data. If md is NULL, a static buffer will be used and a pointer to it returned to the caller. Otherwise the function returns a pointer to md which will contain the message digest.

If you prefer not to use the convenience routine, the functions may be called separately:

RIPEMD160_Init(...);
RIPEMD160_Update(...);
...
RIPEMD160_Update(...);
RIPEMD160_Final(...);

RIPEMD160_Transform does some endian conversions on b before calling the internal function ripemd160_block. I don't see it used anywhere. Anybody know why it would be useful?