#include <eggdrop/eggdrop.h>
Go to the source code of this file.
Defines | |
#define | F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
#define | G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) |
#define | H(x, y, z) ((x) ^ (y) ^ (z)) |
#define | I(x, y, z) ((y) ^ ((x) | ~(z))) |
#define | STEP(f, a, b, c, d, x, t, s) |
#define | SET(n) |
#define | GET(n) (ctx->block[(n)]) |
Functions | |
static const void * | body (MD5_CTX *ctx, const void *data, unsigned long size) |
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) |
Variables | |
static const char | rcsid [] = "$Id: md5.c,v 1.7 2004-10-17 05:14:06 stdarg Exp $" |
#define F | ( | x, | |||
y, | |||||
z | ) | ((z) ^ ((x) & ((y) ^ (z)))) |
#define G | ( | x, | |||
y, | |||||
z | ) | ((y) ^ ((z) & ((x) ^ (y)))) |
#define I | ( | x, | |||
y, | |||||
z | ) | ((y) ^ ((x) | ~(z))) |
#define SET | ( | n | ) |
Value:
(ctx->block[(n)] = \ (MD5_u32plus)ptr[(n) * 4] | \ ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ ((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
Definition at line 57 of file md5.c.
Referenced by body().
#define STEP | ( | f, | |||
a, | |||||
b, | |||||
c, | |||||
d, | |||||
x, | |||||
t, | |||||
s | ) |
static const void* body | ( | MD5_CTX * | ctx, | |
const void * | data, | |||
unsigned long | size | |||
) | [static] |
Definition at line 71 of file md5.c.
References MD5_CTX::a, MD5_CTX::b, MD5_CTX::c, MD5_CTX::d, F, G, GET, H, I, SET, and STEP.
Referenced by MD5_Final(), and MD5_Update().
00072 { 00073 const unsigned char *ptr; 00074 MD5_u32plus a, b, c, d; 00075 MD5_u32plus saved_a, saved_b, saved_c, saved_d; 00076 00077 ptr = data; 00078 00079 a = ctx->a; 00080 b = ctx->b; 00081 c = ctx->c; 00082 d = ctx->d; 00083 00084 do { 00085 saved_a = a; 00086 saved_b = b; 00087 saved_c = c; 00088 saved_d = d; 00089 00090 /* Round 1 */ 00091 STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) 00092 STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) 00093 STEP(F, c, d, a, b, SET(2), 0x242070db, 17) 00094 STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) 00095 STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) 00096 STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) 00097 STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) 00098 STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) 00099 STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) 00100 STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) 00101 STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) 00102 STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) 00103 STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) 00104 STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) 00105 STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) 00106 STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) 00107 00108 /* Round 2 */ 00109 STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) 00110 STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) 00111 STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) 00112 STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) 00113 STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) 00114 STEP(G, d, a, b, c, GET(10), 0x02441453, 9) 00115 STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) 00116 STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) 00117 STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) 00118 STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) 00119 STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) 00120 STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) 00121 STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) 00122 STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) 00123 STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) 00124 STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) 00125 00126 /* Round 3 */ 00127 STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) 00128 STEP(H, d, a, b, c, GET(8), 0x8771f681, 11) 00129 STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) 00130 STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23) 00131 STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) 00132 STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11) 00133 STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) 00134 STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23) 00135 STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) 00136 STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11) 00137 STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) 00138 STEP(H, b, c, d, a, GET(6), 0x04881d05, 23) 00139 STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) 00140 STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11) 00141 STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) 00142 STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23) 00143 00144 /* Round 4 */ 00145 STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) 00146 STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) 00147 STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) 00148 STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) 00149 STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) 00150 STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) 00151 STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) 00152 STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) 00153 STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) 00154 STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) 00155 STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) 00156 STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) 00157 STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) 00158 STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) 00159 STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) 00160 STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) 00161 00162 a += saved_a; 00163 b += saved_b; 00164 c += saved_c; 00165 d += saved_d; 00166 00167 ptr += 64; 00168 } while (size -= 64); 00169 00170 ctx->a = a; 00171 ctx->b = b; 00172 ctx->c = c; 00173 ctx->d = d; 00174 00175 return ptr; 00176 }
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 }
const char rcsid[] = "$Id: md5.c,v 1.7 2004-10-17 05:14:06 stdarg Exp $" [static] |