Lines Matching refs:ctx

106 static void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) {  in sha256_process_block()  argument
111 uint32_t a = ctx->H[0]; in sha256_process_block()
112 uint32_t b = ctx->H[1]; in sha256_process_block()
113 uint32_t c = ctx->H[2]; in sha256_process_block()
114 uint32_t d = ctx->H[3]; in sha256_process_block()
115 uint32_t e = ctx->H[4]; in sha256_process_block()
116 uint32_t f = ctx->H[5]; in sha256_process_block()
117 uint32_t g = ctx->H[6]; in sha256_process_block()
118 uint32_t h = ctx->H[7]; in sha256_process_block()
123 ctx->total[0] += len; in sha256_process_block()
124 if (ctx->total[0] < len) { in sha256_process_block()
125 ++ctx->total[1]; in sha256_process_block()
191 ctx->H[0] = a; in sha256_process_block()
192 ctx->H[1] = b; in sha256_process_block()
193 ctx->H[2] = c; in sha256_process_block()
194 ctx->H[3] = d; in sha256_process_block()
195 ctx->H[4] = e; in sha256_process_block()
196 ctx->H[5] = f; in sha256_process_block()
197 ctx->H[6] = g; in sha256_process_block()
198 ctx->H[7] = h; in sha256_process_block()
204 static void sha256_init_ctx(struct sha256_ctx *ctx) { in sha256_init_ctx() argument
205 ctx->H[0] = 0x6a09e667; in sha256_init_ctx()
206 ctx->H[1] = 0xbb67ae85; in sha256_init_ctx()
207 ctx->H[2] = 0x3c6ef372; in sha256_init_ctx()
208 ctx->H[3] = 0xa54ff53a; in sha256_init_ctx()
209 ctx->H[4] = 0x510e527f; in sha256_init_ctx()
210 ctx->H[5] = 0x9b05688c; in sha256_init_ctx()
211 ctx->H[6] = 0x1f83d9ab; in sha256_init_ctx()
212 ctx->H[7] = 0x5be0cd19; in sha256_init_ctx()
214 ctx->total[0] = ctx->total[1] = 0; in sha256_init_ctx()
215 ctx->buflen = 0; in sha256_init_ctx()
224 static void * sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) { in sha256_finish_ctx() argument
226 uint32_t bytes = ctx->buflen; in sha256_finish_ctx()
231 ctx->total[0] += bytes; in sha256_finish_ctx()
232 if (ctx->total[0] < bytes) { in sha256_finish_ctx()
233 ++ctx->total[1]; in sha256_finish_ctx()
237 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha256_finish_ctx()
240 *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); in sha256_finish_ctx()
241 *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | in sha256_finish_ctx()
242 (ctx->total[0] >> 29)); in sha256_finish_ctx()
245 sha256_process_block(ctx->buffer, bytes + pad + 8, ctx); in sha256_finish_ctx()
249 ((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha256_finish_ctx()
256 static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx) { in sha256_process_bytes() argument
259 if (ctx->buflen != 0) { in sha256_process_bytes()
260 size_t left_over = ctx->buflen; in sha256_process_bytes()
263 memcpy(&ctx->buffer[left_over], buffer, add); in sha256_process_bytes()
264 ctx->buflen += add; in sha256_process_bytes()
266 if (ctx->buflen > 64) { in sha256_process_bytes()
267 sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx); in sha256_process_bytes()
268 ctx->buflen &= 63; in sha256_process_bytes()
270 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); in sha256_process_bytes()
288 sha256_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx); in sha256_process_bytes()
292 sha256_process_block(buffer, len & ~63, ctx); in sha256_process_bytes()
300 size_t left_over = ctx->buflen; in sha256_process_bytes()
302 memcpy(&ctx->buffer[left_over], buffer, len); in sha256_process_bytes()
305 sha256_process_block(ctx->buffer, 64, ctx); in sha256_process_bytes()
307 memcpy(ctx->buffer, &ctx->buffer[64], left_over); in sha256_process_bytes()
309 ctx->buflen = left_over; in sha256_process_bytes()
351 struct sha256_ctx ctx; in php_sha256_crypt_r() local
399 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
402 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
407 sha256_process_bytes(salt, salt_len, &ctx); in php_sha256_crypt_r()
429 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
431 sha256_process_bytes(alt_result, cnt, &ctx); in php_sha256_crypt_r()
437 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
439 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
444 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
486 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
490 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
492 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
497 sha256_process_bytes(s_bytes, salt_len, &ctx); in php_sha256_crypt_r()
502 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
507 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
509 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
513 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
572 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
573 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
577 memset(&ctx, '\0', sizeof(ctx)); in php_sha256_crypt_r()
696 struct sha256_ctx ctx; in main() local
706 sha256_init_ctx(&ctx); in main()
707 sha256_process_bytes(tests[cnt].input, strlen(tests[cnt].input), &ctx); in main()
708 sha256_finish_ctx(&ctx, sum); in main()
714 sha256_init_ctx(&ctx); in main()
716 sha256_process_bytes(&tests[cnt].input[i], 1, &ctx); in main()
718 sha256_finish_ctx(&ctx, sum); in main()
728 sha256_init_ctx(&ctx); in main()
730 sha256_process_bytes (buf, sizeof (buf), &ctx); in main()
733 sha256_finish_ctx(&ctx, sum); in main()