Lines Matching refs:ctx

91 static void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) {  in sha256_process_block()  argument
96 uint32_t a = ctx->H[0]; in sha256_process_block()
97 uint32_t b = ctx->H[1]; in sha256_process_block()
98 uint32_t c = ctx->H[2]; in sha256_process_block()
99 uint32_t d = ctx->H[3]; in sha256_process_block()
100 uint32_t e = ctx->H[4]; in sha256_process_block()
101 uint32_t f = ctx->H[5]; in sha256_process_block()
102 uint32_t g = ctx->H[6]; in sha256_process_block()
103 uint32_t h = ctx->H[7]; in sha256_process_block()
108 ctx->total[0] += (uint32_t)len; in sha256_process_block()
109 if (ctx->total[0] < len) { in sha256_process_block()
110 ++ctx->total[1]; in sha256_process_block()
176 ctx->H[0] = a; in sha256_process_block()
177 ctx->H[1] = b; in sha256_process_block()
178 ctx->H[2] = c; in sha256_process_block()
179 ctx->H[3] = d; in sha256_process_block()
180 ctx->H[4] = e; in sha256_process_block()
181 ctx->H[5] = f; in sha256_process_block()
182 ctx->H[6] = g; in sha256_process_block()
183 ctx->H[7] = h; in sha256_process_block()
189 static void sha256_init_ctx(struct sha256_ctx *ctx) { in sha256_init_ctx() argument
190 ctx->H[0] = 0x6a09e667; in sha256_init_ctx()
191 ctx->H[1] = 0xbb67ae85; in sha256_init_ctx()
192 ctx->H[2] = 0x3c6ef372; in sha256_init_ctx()
193 ctx->H[3] = 0xa54ff53a; in sha256_init_ctx()
194 ctx->H[4] = 0x510e527f; in sha256_init_ctx()
195 ctx->H[5] = 0x9b05688c; in sha256_init_ctx()
196 ctx->H[6] = 0x1f83d9ab; in sha256_init_ctx()
197 ctx->H[7] = 0x5be0cd19; in sha256_init_ctx()
199 ctx->total[0] = ctx->total[1] = 0; in sha256_init_ctx()
200 ctx->buflen = 0; in sha256_init_ctx()
209 static void * sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) { in sha256_finish_ctx() argument
211 uint32_t bytes = ctx->buflen; in sha256_finish_ctx()
216 ctx->total[0] += bytes; in sha256_finish_ctx()
217 if (ctx->total[0] < bytes) { in sha256_finish_ctx()
218 ++ctx->total[1]; in sha256_finish_ctx()
222 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha256_finish_ctx()
225 *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3); in sha256_finish_ctx()
226 *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) | in sha256_finish_ctx()
227 (ctx->total[0] >> 29)); in sha256_finish_ctx()
230 sha256_process_block(ctx->buffer, bytes + pad + 8, ctx); in sha256_finish_ctx()
234 ((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha256_finish_ctx()
241 static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx) { in sha256_process_bytes() argument
244 if (ctx->buflen != 0) { in sha256_process_bytes()
245 size_t left_over = ctx->buflen; in sha256_process_bytes()
248 memcpy(&ctx->buffer[left_over], buffer, add); in sha256_process_bytes()
249 ctx->buflen += (uint32_t)add; in sha256_process_bytes()
251 if (ctx->buflen > 64) { in sha256_process_bytes()
252 sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx); in sha256_process_bytes()
253 ctx->buflen &= 63; in sha256_process_bytes()
255 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen); in sha256_process_bytes()
273 sha256_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx); in sha256_process_bytes()
277 sha256_process_block(buffer, len & ~63, ctx); in sha256_process_bytes()
285 size_t left_over = ctx->buflen; in sha256_process_bytes()
287 memcpy(&ctx->buffer[left_over], buffer, len); in sha256_process_bytes()
290 sha256_process_block(ctx->buffer, 64, ctx); in sha256_process_bytes()
292 memcpy(ctx->buffer, &ctx->buffer[64], left_over); in sha256_process_bytes()
294 ctx->buflen = (uint32_t)left_over; in sha256_process_bytes()
329 struct sha256_ctx ctx; in php_sha256_crypt_r() local
388 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
391 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
396 sha256_process_bytes(salt, salt_len, &ctx); in php_sha256_crypt_r()
418 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
420 sha256_process_bytes(alt_result, cnt, &ctx); in php_sha256_crypt_r()
426 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
428 sha256_process_bytes(key, key_len, &ctx); in php_sha256_crypt_r()
433 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
477 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
481 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
483 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
488 sha256_process_bytes(s_bytes, salt_len, &ctx); in php_sha256_crypt_r()
493 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
498 sha256_process_bytes(alt_result, 32, &ctx); in php_sha256_crypt_r()
500 sha256_process_bytes(p_bytes, key_len, &ctx); in php_sha256_crypt_r()
504 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
563 sha256_init_ctx(&ctx); in php_sha256_crypt_r()
564 sha256_finish_ctx(&ctx, alt_result); in php_sha256_crypt_r()
568 ZEND_SECURE_ZERO(&ctx, sizeof(ctx)); in php_sha256_crypt_r()
694 struct sha256_ctx ctx; in main() local
704 sha256_init_ctx(&ctx); in main()
705 sha256_process_bytes(tests[cnt].input, strlen(tests[cnt].input), &ctx); in main()
706 sha256_finish_ctx(&ctx, sum); in main()
712 sha256_init_ctx(&ctx); in main()
714 sha256_process_bytes(&tests[cnt].input[i], 1, &ctx); in main()
716 sha256_finish_ctx(&ctx, sum); in main()
726 sha256_init_ctx(&ctx); in main()
728 sha256_process_bytes (buf, sizeof (buf), &ctx); in main()
731 sha256_finish_ctx(&ctx, sum); in main()