lib/eggdrop/md5.h File Reference

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, const void *data, unsigned long size)
void MD5_Final (unsigned char *result, MD5_CTX *ctx)
void MD5_Hex (unsigned char *hash, char *hex)


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 md5.c.

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

Referenced by got_passreq(), recving_login(), script_md5(), sending_login(), user_check_pass(), and user_set_pass().

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     memset(&ctx->buffer[used], 0, free);
00234     body(ctx, ctx->buffer, 64);
00235     used = 0;
00236     free = 64;
00237   }
00238 
00239   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   memset(ctx, 0, sizeof(ctx));
00271 }

void MD5_Hex ( unsigned char *  hash,
char *  hex 
)

Definition at line 275 of file md5.c.

Referenced by got_passreq(), recving_login(), script_md5(), sending_login(), user_check_pass(), and user_set_pass().

00276 {
00277   int i;
00278 
00279   for (i = 0; i < 16; i++) sprintf(hex + (i*2), "%.2x", (int) hash[i]);
00280 }

void MD5_Init ( MD5_CTX ctx  ) 

Definition at line 178 of file md5.c.

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

Referenced by got_passreq(), recving_login(), script_md5(), sending_login(), user_check_pass(), and user_set_pass().

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

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

Definition at line 189 of file md5.c.

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

Referenced by got_passreq(), recving_login(), script_md5(), sending_login(), user_check_pass(), and user_set_pass().

00190 {
00191   MD5_u32plus saved_lo;
00192   unsigned long used, free;
00193 
00194   saved_lo = ctx->lo;
00195   if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) 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       memcpy(&ctx->buffer[used], data, size);
00205       return;
00206     }
00207 
00208     memcpy(&ctx->buffer[used], data, free);
00209     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   memcpy(ctx->buffer, data, size);
00220 }


Generated on Sun Nov 30 18:43:34 2008 for eggdrop1.9 by  doxygen 1.5.6