.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * aes-ce-cipher.c - core AES cipher using ARMv8 Crypto Extensions |
---|
3 | 4 | * |
---|
4 | 5 | * 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. |
---|
9 | 6 | */ |
---|
10 | 7 | |
---|
11 | 8 | #include <asm/neon.h> |
---|
12 | 9 | #include <asm/simd.h> |
---|
13 | 10 | #include <asm/unaligned.h> |
---|
14 | 11 | #include <crypto/aes.h> |
---|
| 12 | +#include <crypto/internal/simd.h> |
---|
15 | 13 | #include <linux/cpufeature.h> |
---|
16 | 14 | #include <linux/crypto.h> |
---|
17 | 15 | #include <linux/module.h> |
---|
.. | .. |
---|
21 | 19 | MODULE_DESCRIPTION("Synchronous AES cipher using ARMv8 Crypto Extensions"); |
---|
22 | 20 | MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>"); |
---|
23 | 21 | 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); |
---|
27 | 22 | |
---|
28 | 23 | struct aes_block { |
---|
29 | 24 | u8 b[AES_BLOCK_SIZE]; |
---|
.. | .. |
---|
52 | 47 | { |
---|
53 | 48 | struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
54 | 49 | |
---|
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); |
---|
57 | 52 | return; |
---|
58 | 53 | } |
---|
59 | 54 | |
---|
.. | .. |
---|
66 | 61 | { |
---|
67 | 62 | struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
68 | 63 | |
---|
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); |
---|
71 | 66 | return; |
---|
72 | 67 | } |
---|
73 | 68 | |
---|
.. | .. |
---|
148 | 143 | unsigned int key_len) |
---|
149 | 144 | { |
---|
150 | 145 | struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
151 | | - int ret; |
---|
152 | 146 | |
---|
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); |
---|
159 | 148 | } |
---|
160 | 149 | EXPORT_SYMBOL(ce_aes_setkey); |
---|
161 | 150 | |
---|