src/md5/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_CTX

Typedefs

typedef unsigned long MD5_u32plus

Functions

void MD5_Init (MD5_CTX *ctx)
void MD5_Update (MD5_CTX *ctx, void *data, unsigned long size)
void MD5_Final (unsigned char *result, MD5_CTX *ctx)

Typedef Documentation

typedef unsigned long MD5_u32plus

Definition at line 13 of file md5.h.


Function Documentation

void MD5_Final ( unsigned char *  result,
MD5_CTX ctx 
)

Definition at line 222 of file md5c.c.

References MD5_CTX::a, MD5_CTX::b, body(), MD5_CTX::buffer, MD5_CTX::c, MD5_CTX::d, egg_memset, free, MD5_CTX::hi, and MD5_CTX::lo.

00223 {
00224     unsigned long used, free;
00225 
00226     used = ctx->lo & 0x3f;
00227 
00228     ctx->buffer[used++] = 0x80;
00229 
00230     free = 64 - used;
00231 
00232     if (free < 8) {
00233         egg_memset(&ctx->buffer[used], 0, free);
00234         body(ctx, ctx->buffer, 64);
00235         used = 0;
00236         free = 64;
00237     }
00238 
00239     egg_memset(&ctx->buffer[used], 0, free - 8);
00240 
00241     ctx->lo <<= 3;
00242     ctx->buffer[56] = ctx->lo;
00243     ctx->buffer[57] = ctx->lo >> 8;
00244     ctx->buffer[58] = ctx->lo >> 16;
00245     ctx->buffer[59] = ctx->lo >> 24;
00246     ctx->buffer[60] = ctx->hi;
00247     ctx->buffer[61] = ctx->hi >> 8;
00248     ctx->buffer[62] = ctx->hi >> 16;
00249     ctx->buffer[63] = ctx->hi >> 24;
00250 
00251     body(ctx, ctx->buffer, 64);
00252 
00253     result[0] = ctx->a;
00254     result[1] = ctx->a >> 8;
00255     result[2] = ctx->a >> 16;
00256     result[3] = ctx->a >> 24;
00257     result[4] = ctx->b;
00258     result[5] = ctx->b >> 8;
00259     result[6] = ctx->b >> 16;
00260     result[7] = ctx->b >> 24;
00261     result[8] = ctx->c;
00262     result[9] = ctx->c >> 8;
00263     result[10] = ctx->c >> 16;
00264     result[11] = ctx->c >> 24;
00265     result[12] = ctx->d;
00266     result[13] = ctx->d >> 8;
00267     result[14] = ctx->d >> 16;
00268     result[15] = ctx->d >> 24;
00269 
00270     egg_memset(ctx, 0, sizeof(ctx));
00271 }

Here is the call graph for this function:

void MD5_Init ( MD5_CTX ctx  ) 

Definition at line 177 of file md5c.c.

References MD5_CTX::a, MD5_CTX::b, MD5_CTX::c, MD5_CTX::d, MD5_CTX::hi, and MD5_CTX::lo.

00178 {
00179     ctx->a = 0x67452301;
00180     ctx->b = 0xefcdab89;
00181     ctx->c = 0x98badcfe;
00182     ctx->d = 0x10325476;
00183 
00184     ctx->lo = 0;
00185     ctx->hi = 0;
00186 }

void MD5_Update ( MD5_CTX ctx,
void *  data,
unsigned long  size 
)

Definition at line 188 of file md5c.c.

References body(), MD5_CTX::buffer, egg_memcpy(), free, MD5_CTX::hi, and MD5_CTX::lo.

00189 {
00190     MD5_u32plus saved_lo;
00191     unsigned long used, free;
00192 
00193     saved_lo = ctx->lo;
00194     if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
00195         ctx->hi++;
00196     ctx->hi += size >> 29;
00197 
00198     used = saved_lo & 0x3f;
00199 
00200     if (used) {
00201         free = 64 - used;
00202 
00203         if (size < free) {
00204             egg_memcpy(&ctx->buffer[used], data, size);
00205             return;
00206         }
00207 
00208         egg_memcpy(&ctx->buffer[used], data, free);
00209         data = ((unsigned char *)data) + free;
00210         size -= free;
00211         body(ctx, ctx->buffer, 64);
00212     }
00213 
00214     if (size >= 64) {
00215         data = body(ctx, data, size & ~(unsigned long)0x3f);
00216         size &= 0x3f;
00217     }
00218 
00219     egg_memcpy(ctx->buffer, data, size);
00220 }

Here is the call graph for this function:


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1