Lines Matching refs:ctx

123 sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) {  in sha512_process_block()  argument
126 uint64_t a = ctx->H[0]; in sha512_process_block()
127 uint64_t b = ctx->H[1]; in sha512_process_block()
128 uint64_t c = ctx->H[2]; in sha512_process_block()
129 uint64_t d = ctx->H[3]; in sha512_process_block()
130 uint64_t e = ctx->H[4]; in sha512_process_block()
131 uint64_t f = ctx->H[5]; in sha512_process_block()
132 uint64_t g = ctx->H[6]; in sha512_process_block()
133 uint64_t h = ctx->H[7]; in sha512_process_block()
138 ctx->total[0] += len; in sha512_process_block()
139 if (ctx->total[0] < len) { in sha512_process_block()
140 ++ctx->total[1]; in sha512_process_block()
209 ctx->H[0] = a; in sha512_process_block()
210 ctx->H[1] = b; in sha512_process_block()
211 ctx->H[2] = c; in sha512_process_block()
212 ctx->H[3] = d; in sha512_process_block()
213 ctx->H[4] = e; in sha512_process_block()
214 ctx->H[5] = f; in sha512_process_block()
215 ctx->H[6] = g; in sha512_process_block()
216 ctx->H[7] = h; in sha512_process_block()
222 static void sha512_init_ctx (struct sha512_ctx *ctx) { in sha512_init_ctx() argument
223 ctx->H[0] = UINT64_C (0x6a09e667f3bcc908); in sha512_init_ctx()
224 ctx->H[1] = UINT64_C (0xbb67ae8584caa73b); in sha512_init_ctx()
225 ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b); in sha512_init_ctx()
226 ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1); in sha512_init_ctx()
227 ctx->H[4] = UINT64_C (0x510e527fade682d1); in sha512_init_ctx()
228 ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f); in sha512_init_ctx()
229 ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b); in sha512_init_ctx()
230 ctx->H[7] = UINT64_C (0x5be0cd19137e2179); in sha512_init_ctx()
232 ctx->total[0] = ctx->total[1] = 0; in sha512_init_ctx()
233 ctx->buflen = 0; in sha512_init_ctx()
242 static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) { in sha512_finish_ctx() argument
244 uint64_t bytes = ctx->buflen; in sha512_finish_ctx()
249 ctx->total[0] += bytes; in sha512_finish_ctx()
250 if (ctx->total[0] < bytes) { in sha512_finish_ctx()
251 ++ctx->total[1]; in sha512_finish_ctx()
255 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha512_finish_ctx()
258 *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3); in sha512_finish_ctx()
259 *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) | in sha512_finish_ctx()
260 (ctx->total[0] >> 61)); in sha512_finish_ctx()
263 sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx); in sha512_finish_ctx()
267 ((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha512_finish_ctx()
274 sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_bytes() argument
277 if (ctx->buflen != 0) { in sha512_process_bytes()
278 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
281 memcpy(&ctx->buffer[left_over], buffer, add); in sha512_process_bytes()
282 ctx->buflen += add; in sha512_process_bytes()
284 if (ctx->buflen > 128) { in sha512_process_bytes()
285 sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx); in sha512_process_bytes()
287 ctx->buflen &= 127; in sha512_process_bytes()
289 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127], in sha512_process_bytes()
290 (size_t)ctx->buflen); in sha512_process_bytes()
309 sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx); in sha512_process_bytes()
316 sha512_process_block(buffer, len & ~127, ctx); in sha512_process_bytes()
324 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
326 memcpy(&ctx->buffer[left_over], buffer, len); in sha512_process_bytes()
329 sha512_process_block(ctx->buffer, 128, ctx); in sha512_process_bytes()
331 memcpy(ctx->buffer, &ctx->buffer[128], left_over); in sha512_process_bytes()
333 ctx->buflen = left_over; in sha512_process_bytes()
368 struct sha512_ctx ctx; in php_sha512_crypt_r() local
417 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
420 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
425 sha512_process_bytes(salt, salt_len, &ctx); in php_sha512_crypt_r()
447 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
449 sha512_process_bytes(alt_result, cnt, &ctx); in php_sha512_crypt_r()
455 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
457 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
462 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
505 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
509 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
511 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
516 sha512_process_bytes(s_bytes, salt_len, &ctx); in php_sha512_crypt_r()
521 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
526 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
528 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
532 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
604 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
605 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
609 ZEND_SECURE_ZERO(&ctx, sizeof(ctx)); in php_sha512_crypt_r()
744 struct sha512_ctx ctx; in main() local
757 sha512_init_ctx (&ctx); in main()
758 sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx); in main()
759 sha512_finish_ctx (&ctx, sum); in main()
765 sha512_init_ctx (&ctx); in main()
767 sha512_process_bytes (&tests[cnt].input[i], 1, &ctx); in main()
769 sha512_finish_ctx (&ctx, sum); in main()
779 sha512_init_ctx (&ctx); in main()
781 sha512_process_bytes (buf, sizeof (buf), &ctx); in main()
784 sha512_finish_ctx (&ctx, sum); in main()