Lines Matching refs:ctx

101 static void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) {  in sha256_process_block()  argument
106 uint32_t a = ctx->H[0]; in sha256_process_block()
107 uint32_t b = ctx->H[1]; in sha256_process_block()
108 uint32_t c = ctx->H[2]; in sha256_process_block()
109 uint32_t d = ctx->H[3]; in sha256_process_block()
110 uint32_t e = ctx->H[4]; in sha256_process_block()
111 uint32_t f = ctx->H[5]; in sha256_process_block()
112 uint32_t g = ctx->H[6]; in sha256_process_block()
113 uint32_t h = ctx->H[7]; in sha256_process_block()
118 ctx->total[0] += (uint32_t)len; in sha256_process_block()
119 if (ctx->total[0] < len) { in sha256_process_block()
120 ++ctx->total[1]; in sha256_process_block()
186 ctx->H[0] = a; in sha256_process_block()
187 ctx->H[1] = b; in sha256_process_block()
188 ctx->H[2] = c; in sha256_process_block()
189 ctx->H[3] = d; in sha256_process_block()
190 ctx->H[4] = e; in sha256_process_block()
191 ctx->H[5] = f; in sha256_process_block()
192 ctx->H[6] = g; in sha256_process_block()
193 ctx->H[7] = h; in sha256_process_block()
199 static void sha256_init_ctx(struct sha256_ctx *ctx) { in sha256_init_ctx() argument
200 ctx->H[0] = 0x6a09e667; in sha256_init_ctx()
201 ctx->H[1] = 0xbb67ae85; in sha256_init_ctx()
202 ctx->H[2] = 0x3c6ef372; in sha256_init_ctx()
203 ctx->H[3] = 0xa54ff53a; in sha256_init_ctx()
204 ctx->H[4] = 0x510e527f; in sha256_init_ctx()
205 ctx->H[5] = 0x9b05688c; in sha256_init_ctx()
206 ctx->H[6] = 0x1f83d9ab; in sha256_init_ctx()
207 ctx->H[7] = 0x5be0cd19; in sha256_init_ctx()
209 ctx->total[0] = ctx->total[1] = 0; in sha256_init_ctx()
210 ctx->buflen = 0; in sha256_init_ctx()
219 static void * sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) { in sha256_finish_ctx() argument
221 uint32_t bytes = ctx->buflen; in sha256_finish_ctx()
226 ctx->total[0] += bytes; in sha256_finish_ctx()
227 if (ctx->total[0] < bytes) { in sha256_finish_ctx()
228 ++ctx->total[1]; in sha256_finish_ctx()
232 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha256_finish_ctx()
235 *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); in sha256_finish_ctx()
236 *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | in sha256_finish_ctx()
237 (ctx->total[0] >> 29)); in sha256_finish_ctx()
240 sha256_process_block(ctx->buffer, bytes + pad + 8, ctx); in sha256_finish_ctx()
244 ((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha256_finish_ctx()
251 static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx) { in sha256_process_bytes() argument
254 if (ctx->buflen != 0) { in sha256_process_bytes()
255 size_t left_over = ctx->buflen; in sha256_process_bytes()
258 memcpy(&ctx->buffer[left_over], buffer, add); in sha256_process_bytes()
259 ctx->buflen += (uint32_t)add; in sha256_process_bytes()
261 if (ctx->buflen > 64) { in sha256_process_bytes()
262 sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx); in sha256_process_bytes()
263 ctx->buflen &= 63; in sha256_process_bytes()
265 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); in sha256_process_bytes()
283 sha256_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx); in sha256_process_bytes()
287 sha256_process_block(buffer, len & ~63, ctx); in sha256_process_bytes()
295 size_t left_over = ctx->buflen; in sha256_process_bytes()
297 memcpy(&ctx->buffer[left_over], buffer, len); in sha256_process_bytes()
300 sha256_process_block(ctx->buffer, 64, ctx); in sha256_process_bytes()
302 memcpy(ctx->buffer, &ctx->buffer[64], left_over); in sha256_process_bytes()
304 ctx->buflen = (uint32_t)left_over; in sha256_process_bytes()
339 struct sha256_ctx ctx; in php_sha256_crypt_r() local
387 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
390 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
395 sha256_process_bytes(salt, salt_len, &ctx); in php_sha256_crypt_r()
417 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
419 sha256_process_bytes(alt_result, cnt, &ctx); in php_sha256_crypt_r()
425 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
427 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
432 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
474 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
478 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
480 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
485 sha256_process_bytes(s_bytes, salt_len, &ctx); in php_sha256_crypt_r()
490 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
495 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
497 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
501 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
560 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
561 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
565 ZEND_SECURE_ZERO(&ctx, sizeof(ctx)); in php_sha256_crypt_r()
683 struct sha256_ctx ctx; in main() local
693 sha256_init_ctx(&ctx); in main()
694 sha256_process_bytes(tests[cnt].input, strlen(tests[cnt].input), &ctx); in main()
695 sha256_finish_ctx(&ctx, sum); in main()
701 sha256_init_ctx(&ctx); in main()
703 sha256_process_bytes(&tests[cnt].input[i], 1, &ctx); in main()
705 sha256_finish_ctx(&ctx, sum); in main()
715 sha256_init_ctx(&ctx); in main()
717 sha256_process_bytes (buf, sizeof (buf), &ctx); in main()
720 sha256_finish_ctx(&ctx, sum); in main()