UCL Common Library Reference
<<< Previous Page | Home | Up | Next Page >>>

# MD5

## Name

MD5 -- Message Digest-5 algorithm.

## Synopsis

    #include <md5.h>

    typedef     MD5_CTX;
    void        MD5Init                         (MD5_CTX *context);
    void        MD5Update                       (MD5_CTX *context,
                                                 unsigned char *input,
                                                 unsigned int inputLen);
    void        MD5Final                        (unsigned char digest[16],
                                                 MD5_CTX *context);

## Description

The MD5 algorithm calculates a 128-bit digest of an arbitrary length stream of data. The digest is a fingerprint that can be used to verify the integrity of a transmitted message. The sender and receiver of the message independently calculate the message digest and compare values to ascertain the integrity of the message. The probability of two messages having the same digest is miniscule.

The MD5 algorithm is the intellectual property of RSA Data Security, Inc.

## Details

### MD5_CTX

    typedef struct {
      uint32_t state[4];            /* state (ABCD) */
      uint32_t count[2];        	/* number of bits, modulo 2^64 (lsb first) */
      unsigned char buffer[64];     /* input buffer */
    } MD5_CTX;

The state for the MD5 calculation.

### MD5Init ()

    void        MD5Init                         (MD5_CTX *context);

Initializes MD5 context for the start of message digest computation.

`context` : | MD5 context to be initialized.

### MD5Update ()

    void        MD5Update                       (MD5_CTX *context,
                                                 unsigned char *input,
                                                 unsigned int inputLen);

MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context.

`context` : | MD5 context to be updated.
`input` : | pointer to data to be fed into MD5 algorithm.
`inputLen` : | size of `input` data in bytes.

### MD5Final ()

    void        MD5Final                        (unsigned char digest[16],
                                                 MD5_CTX *context);

Ends an MD5 message-digest operation, writing the the message digest and zeroing the context. The context must be initialized with MD5Init() before being used for other MD5 checksum calculations.

`digest` : | 16-byte buffer to write MD5 checksum.
`context` : | MD5 context to be finalized.

## See Also

RFC1321 - The MD5 Message Digest Algorithm

<<< Previous Page | Home | Up | Next Page >>>
HMAC | NETUDP