Lines Matching refs:ctx

121 sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) {  in sha512_process_block()  argument
124 uint64_t a = ctx->H[0]; in sha512_process_block()
125 uint64_t b = ctx->H[1]; in sha512_process_block()
126 uint64_t c = ctx->H[2]; in sha512_process_block()
127 uint64_t d = ctx->H[3]; in sha512_process_block()
128 uint64_t e = ctx->H[4]; in sha512_process_block()
129 uint64_t f = ctx->H[5]; in sha512_process_block()
130 uint64_t g = ctx->H[6]; in sha512_process_block()
131 uint64_t h = ctx->H[7]; in sha512_process_block()
136 ctx->total[0] += len; in sha512_process_block()
137 if (ctx->total[0] < len) { in sha512_process_block()
138 ++ctx->total[1]; in sha512_process_block()
207 ctx->H[0] = a; in sha512_process_block()
208 ctx->H[1] = b; in sha512_process_block()
209 ctx->H[2] = c; in sha512_process_block()
210 ctx->H[3] = d; in sha512_process_block()
211 ctx->H[4] = e; in sha512_process_block()
212 ctx->H[5] = f; in sha512_process_block()
213 ctx->H[6] = g; in sha512_process_block()
214 ctx->H[7] = h; in sha512_process_block()
220 static void sha512_init_ctx (struct sha512_ctx *ctx) { in sha512_init_ctx() argument
221 ctx->H[0] = UINT64_C (0x6a09e667f3bcc908); in sha512_init_ctx()
222 ctx->H[1] = UINT64_C (0xbb67ae8584caa73b); in sha512_init_ctx()
223 ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b); in sha512_init_ctx()
224 ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1); in sha512_init_ctx()
225 ctx->H[4] = UINT64_C (0x510e527fade682d1); in sha512_init_ctx()
226 ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f); in sha512_init_ctx()
227 ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b); in sha512_init_ctx()
228 ctx->H[7] = UINT64_C (0x5be0cd19137e2179); in sha512_init_ctx()
230 ctx->total[0] = ctx->total[1] = 0; in sha512_init_ctx()
231 ctx->buflen = 0; in sha512_init_ctx()
240 static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) { in sha512_finish_ctx() argument
242 uint64_t bytes = ctx->buflen; in sha512_finish_ctx()
247 ctx->total[0] += bytes; in sha512_finish_ctx()
248 if (ctx->total[0] < bytes) { in sha512_finish_ctx()
249 ++ctx->total[1]; in sha512_finish_ctx()
253 memcpy(&ctx->buffer[bytes], fillbuf, pad); in sha512_finish_ctx()
256 *(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3); in sha512_finish_ctx()
257 *(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) | in sha512_finish_ctx()
258 (ctx->total[0] >> 61)); in sha512_finish_ctx()
261 sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx); in sha512_finish_ctx()
265 ((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]); in sha512_finish_ctx()
272 sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) { in sha512_process_bytes() argument
275 if (ctx->buflen != 0) { in sha512_process_bytes()
276 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
279 memcpy(&ctx->buffer[left_over], buffer, add); in sha512_process_bytes()
280 ctx->buflen += add; in sha512_process_bytes()
282 if (ctx->buflen > 128) { in sha512_process_bytes()
283 sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx); in sha512_process_bytes()
285 ctx->buflen &= 127; in sha512_process_bytes()
287 memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127], in sha512_process_bytes()
288 (size_t)ctx->buflen); in sha512_process_bytes()
307 sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx); in sha512_process_bytes()
314 sha512_process_block(buffer, len & ~127, ctx); in sha512_process_bytes()
322 size_t left_over = (size_t)ctx->buflen; in sha512_process_bytes()
324 memcpy(&ctx->buffer[left_over], buffer, len); in sha512_process_bytes()
327 sha512_process_block(ctx->buffer, 128, ctx); in sha512_process_bytes()
329 memcpy(ctx->buffer, &ctx->buffer[128], left_over); in sha512_process_bytes()
331 ctx->buflen = left_over; in sha512_process_bytes()
366 struct sha512_ctx ctx; in php_sha512_crypt_r() local
426 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
429 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
434 sha512_process_bytes(salt, salt_len, &ctx); in php_sha512_crypt_r()
456 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
458 sha512_process_bytes(alt_result, cnt, &ctx); in php_sha512_crypt_r()
464 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
466 sha512_process_bytes(key, key_len, &ctx); in php_sha512_crypt_r()
471 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
516 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
520 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
522 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
527 sha512_process_bytes(s_bytes, salt_len, &ctx); in php_sha512_crypt_r()
532 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
537 sha512_process_bytes(alt_result, 64, &ctx); in php_sha512_crypt_r()
539 sha512_process_bytes(p_bytes, key_len, &ctx); in php_sha512_crypt_r()
543 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
615 sha512_init_ctx(&ctx); in php_sha512_crypt_r()
616 sha512_finish_ctx(&ctx, alt_result); in php_sha512_crypt_r()
620 ZEND_SECURE_ZERO(&ctx, sizeof(ctx)); in php_sha512_crypt_r()
763 struct sha512_ctx ctx; in main() local
776 sha512_init_ctx (&ctx); in main()
777 sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx); in main()
778 sha512_finish_ctx (&ctx, sum); in main()
784 sha512_init_ctx (&ctx); in main()
786 sha512_process_bytes (&tests[cnt].input[i], 1, &ctx); in main()
788 sha512_finish_ctx (&ctx, sum); in main()
798 sha512_init_ctx (&ctx); in main()
800 sha512_process_bytes (buf, sizeof (buf), &ctx); in main()
803 sha512_finish_ctx (&ctx, sum); in main()