forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/arch/arm/crypto/sha256_neon_glue.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Glue code for the SHA256 Secure Hash Algorithm assembly implementation
34 * using NEON instructions.
....@@ -6,16 +7,10 @@
67 *
78 * This file is based on sha512_neon_glue.c:
89 * Copyright © 2014 Jussi Kivilinna <jussi.kivilinna@iki.fi>
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License as published by the Free
12
- * Software Foundation; either version 2 of the License, or (at your option)
13
- * any later version.
14
- *
1510 */
1611
1712 #include <crypto/internal/hash.h>
18
-#include <linux/cryptohash.h>
13
+#include <crypto/internal/simd.h>
1914 #include <linux/types.h>
2015 #include <linux/string.h>
2116 #include <crypto/sha.h>
....@@ -29,12 +24,12 @@
2924 asmlinkage void sha256_block_data_order_neon(u32 *digest, const void *data,
3025 unsigned int num_blks);
3126
32
-static int sha256_update(struct shash_desc *desc, const u8 *data,
33
- unsigned int len)
27
+static int crypto_sha256_neon_update(struct shash_desc *desc, const u8 *data,
28
+ unsigned int len)
3429 {
3530 struct sha256_state *sctx = shash_desc_ctx(desc);
3631
37
- if (!may_use_simd() ||
32
+ if (!crypto_simd_usable() ||
3833 (sctx->count % SHA256_BLOCK_SIZE) + len < SHA256_BLOCK_SIZE)
3934 return crypto_sha256_arm_update(desc, data, len);
4035
....@@ -46,10 +41,10 @@
4641 return 0;
4742 }
4843
49
-static int sha256_finup(struct shash_desc *desc, const u8 *data,
50
- unsigned int len, u8 *out)
44
+static int crypto_sha256_neon_finup(struct shash_desc *desc, const u8 *data,
45
+ unsigned int len, u8 *out)
5146 {
52
- if (!may_use_simd())
47
+ if (!crypto_simd_usable())
5348 return crypto_sha256_arm_finup(desc, data, len, out);
5449
5550 kernel_neon_begin();
....@@ -63,17 +58,17 @@
6358 return sha256_base_finish(desc, out);
6459 }
6560
66
-static int sha256_final(struct shash_desc *desc, u8 *out)
61
+static int crypto_sha256_neon_final(struct shash_desc *desc, u8 *out)
6762 {
68
- return sha256_finup(desc, NULL, 0, out);
63
+ return crypto_sha256_neon_finup(desc, NULL, 0, out);
6964 }
7065
7166 struct shash_alg sha256_neon_algs[] = { {
7267 .digestsize = SHA256_DIGEST_SIZE,
7368 .init = sha256_base_init,
74
- .update = sha256_update,
75
- .final = sha256_final,
76
- .finup = sha256_finup,
69
+ .update = crypto_sha256_neon_update,
70
+ .final = crypto_sha256_neon_final,
71
+ .finup = crypto_sha256_neon_finup,
7772 .descsize = sizeof(struct sha256_state),
7873 .base = {
7974 .cra_name = "sha256",
....@@ -85,9 +80,9 @@
8580 }, {
8681 .digestsize = SHA224_DIGEST_SIZE,
8782 .init = sha224_base_init,
88
- .update = sha256_update,
89
- .final = sha256_final,
90
- .finup = sha256_finup,
83
+ .update = crypto_sha256_neon_update,
84
+ .final = crypto_sha256_neon_final,
85
+ .finup = crypto_sha256_neon_finup,
9186 .descsize = sizeof(struct sha256_state),
9287 .base = {
9388 .cra_name = "sha224",