Lines Matching refs:ctx

132 sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) {  in sha512_process_block()  argument
135 uint64_t a = ctx->H[0]; in sha512_process_block()
136 uint64_t b = ctx->H[1]; in sha512_process_block()
137 uint64_t c = ctx->H[2]; in sha512_process_block()
138 uint64_t d = ctx->H[3]; in sha512_process_block()
139 uint64_t e = ctx->H[4]; in sha512_process_block()
140 uint64_t f = ctx->H[5]; in sha512_process_block()
141 uint64_t g = ctx->H[6]; in sha512_process_block()
142 uint64_t h = ctx->H[7]; in sha512_process_block()
147 ctx->total[0] += len; in sha512_process_block()
148 if (ctx->total[0] < len) { in sha512_process_block()
149 ++ctx->total[1]; in sha512_process_block()
218 ctx->H[0] = a; in sha512_process_block()
219 ctx->H[1] = b; in sha512_process_block()
220 ctx->H[2] = c; in sha512_process_block()
221 ctx->H[3] = d; in sha512_process_block()
222 ctx->H[4] = e; in sha512_process_block()
223 ctx->H[5] = f; in sha512_process_block()
224 ctx->H[6] = g; in sha512_process_block()
225 ctx->H[7] = h; in sha512_process_block()
231 static void sha512_init_ctx (struct sha512_ctx *ctx) { in sha512_init_ctx() argument
232 ctx->H[0] = UINT64_C (0x6a09e667f3bcc908); in sha512_init_ctx()
233 ctx->H[1] = UINT64_C (0xbb67ae8584caa73b); in sha512_init_ctx()
234 ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b); in sha512_init_ctx()
235 ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1); in sha512_init_ctx()
236 ctx->H[4] = UINT64_C (0x510e527fade682d1); in sha512_init_ctx()
237 ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f); in sha512_init_ctx()
238 ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b); in sha512_init_ctx()
239 ctx->H[7] = UINT64_C (0x5be0cd19137e2179); in sha512_init_ctx()
241 ctx->total[0] = ctx->total[1] = 0; in sha512_init_ctx()
242 ctx->buflen = 0; in sha512_init_ctx()
251 static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) { in sha512_finish_ctx() argument
253 uint64_t bytes = ctx->buflen; in sha512_finish_ctx()
258 ctx->total[0] += bytes; in sha512_finish_ctx()
259 if (ctx->total[0] < bytes) { in sha512_finish_ctx()
260 ++ctx->total[1]; in sha512_finish_ctx()
264 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha512_finish_ctx()
267 *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3); in sha512_finish_ctx()
268 *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) | in sha512_finish_ctx()
269 (ctx->total[0] >> 61)); in sha512_finish_ctx()
272 sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx); in sha512_finish_ctx()
276 ((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha512_finish_ctx()
283 sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_bytes() argument
286 if (ctx->buflen != 0) { in sha512_process_bytes()
287 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
290 memcpy(&ctx->buffer[left_over], buffer, add); in sha512_process_bytes()
291 ctx->buflen += add; in sha512_process_bytes()
293 if (ctx->buflen > 128) { in sha512_process_bytes()
294 sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx); in sha512_process_bytes()
296 ctx->buflen &= 127; in sha512_process_bytes()
298 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127], in sha512_process_bytes()
299 (size_t)ctx->buflen); in sha512_process_bytes()
318 sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx); in sha512_process_bytes()
325 sha512_process_block(buffer, len & ~127, ctx); in sha512_process_bytes()
333 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
335 memcpy(&ctx->buffer[left_over], buffer, len); in sha512_process_bytes()
338 sha512_process_block(ctx->buffer, 128, ctx); in sha512_process_bytes()
340 memcpy(ctx->buffer, &ctx->buffer[128], left_over); in sha512_process_bytes()
342 ctx->buflen = left_over; in sha512_process_bytes()
384 struct sha512_ctx ctx; in php_sha512_crypt_r() local
433 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
436 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
441 sha512_process_bytes(salt, salt_len, &ctx); in php_sha512_crypt_r()
463 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
465 sha512_process_bytes(alt_result, cnt, &ctx); in php_sha512_crypt_r()
471 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
473 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
478 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
521 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
525 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
527 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
532 sha512_process_bytes(s_bytes, salt_len, &ctx); in php_sha512_crypt_r()
537 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
542 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
544 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
548 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
620 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
621 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
625 memset(&ctx, '\0', sizeof(ctx)); in php_sha512_crypt_r()
760 struct sha512_ctx ctx; in main() local
773 sha512_init_ctx (&ctx); in main()
774 sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx); in main()
775 sha512_finish_ctx (&ctx, sum); in main()
781 sha512_init_ctx (&ctx); in main()
783 sha512_process_bytes (&tests[cnt].input[i], 1, &ctx); in main()
785 sha512_finish_ctx (&ctx, sum); in main()
795 sha512_init_ctx (&ctx); in main()
797 sha512_process_bytes (buf, sizeof (buf), &ctx); in main()
800 sha512_finish_ctx (&ctx, sum); in main()