Lines Matching +full:sha +full:- +full:256
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * sha256_base.h - core logic for SHA-256 implementations
12 #include <crypto/sha.h>
43 unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; in sha256_base_do_update()
45 sctx->count += len; in sha256_base_do_update()
51 int p = SHA256_BLOCK_SIZE - partial; in sha256_base_do_update()
53 memcpy(sctx->buf + partial, data, p); in sha256_base_do_update()
55 len -= p; in sha256_base_do_update()
57 block_fn(sctx, sctx->buf, 1); in sha256_base_do_update()
70 memcpy(sctx->buf + partial, data, len); in sha256_base_do_update()
78 const int bit_offset = SHA256_BLOCK_SIZE - sizeof(__be64); in sha256_base_do_finalize()
80 __be64 *bits = (__be64 *)(sctx->buf + bit_offset); in sha256_base_do_finalize()
81 unsigned int partial = sctx->count % SHA256_BLOCK_SIZE; in sha256_base_do_finalize()
83 sctx->buf[partial++] = 0x80; in sha256_base_do_finalize()
85 memset(sctx->buf + partial, 0x0, SHA256_BLOCK_SIZE - partial); in sha256_base_do_finalize()
88 block_fn(sctx, sctx->buf, 1); in sha256_base_do_finalize()
91 memset(sctx->buf + partial, 0x0, bit_offset - partial); in sha256_base_do_finalize()
92 *bits = cpu_to_be64(sctx->count << 3); in sha256_base_do_finalize()
93 block_fn(sctx, sctx->buf, 1); in sha256_base_do_finalize()
100 unsigned int digest_size = crypto_shash_digestsize(desc->tfm); in sha256_base_finish()
105 for (i = 0; digest_size > 0; i++, digest_size -= sizeof(__be32)) in sha256_base_finish()
106 put_unaligned_be32(sctx->state[i], digest++); in sha256_base_finish()