Lines Matching +full:sha +full:- +full:512

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * SHA-3, as specified in
8 * SHA-3 code by Jeff Garzik <jeff@garzik.org>
19 * On some 32-bit architectures (h8300), GCC ends up using
21 * in keccakf(). On the other hand, on 64-bit architectures with plenty
22 * of [64-bit wide] general purpose registers, not inlining it severely
23 * hurts performance. So let's use 64-bitness as a heuristic to decide
164 unsigned int digest_size = crypto_shash_digestsize(desc->tfm); in crypto_sha3_init()
166 sctx->rsiz = 200 - 2 * digest_size; in crypto_sha3_init()
167 sctx->rsizw = sctx->rsiz / 8; in crypto_sha3_init()
168 sctx->partial = 0; in crypto_sha3_init()
170 memset(sctx->st, 0, sizeof(sctx->st)); in crypto_sha3_init()
185 if ((sctx->partial + len) > (sctx->rsiz - 1)) { in crypto_sha3_update()
186 if (sctx->partial) { in crypto_sha3_update()
187 done = -sctx->partial; in crypto_sha3_update()
188 memcpy(sctx->buf + sctx->partial, data, in crypto_sha3_update()
189 done + sctx->rsiz); in crypto_sha3_update()
190 src = sctx->buf; in crypto_sha3_update()
196 for (i = 0; i < sctx->rsizw; i++) in crypto_sha3_update()
197 sctx->st[i] ^= get_unaligned_le64(src + 8 * i); in crypto_sha3_update()
198 keccakf(sctx->st); in crypto_sha3_update()
200 done += sctx->rsiz; in crypto_sha3_update()
202 } while (done + (sctx->rsiz - 1) < len); in crypto_sha3_update()
204 sctx->partial = 0; in crypto_sha3_update()
206 memcpy(sctx->buf + sctx->partial, src, len - done); in crypto_sha3_update()
207 sctx->partial += (len - done); in crypto_sha3_update()
216 unsigned int i, inlen = sctx->partial; in crypto_sha3_final()
217 unsigned int digest_size = crypto_shash_digestsize(desc->tfm); in crypto_sha3_final()
220 sctx->buf[inlen++] = 0x06; in crypto_sha3_final()
221 memset(sctx->buf + inlen, 0, sctx->rsiz - inlen); in crypto_sha3_final()
222 sctx->buf[sctx->rsiz - 1] |= 0x80; in crypto_sha3_final()
224 for (i = 0; i < sctx->rsizw; i++) in crypto_sha3_final()
225 sctx->st[i] ^= get_unaligned_le64(sctx->buf + 8 * i); in crypto_sha3_final()
227 keccakf(sctx->st); in crypto_sha3_final()
230 put_unaligned_le64(sctx->st[i], digest++); in crypto_sha3_final()
233 put_unaligned_le32(sctx->st[i], (__le32 *)digest); in crypto_sha3_final()
246 .base.cra_name = "sha3-224",
247 .base.cra_driver_name = "sha3-224-generic",
256 .base.cra_name = "sha3-256",
257 .base.cra_driver_name = "sha3-256-generic",
266 .base.cra_name = "sha3-384",
267 .base.cra_driver_name = "sha3-384-generic",
276 .base.cra_name = "sha3-512",
277 .base.cra_driver_name = "sha3-512-generic",
296 MODULE_DESCRIPTION("SHA-3 Secure Hash Algorithm");
298 MODULE_ALIAS_CRYPTO("sha3-224");
299 MODULE_ALIAS_CRYPTO("sha3-224-generic");
300 MODULE_ALIAS_CRYPTO("sha3-256");
301 MODULE_ALIAS_CRYPTO("sha3-256-generic");
302 MODULE_ALIAS_CRYPTO("sha3-384");
303 MODULE_ALIAS_CRYPTO("sha3-384-generic");
304 MODULE_ALIAS_CRYPTO("sha3-512");
305 MODULE_ALIAS_CRYPTO("sha3-512-generic");