md5.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  md5_state_s

Typedefs

typedef unsigned char md5_byte_t
typedef unsigned int md5_word_t
typedef 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])


Typedef Documentation

typedef unsigned char md5_byte_t

Definition at line 62 of file md5.h.

typedef struct md5_state_s md5_state_t

typedef unsigned int md5_word_t

Definition at line 63 of file md5.h.


Function Documentation

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

Definition at line 324 of file md5.c.

References md5_state_s::buf, md5_state_s::count, left, md5_process(), memcpy(), offset, and p.

Referenced by md5_file(), md5_finish(), and md5_str().

00325 {
00326     const md5_byte_t *p = data;
00327     int left = nbytes;
00328     int offset = (pms->count[0] >> 3) & 63;
00329     md5_word_t nbits = (md5_word_t)(nbytes << 3);
00330 
00331     if (nbytes <= 0)
00332         return;
00333 
00334     /* Update the message length. */
00335     pms->count[1] += nbytes >> 29;
00336     pms->count[0] += nbits;
00337     if (pms->count[0] < nbits)
00338         pms->count[1]++;
00339 
00340     /* Process an initial partial block. */
00341     if (offset) {
00342         int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
00343 
00344         memcpy(pms->buf + offset, p, copy);
00345         if (offset + copy < 64)
00346             return;
00347         p += copy;
00348         left -= copy;
00349         md5_process(pms, pms->buf);
00350     }
00351 
00352     /* Process full blocks. */
00353     for (; left >= 64; p += 64, left -= 64)
00354         md5_process(pms, p);
00355 
00356     /* Process a final partial block. */
00357     if (left)
00358         memcpy(pms->buf, p, left);
00359 }

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.

References md5_state_s::abcd, md5_state_s::count, data, i, and md5_append().

Referenced by md5_file(), and md5_str().

00362 {
00363     static const md5_byte_t pad[64] = {
00364         0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00365         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00366         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00367         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00368     };
00369     md5_byte_t data[8];
00370     int i;
00371 
00372     /* Save the length before padding. */
00373     for (i = 0; i < 8; ++i)
00374         data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
00375     /* Pad to 56 bytes mod 64. */
00376     md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
00377     /* Append the length. */
00378     md5_append(pms, data, 8);
00379     for (i = 0; i < 16; ++i)
00380         digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
00381 }

Here is the call graph for this function:

Here is the caller graph for this function:

void md5_init ( md5_state_t pms  ) 

Definition at line 315 of file md5.c.

References md5_state_s::abcd, md5_state_s::count, and T_MASK.

Referenced by md5_file(), and md5_str().

00316 {
00317     pms->count[0] = pms->count[1] = 0;
00318     pms->abcd[0] = 0x67452301;
00319     pms->abcd[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
00320     pms->abcd[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
00321     pms->abcd[3] = 0x10325476;
00322 }

Here is the caller graph for this function:


Generated on Sun Mar 4 15:15:23 2007 for Scilab [trunk] by  doxygen 1.5.1