Home | History | Annotate | Download | only in lib

Lines Matching refs:ctx

54 sha1_init_ctx (ctx)
55 struct sha1_ctx *ctx;
57 ctx->A = 0x67452301;
58 ctx->B = 0xefcdab89;
59 ctx->C = 0x98badcfe;
60 ctx->D = 0x10325476;
61 ctx->E = 0xc3d2e1f0;
63 ctx->total[0] = ctx->total[1] = 0;
64 ctx->buflen = 0;
67 /* Put result from CTX in first 20 bytes following RESBUF. The result
73 sha1_read_ctx (ctx, resbuf)
74 const struct sha1_ctx *ctx;
77 ((sha1_uint32 *) resbuf)[0] = SWAP (ctx->A);
78 ((sha1_uint32 *) resbuf)[1] = SWAP (ctx->B);
79 ((sha1_uint32 *) resbuf)[2] = SWAP (ctx->C);
80 ((sha1_uint32 *) resbuf)[3] = SWAP (ctx->D);
81 ((sha1_uint32 *) resbuf)[4] = SWAP (ctx->E);
92 sha1_finish_ctx (ctx, resbuf)
93 struct sha1_ctx *ctx;
97 sha1_uint32 bytes = ctx->buflen;
101 ctx->total[0] += bytes;
102 if (ctx->total[0] < bytes)
103 ++ctx->total[1];
106 memcpy (&ctx->buffer[bytes], fillbuf, pad);
109 *(sha1_uint32 *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
110 (ctx->total[0] >> 29));
111 *(sha1_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
114 sha1_process_block (ctx->buffer, bytes + pad + 8, ctx);
116 return sha1_read_ctx (ctx, resbuf);
121 sha1_process_bytes (buffer, len, ctx)
124 struct sha1_ctx *ctx;
128 if (ctx->buflen != 0)
130 size_t left_over = ctx->buflen;
133 memcpy (&ctx->buffer[left_over], buffer, add);
134 ctx->buflen += add;
136 if (ctx->buflen > 64)
138 sha1_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
140 ctx->buflen &= 63;
142 memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
143 ctx->buflen);
164 sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
171 sha1_process_block (buffer, len & ~63, ctx);
180 size_t left_over = ctx->buflen;
182 memcpy (&ctx->buffer[left_over], buffer, len);
186 sha1_process_block (ctx->buffer, 64, ctx);
188 memcpy (ctx->buffer, &ctx->buffer[64], left_over);
190 ctx->buflen = left_over;
214 /* Process LEN bytes of BUFFER, accumulating context into CTX.
218 sha1_process_block (buffer, len, ctx)
221 struct sha1_ctx *ctx;
228 sha1_uint32 A = ctx->A;
229 sha1_uint32 B = ctx->B;
230 sha1_uint32 C = ctx->C;
231 sha1_uint32 D = ctx->D;
232 sha1_uint32 E = ctx->E;
237 ctx->total[0] += len;
238 if (ctx->total[0] < len)
239 ++ctx->total[1];
381 ctx->A = A;
382 ctx->B = B;
383 ctx->C = C;
384 ctx->D = D;
385 ctx->E = E;