Back to index

tetex-bin  3.0
Classes | Typedefs | Functions
md5.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  md5_state_s

Typedefs

typedef unsigned char md5_byte_t
typedef unsigned int md5_word_t
typedef struct md5_state_s md5_state_t

Functions

void md5_init (md5_state_t *pms)
void md5_append (md5_state_t *pms, const md5_byte_t *data, int nbytes)
void md5_finish (md5_state_t *pms, md5_byte_t digest[16])

Class Documentation

struct md5_state_s

Definition at line 67 of file md5.h.

Class Members
md5_word_t abcd
md5_byte_t buf
md5_word_t count

Typedef Documentation

typedef unsigned char md5_byte_t

Definition at line 63 of file md5.h.

typedef struct md5_state_s md5_state_t
typedef unsigned int md5_word_t

Definition at line 64 of file md5.h.


Function Documentation

void md5_append ( md5_state_t pms,
const md5_byte_t data,
int  nbytes 
)

Definition at line 323 of file md5.c.

{
    const md5_byte_t *p = data;
    int left = nbytes;
    int offset = (pms->count[0] >> 3) & 63;
    md5_word_t nbits = (md5_word_t)(nbytes << 3);

    if (nbytes <= 0)
       return;

    /* Update the message length. */
    pms->count[1] += nbytes >> 29;
    pms->count[0] += nbits;
    if (pms->count[0] < nbits)
       pms->count[1]++;

    /* Process an initial partial block. */
    if (offset) {
       int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);

       memcpy(pms->buf + offset, p, copy);
       if (offset + copy < 64)
           return;
       p += copy;
       left -= copy;
       md5_process(pms, pms->buf);
    }

    /* Process full blocks. */
    for (; left >= 64; p += 64, left -= 64)
       md5_process(pms, p);

    /* Process a final partial block. */
    if (left)
       memcpy(pms->buf, p, left);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void md5_finish ( md5_state_t pms,
md5_byte_t  digest[16] 
)

Definition at line 361 of file md5.c.

{
    static const md5_byte_t pad[64] = {
       0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };
    md5_byte_t data[8];
    int i;

    /* Save the length before padding. */
    for (i = 0; i < 8; ++i)
       data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
    /* Pad to 56 bytes mod 64. */
    md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
    /* Append the length. */
    md5_append(pms, data, 8);
    for (i = 0; i < 16; ++i)
       digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 313 of file md5.c.

{
    pms->count[0] = pms->count[1] = 0;
    pms->abcd[0] = 0x67452301;
    pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
    pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
    pms->abcd[3] = 0x10325476;
}

Here is the caller graph for this function: