Lines Matching defs:ctx
41 static const void *body(MD5_CTX *ctx, const void *data, ulong_t size) {
46 a = ctx->a;
47 b = ctx->b;
48 c = ctx->c;
49 d = ctx->d;
133 ctx->a = a;
134 ctx->b = b;
135 ctx->c = c;
136 ctx->d = d;
149 void MD5_Init(MD5_CTX *ctx) {
150 ctx->a = 0x67452301;
151 ctx->b = 0xefcdab89;
152 ctx->c = 0x98badcfe;
153 ctx->d = 0x10325476;
155 ctx->lo = 0;
156 ctx->hi = 0;
159 void MD5_Update(MD5_CTX *ctx, const void *data, ulong_t size) {
163 saved_lo = ctx->lo;
164 if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
165 ctx->hi++;
166 ctx->hi += size >> 29;
174 internal_memcpy(&ctx->buffer[used], data, size);
178 internal_memcpy(&ctx->buffer[used], data, free);
181 body(ctx, ctx->buffer, 64);
185 data = body(ctx, data, size & ~(ulong_t)0x3f);
189 internal_memcpy(ctx->buffer, data, size);
192 void MD5_Final(unsigned char *result, MD5_CTX *ctx) {
195 used = ctx->lo & 0x3f;
197 ctx->buffer[used++] = 0x80;
202 internal_memset(&ctx->buffer[used], 0, free);
203 body(ctx, ctx->buffer, 64);
208 internal_memset(&ctx->buffer[used], 0, free - 8);
210 ctx->lo <<= 3;
211 ctx->buffer[56] = ctx->lo;
212 ctx->buffer[57] = ctx->lo >> 8;
213 ctx->buffer[58] = ctx->lo >> 16;
214 ctx->buffer[59] = ctx->lo >> 24;
215 ctx->buffer[60] = ctx->hi;
216 ctx->buffer[61] = ctx->hi >> 8;
217 ctx->buffer[62] = ctx->hi >> 16;
218 ctx->buffer[63] = ctx->hi >> 24;
220 body(ctx, ctx->buffer, 64);
222 result[0] = ctx->a;
223 result[1] = ctx->a >> 8;
224 result[2] = ctx->a >> 16;
225 result[3] = ctx->a >> 24;
226 result[4] = ctx->b;
227 result[5] = ctx->b >> 8;
228 result[6] = ctx->b >> 16;
229 result[7] = ctx->b >> 24;
230 result[8] = ctx->c;
231 result[9] = ctx->c >> 8;
232 result[10] = ctx->c >> 16;
233 result[11] = ctx->c >> 24;
234 result[12] = ctx->d;
235 result[13] = ctx->d >> 8;
236 result[14] = ctx->d >> 16;
237 result[15] = ctx->d >> 24;
239 internal_memset(ctx, 0, sizeof(*ctx));
244 MD5_CTX ctx;
245 MD5_Init(&ctx);
246 MD5_Update(&ctx, data, size);
247 MD5_Final((unsigned char*)&res.hash[0], &ctx);