Lines Matching refs:ctx

52 md5_init_ctx (struct md5_ctx *ctx)
54 ctx->A = 0x67452301;
55 ctx->B = 0xefcdab89;
56 ctx->C = 0x98badcfe;
57 ctx->D = 0x10325476;
59 ctx->total[0] = ctx->total[1] = 0;
60 ctx->buflen = 0;
69 md5_read_ctx (const struct md5_ctx *ctx, void *resbuf)
71 ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A);
72 ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B);
73 ((md5_uint32 *) resbuf)[2] = SWAP (ctx->C);
74 ((md5_uint32 *) resbuf)[3] = SWAP (ctx->D);
95 md5_finish_ctx (struct md5_ctx *ctx, void *resbuf)
98 md5_uint32 bytes = ctx->buflen;
102 ctx->total[0] += bytes;
103 if (ctx->total[0] < bytes)
104 ++ctx->total[1];
107 memcpy (&ctx->buffer[bytes], fillbuf, pad);
110 const uint64_t bit_length = ((ctx->total[0] << 3)
111 + ((uint64_t) ((ctx->total[1] << 3) |
112 (ctx->total[0] >> 29)) << 32));
113 le64_copy (&ctx->buffer[bytes + pad], bit_length);
116 md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
118 return md5_read_ctx (ctx, resbuf);
131 struct md5_ctx ctx;
136 md5_init_ctx (&ctx);
165 md5_process_block (buffer, BLOCKSIZE, &ctx);
170 md5_process_bytes (buffer, sum, &ctx);
173 md5_finish_ctx (&ctx, resblock);
187 struct md5_ctx ctx;
190 md5_init_ctx (&ctx);
193 md5_process_bytes (buffer, len, &ctx);
196 return md5_finish_ctx (&ctx, resblock);
202 md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
206 if (ctx->buflen != 0)
208 size_t left_over = ctx->buflen;
211 memcpy (&ctx->buffer[left_over], buffer, add);
212 ctx->buflen += add;
214 if (ctx->buflen > 64)
216 md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
218 ctx->buflen &= 63;
220 memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
221 ctx->buflen);
242 md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
249 md5_process_block (buffer, len & ~63, ctx);
258 size_t left_over = ctx->buflen;
260 memcpy (&ctx->buffer[left_over], buffer, len);
264 md5_process_block (ctx->buffer, 64, ctx);
266 memcpy (ctx->buffer, &ctx->buffer[64], left_over);
268 ctx->buflen = left_over;
286 md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
292 md5_uint32 A = ctx->A;
293 md5_uint32 B = ctx->B;
294 md5_uint32 C = ctx->C;
295 md5_uint32 D = ctx->D;
300 ctx->total[0] += len;
301 if (ctx->total[0] < len)
302 ++ctx->total[1];
434 ctx->A = A;
435 ctx->B = B;
436 ctx->C = C;
437 ctx->D = D;