Lines Matching refs:ctx
138 sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_block() argument
141 uint64_t a = ctx->H[0]; in sha512_process_block()
142 uint64_t b = ctx->H[1]; in sha512_process_block()
143 uint64_t c = ctx->H[2]; in sha512_process_block()
144 uint64_t d = ctx->H[3]; in sha512_process_block()
145 uint64_t e = ctx->H[4]; in sha512_process_block()
146 uint64_t f = ctx->H[5]; in sha512_process_block()
147 uint64_t g = ctx->H[6]; in sha512_process_block()
148 uint64_t h = ctx->H[7]; in sha512_process_block()
153 ctx->total[0] += len; in sha512_process_block()
154 if (ctx->total[0] < len) { in sha512_process_block()
155 ++ctx->total[1]; in sha512_process_block()
224 ctx->H[0] = a; in sha512_process_block()
225 ctx->H[1] = b; in sha512_process_block()
226 ctx->H[2] = c; in sha512_process_block()
227 ctx->H[3] = d; in sha512_process_block()
228 ctx->H[4] = e; in sha512_process_block()
229 ctx->H[5] = f; in sha512_process_block()
230 ctx->H[6] = g; in sha512_process_block()
231 ctx->H[7] = h; in sha512_process_block()
237 static void sha512_init_ctx (struct sha512_ctx *ctx) { in sha512_init_ctx() argument
238 ctx->H[0] = UINT64_C (0x6a09e667f3bcc908); in sha512_init_ctx()
239 ctx->H[1] = UINT64_C (0xbb67ae8584caa73b); in sha512_init_ctx()
240 ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b); in sha512_init_ctx()
241 ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1); in sha512_init_ctx()
242 ctx->H[4] = UINT64_C (0x510e527fade682d1); in sha512_init_ctx()
243 ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f); in sha512_init_ctx()
244 ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b); in sha512_init_ctx()
245 ctx->H[7] = UINT64_C (0x5be0cd19137e2179); in sha512_init_ctx()
247 ctx->total[0] = ctx->total[1] = 0; in sha512_init_ctx()
248 ctx->buflen = 0; in sha512_init_ctx()
257 static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) { in sha512_finish_ctx() argument
259 uint64_t bytes = ctx->buflen; in sha512_finish_ctx()
264 ctx->total[0] += bytes; in sha512_finish_ctx()
265 if (ctx->total[0] < bytes) { in sha512_finish_ctx()
266 ++ctx->total[1]; in sha512_finish_ctx()
270 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha512_finish_ctx()
273 *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3); in sha512_finish_ctx()
274 *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) | in sha512_finish_ctx()
275 (ctx->total[0] >> 61)); in sha512_finish_ctx()
278 sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx); in sha512_finish_ctx()
282 ((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha512_finish_ctx()
289 sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_bytes() argument
292 if (ctx->buflen != 0) { in sha512_process_bytes()
293 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
296 memcpy(&ctx->buffer[left_over], buffer, add); in sha512_process_bytes()
297 ctx->buflen += add; in sha512_process_bytes()
299 if (ctx->buflen > 128) { in sha512_process_bytes()
300 sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx); in sha512_process_bytes()
302 ctx->buflen &= 127; in sha512_process_bytes()
304 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127], in sha512_process_bytes()
305 (size_t)ctx->buflen); in sha512_process_bytes()
324 sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx); in sha512_process_bytes()
331 sha512_process_block(buffer, len & ~127, ctx); in sha512_process_bytes()
339 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
341 memcpy(&ctx->buffer[left_over], buffer, len); in sha512_process_bytes()
344 sha512_process_block(ctx->buffer, 128, ctx); in sha512_process_bytes()
346 memcpy(ctx->buffer, &ctx->buffer[128], left_over); in sha512_process_bytes()
348 ctx->buflen = left_over; in sha512_process_bytes()
390 struct sha512_ctx ctx; in php_sha512_crypt_r() local
439 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
442 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
447 sha512_process_bytes(salt, salt_len, &ctx); in php_sha512_crypt_r()
469 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
471 sha512_process_bytes(alt_result, cnt, &ctx); in php_sha512_crypt_r()
477 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
479 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
484 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
527 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
531 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
533 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
538 sha512_process_bytes(s_bytes, salt_len, &ctx); in php_sha512_crypt_r()
543 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
548 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
550 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
554 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
626 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
627 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
631 memset(&ctx, '\0', sizeof(ctx)); in php_sha512_crypt_r()
766 struct sha512_ctx ctx; in main() local
779 sha512_init_ctx (&ctx); in main()
780 sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx); in main()
781 sha512_finish_ctx (&ctx, sum); in main()
787 sha512_init_ctx (&ctx); in main()
789 sha512_process_bytes (&tests[cnt].input[i], 1, &ctx); in main()
791 sha512_finish_ctx (&ctx, sum); in main()
801 sha512_init_ctx (&ctx); in main()
803 sha512_process_bytes (buf, sizeof (buf), &ctx); in main()
806 sha512_finish_ctx (&ctx, sum); in main()