| .. | .. |
|---|
| 14 | 14 | #include <asm/simd.h> |
|---|
| 15 | 15 | #include <asm/unaligned.h> |
|---|
| 16 | 16 | #include <crypto/internal/hash.h> |
|---|
| 17 | +#include <crypto/internal/simd.h> |
|---|
| 17 | 18 | #include <crypto/sha3.h> |
|---|
| 18 | 19 | #include <linux/cpufeature.h> |
|---|
| 19 | 20 | #include <linux/crypto.h> |
|---|
| .. | .. |
|---|
| 27 | 28 | MODULE_ALIAS_CRYPTO("sha3-384"); |
|---|
| 28 | 29 | MODULE_ALIAS_CRYPTO("sha3-512"); |
|---|
| 29 | 30 | |
|---|
| 30 | | -asmlinkage void sha3_ce_transform(u64 *st, const u8 *data, int blocks, |
|---|
| 31 | | - int md_len); |
|---|
| 31 | +asmlinkage int sha3_ce_transform(u64 *st, const u8 *data, int blocks, |
|---|
| 32 | + int md_len); |
|---|
| 32 | 33 | |
|---|
| 33 | 34 | static int sha3_update(struct shash_desc *desc, const u8 *data, |
|---|
| 34 | 35 | unsigned int len) |
|---|
| .. | .. |
|---|
| 36 | 37 | struct sha3_state *sctx = shash_desc_ctx(desc); |
|---|
| 37 | 38 | unsigned int digest_size = crypto_shash_digestsize(desc->tfm); |
|---|
| 38 | 39 | |
|---|
| 39 | | - if (!may_use_simd()) |
|---|
| 40 | + if (!crypto_simd_usable()) |
|---|
| 40 | 41 | return crypto_sha3_update(desc, data, len); |
|---|
| 41 | 42 | |
|---|
| 42 | 43 | if ((sctx->partial + len) >= sctx->rsiz) { |
|---|
| .. | .. |
|---|
| 58 | 59 | blocks = len / sctx->rsiz; |
|---|
| 59 | 60 | len %= sctx->rsiz; |
|---|
| 60 | 61 | |
|---|
| 61 | | - if (blocks) { |
|---|
| 62 | + while (blocks) { |
|---|
| 63 | + int rem; |
|---|
| 64 | + |
|---|
| 62 | 65 | kernel_neon_begin(); |
|---|
| 63 | | - sha3_ce_transform(sctx->st, data, blocks, digest_size); |
|---|
| 66 | + rem = sha3_ce_transform(sctx->st, data, blocks, |
|---|
| 67 | + digest_size); |
|---|
| 64 | 68 | kernel_neon_end(); |
|---|
| 65 | | - data += blocks * sctx->rsiz; |
|---|
| 69 | + data += (blocks - rem) * sctx->rsiz; |
|---|
| 70 | + blocks = rem; |
|---|
| 66 | 71 | } |
|---|
| 67 | 72 | } |
|---|
| 68 | 73 | |
|---|
| .. | .. |
|---|
| 80 | 85 | __le64 *digest = (__le64 *)out; |
|---|
| 81 | 86 | int i; |
|---|
| 82 | 87 | |
|---|
| 83 | | - if (!may_use_simd()) |
|---|
| 88 | + if (!crypto_simd_usable()) |
|---|
| 84 | 89 | return crypto_sha3_final(desc, out); |
|---|
| 85 | 90 | |
|---|
| 86 | 91 | sctx->buf[sctx->partial++] = 0x06; |
|---|