forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/arch/arm64/crypto/aes-ce-glue.c
....@@ -1,17 +1,15 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * aes-ce-cipher.c - core AES cipher using ARMv8 Crypto Extensions
34 *
45 * Copyright (C) 2013 - 2017 Linaro Ltd <ard.biesheuvel@linaro.org>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
96 */
107
118 #include <asm/neon.h>
129 #include <asm/simd.h>
1310 #include <asm/unaligned.h>
1411 #include <crypto/aes.h>
12
+#include <crypto/internal/simd.h>
1513 #include <linux/cpufeature.h>
1614 #include <linux/crypto.h>
1715 #include <linux/module.h>
....@@ -21,9 +19,6 @@
2119 MODULE_DESCRIPTION("Synchronous AES cipher using ARMv8 Crypto Extensions");
2220 MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
2321 MODULE_LICENSE("GPL v2");
24
-
25
-asmlinkage void __aes_arm64_encrypt(u32 *rk, u8 *out, const u8 *in, int rounds);
26
-asmlinkage void __aes_arm64_decrypt(u32 *rk, u8 *out, const u8 *in, int rounds);
2722
2823 struct aes_block {
2924 u8 b[AES_BLOCK_SIZE];
....@@ -52,8 +47,8 @@
5247 {
5348 struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
5449
55
- if (!may_use_simd()) {
56
- __aes_arm64_encrypt(ctx->key_enc, dst, src, num_rounds(ctx));
50
+ if (!crypto_simd_usable()) {
51
+ aes_encrypt(ctx, dst, src);
5752 return;
5853 }
5954
....@@ -66,8 +61,8 @@
6661 {
6762 struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
6863
69
- if (!may_use_simd()) {
70
- __aes_arm64_decrypt(ctx->key_dec, dst, src, num_rounds(ctx));
64
+ if (!crypto_simd_usable()) {
65
+ aes_decrypt(ctx, dst, src);
7166 return;
7267 }
7368
....@@ -148,14 +143,8 @@
148143 unsigned int key_len)
149144 {
150145 struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
151
- int ret;
152146
153
- ret = ce_aes_expandkey(ctx, in_key, key_len);
154
- if (!ret)
155
- return 0;
156
-
157
- tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
158
- return -EINVAL;
147
+ return ce_aes_expandkey(ctx, in_key, key_len);
159148 }
160149 EXPORT_SYMBOL(ce_aes_setkey);
161150