Lines Matching refs:ctx
226 ctx->wbuf[i & 15] += \
227 g256_1(ctx->wbuf[(i + 14) & 15]) + ctx->wbuf[(i + 9) & 15] + \
228 g256_0(ctx->wbuf[(i + 1) & 15])
232 (j ? h2(i) : ctx->wbuf[i & 15]) + k256[i + j] + s256_1(v[(4 - i) & 7]) + \
266 void sha256_begin(sha256_ctx ctx[1]) in sha256_begin()
268 ctx->count[0] = ctx->count[1] = 0; in sha256_begin()
269 memcpy(ctx->hash, i256, 8 * sizeof(sha2_32t)); in sha256_begin()
279 void sha256_compile(sha256_ctx ctx[1]) in sha256_compile()
283 memcpy(v, ctx->hash, 8 * sizeof(sha2_32t)); in sha256_compile()
304 ctx->hash[0] += v[0]; in sha256_compile()
305 ctx->hash[1] += v[1]; in sha256_compile()
306 ctx->hash[2] += v[2]; in sha256_compile()
307 ctx->hash[3] += v[3]; in sha256_compile()
308 ctx->hash[4] += v[4]; in sha256_compile()
309 ctx->hash[5] += v[5]; in sha256_compile()
310 ctx->hash[6] += v[6]; in sha256_compile()
311 ctx->hash[7] += v[7]; in sha256_compile()
317 void sha256_hash(sha256_ctx ctx[1], const unsigned char data[], in sha256_hash()
320 sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA256_MASK), in sha256_hash()
324 if ((ctx->count[0] += len) < len) in sha256_hash()
325 ++(ctx->count[1]); in sha256_hash()
328 memcpy(((unsigned char *)ctx->wbuf) + pos, sp, space); in sha256_hash()
333 bsw_32(ctx->wbuf, SHA256_BLOCK_SIZE >> 2); in sha256_hash()
334 sha256_compile(ctx); in sha256_hash()
337 memcpy(((unsigned char *)ctx->wbuf) + pos, sp, len); in sha256_hash()
350 void sha256_end(sha256_ctx ctx[1], unsigned char hval[]) in sha256_end()
352 sha2_32t i = (sha2_32t)(ctx->count[0] & SHA256_MASK); in sha256_end()
354 bsw_32(ctx->wbuf, (i + 3) >> 2) in sha256_end()
361 ctx->wbuf[i >> 2] = (ctx->wbuf[i >> 2] & m1[i & 3]) | b1[i & 3]; in sha256_end()
368 ctx->wbuf[15] = 0; in sha256_end()
369 sha256_compile(ctx); in sha256_end()
375 ctx->wbuf[i++] = 0; in sha256_end()
382 ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 29); in sha256_end()
383 ctx->wbuf[15] = ctx->count[0] << 3; in sha256_end()
385 sha256_compile(ctx); in sha256_end()
390 hval[i] = (unsigned char)(ctx->hash[i >> 2] >> 8 * (~i & 3)); in sha256_end()
440 ctx->wbuf[i & 15] += \
441 g512_1(ctx->wbuf[(i + 14) & 15]) + ctx->wbuf[(i + 9) & 15] + \
442 g512_0(ctx->wbuf[(i + 1) & 15])
446 (j ? h5(i) : ctx->wbuf[i & 15]) + k512[i + j] + s512_1(v[(4 - i) & 7]) + \
486 void sha512_compile(sha512_ctx ctx[1]) in sha512_compile()
491 memcpy(v, ctx->hash, 8 * sizeof(sha2_64t)); in sha512_compile()
512 ctx->hash[0] += v[0]; in sha512_compile()
513 ctx->hash[1] += v[1]; in sha512_compile()
514 ctx->hash[2] += v[2]; in sha512_compile()
515 ctx->hash[3] += v[3]; in sha512_compile()
516 ctx->hash[4] += v[4]; in sha512_compile()
517 ctx->hash[5] += v[5]; in sha512_compile()
518 ctx->hash[6] += v[6]; in sha512_compile()
519 ctx->hash[7] += v[7]; in sha512_compile()
529 void sha512_hash(sha512_ctx ctx[1], const unsigned char data[], in sha512_hash()
532 sha2_32t pos = (sha2_32t)(ctx->count[0] & SHA512_MASK), in sha512_hash()
536 if ((ctx->count[0] += len) < len) in sha512_hash()
537 ++(ctx->count[1]); in sha512_hash()
540 memcpy(((unsigned char *)ctx->wbuf) + pos, sp, space); in sha512_hash()
545 bsw_64(ctx->wbuf, SHA512_BLOCK_SIZE >> 3); in sha512_hash()
546 sha512_compile(ctx); in sha512_hash()
549 memcpy(((unsigned char *)ctx->wbuf) + pos, sp, len); in sha512_hash()
566 static void sha_end(sha512_ctx ctx[1], unsigned char hval[], in sha_end()
569 sha2_32t i = (sha2_32t)(ctx->count[0] & SHA512_MASK); in sha_end()
571 bsw_64(ctx->wbuf, (i + 7) >> 3); in sha_end()
579 ctx->wbuf[i >> 3] = (ctx->wbuf[i >> 3] & m2[i & 7]) | b2[i & 7]; in sha_end()
586 ctx->wbuf[15] = 0; in sha_end()
587 sha512_compile(ctx); in sha_end()
593 ctx->wbuf[i++] = 0; in sha_end()
600 ctx->wbuf[14] = (ctx->count[1] << 3) | (ctx->count[0] >> 61); in sha_end()
601 ctx->wbuf[15] = ctx->count[0] << 3; in sha_end()
603 sha512_compile(ctx); in sha_end()
608 hval[i] = (unsigned char)(ctx->hash[i >> 3] >> 8 * (~i & 7)); in sha_end()
623 void sha384_begin(sha384_ctx ctx[1]) in sha384_begin()
625 ctx->count[0] = ctx->count[1] = 0; in sha384_begin()
626 memcpy(ctx->hash, i384, 8 * sizeof(sha2_64t)); in sha384_begin()
629 void sha384_end(sha384_ctx ctx[1], unsigned char hval[]) in sha384_end()
631 sha_end(ctx, hval, SHA384_DIGEST_SIZE); in sha384_end()
656 void sha512_begin(sha512_ctx ctx[1]) in sha512_begin()
658 ctx->count[0] = ctx->count[1] = 0; in sha512_begin()
659 memcpy(ctx->hash, i512, 8 * sizeof(sha2_64t)); in sha512_begin()
662 void sha512_end(sha512_ctx ctx[1], unsigned char hval[]) in sha512_end()
664 sha_end(ctx, hval, SHA512_DIGEST_SIZE); in sha512_end()
687 int sha2_begin(sha2_ctx ctx[1], unsigned long len) in sha2_begin()
694 CTX_256(ctx)->count[0] = CTX_256(ctx)->count[1] = 0; in sha2_begin()
695 memcpy(CTX_256(ctx)->hash, i256, 32); in sha2_begin()
700 CTX_384(ctx)->count[0] = CTX_384(ctx)->count[1] = 0; in sha2_begin()
701 memcpy(CTX_384(ctx)->hash, i384, 64); in sha2_begin()
706 CTX_512(ctx)->count[0] = CTX_512(ctx)->count[1] = 0; in sha2_begin()
707 memcpy(CTX_512(ctx)->hash, i512, 64); in sha2_begin()
713 ctx->sha2_len = l; in sha2_begin()
717 void sha2_hash(sha2_ctx ctx[1], const unsigned char data[], unsigned long len) in sha2_hash()
719 switch (ctx->sha2_len) { in sha2_hash()
721 sha256_hash(CTX_256(ctx), data, len); in sha2_hash()
724 sha384_hash(CTX_384(ctx), data, len); in sha2_hash()
727 sha512_hash(CTX_512(ctx), data, len); in sha2_hash()
732 void sha2_end(sha2_ctx ctx[1], unsigned char hval[]) in sha2_end()
734 switch (ctx->sha2_len) { in sha2_end()
736 sha256_end(CTX_256(ctx), hval); in sha2_end()
739 sha_end(CTX_384(ctx), hval, SHA384_DIGEST_SIZE); in sha2_end()
742 sha_end(CTX_512(ctx), hval, SHA512_DIGEST_SIZE); in sha2_end()