Lines Matching refs:ctx
122 sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_block() argument
125 uint64_t a = ctx->H[0]; in sha512_process_block()
126 uint64_t b = ctx->H[1]; in sha512_process_block()
127 uint64_t c = ctx->H[2]; in sha512_process_block()
128 uint64_t d = ctx->H[3]; in sha512_process_block()
129 uint64_t e = ctx->H[4]; in sha512_process_block()
130 uint64_t f = ctx->H[5]; in sha512_process_block()
131 uint64_t g = ctx->H[6]; in sha512_process_block()
132 uint64_t h = ctx->H[7]; in sha512_process_block()
137 ctx->total[0] += len; in sha512_process_block()
138 if (ctx->total[0] < len) { in sha512_process_block()
139 ++ctx->total[1]; in sha512_process_block()
208 ctx->H[0] = a; in sha512_process_block()
209 ctx->H[1] = b; in sha512_process_block()
210 ctx->H[2] = c; in sha512_process_block()
211 ctx->H[3] = d; in sha512_process_block()
212 ctx->H[4] = e; in sha512_process_block()
213 ctx->H[5] = f; in sha512_process_block()
214 ctx->H[6] = g; in sha512_process_block()
215 ctx->H[7] = h; in sha512_process_block()
221 static void sha512_init_ctx (struct sha512_ctx *ctx) { in sha512_init_ctx() argument
222 ctx->H[0] = UINT64_C (0x6a09e667f3bcc908); in sha512_init_ctx()
223 ctx->H[1] = UINT64_C (0xbb67ae8584caa73b); in sha512_init_ctx()
224 ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b); in sha512_init_ctx()
225 ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1); in sha512_init_ctx()
226 ctx->H[4] = UINT64_C (0x510e527fade682d1); in sha512_init_ctx()
227 ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f); in sha512_init_ctx()
228 ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b); in sha512_init_ctx()
229 ctx->H[7] = UINT64_C (0x5be0cd19137e2179); in sha512_init_ctx()
231 ctx->total[0] = ctx->total[1] = 0; in sha512_init_ctx()
232 ctx->buflen = 0; in sha512_init_ctx()
241 static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) { in sha512_finish_ctx() argument
243 uint64_t bytes = ctx->buflen; in sha512_finish_ctx()
248 ctx->total[0] += bytes; in sha512_finish_ctx()
249 if (ctx->total[0] < bytes) { in sha512_finish_ctx()
250 ++ctx->total[1]; in sha512_finish_ctx()
254 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha512_finish_ctx()
257 *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3); in sha512_finish_ctx()
258 *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) | in sha512_finish_ctx()
259 (ctx->total[0] >> 61)); in sha512_finish_ctx()
262 sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx); in sha512_finish_ctx()
266 ((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha512_finish_ctx()
273 sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_bytes() argument
276 if (ctx->buflen != 0) { in sha512_process_bytes()
277 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
280 memcpy(&ctx->buffer[left_over], buffer, add); in sha512_process_bytes()
281 ctx->buflen += add; in sha512_process_bytes()
283 if (ctx->buflen > 128) { in sha512_process_bytes()
284 sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx); in sha512_process_bytes()
286 ctx->buflen &= 127; in sha512_process_bytes()
288 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127], in sha512_process_bytes()
289 (size_t)ctx->buflen); in sha512_process_bytes()
308 sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx); in sha512_process_bytes()
315 sha512_process_block(buffer, len & ~127, ctx); in sha512_process_bytes()
323 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
325 memcpy(&ctx->buffer[left_over], buffer, len); in sha512_process_bytes()
328 sha512_process_block(ctx->buffer, 128, ctx); in sha512_process_bytes()
330 memcpy(ctx->buffer, &ctx->buffer[128], left_over); in sha512_process_bytes()
332 ctx->buflen = left_over; in sha512_process_bytes()
367 struct sha512_ctx ctx; in php_sha512_crypt_r() local
427 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
430 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
435 sha512_process_bytes(salt, salt_len, &ctx); in php_sha512_crypt_r()
457 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
459 sha512_process_bytes(alt_result, cnt, &ctx); in php_sha512_crypt_r()
465 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
467 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
472 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
517 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
521 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
523 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
528 sha512_process_bytes(s_bytes, salt_len, &ctx); in php_sha512_crypt_r()
533 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
538 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
540 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
544 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
616 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
617 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
621 ZEND_SECURE_ZERO(&ctx, sizeof(ctx)); in php_sha512_crypt_r()
764 struct sha512_ctx ctx; in main() local
777 sha512_init_ctx (&ctx); in main()
778 sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx); in main()
779 sha512_finish_ctx (&ctx, sum); in main()
785 sha512_init_ctx (&ctx); in main()
787 sha512_process_bytes (&tests[cnt].input[i], 1, &ctx); in main()
789 sha512_finish_ctx (&ctx, sum); in main()
799 sha512_init_ctx (&ctx); in main()
801 sha512_process_bytes (buf, sizeof (buf), &ctx); in main()
804 sha512_finish_ctx (&ctx, sum); in main()