hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/crypto/twofish_glue_3way.c
....@@ -1,23 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Glue Code for 3-way parallel assembler optimized version of Twofish
34 *
45 * Copyright (c) 2011 Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
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 as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19
- * USA
20
- *
216 */
227
238 #include <asm/crypto/glue_helper.h>
....@@ -40,21 +25,22 @@
4025 return twofish_setkey(&tfm->base, key, keylen);
4126 }
4227
43
-static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst,
44
- const u8 *src)
28
+static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src)
4529 {
4630 __twofish_enc_blk_3way(ctx, dst, src, false);
4731 }
4832
49
-static inline void twofish_enc_blk_xor_3way(struct twofish_ctx *ctx, u8 *dst,
33
+static inline void twofish_enc_blk_xor_3way(const void *ctx, u8 *dst,
5034 const u8 *src)
5135 {
5236 __twofish_enc_blk_3way(ctx, dst, src, true);
5337 }
5438
55
-void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src)
39
+void twofish_dec_blk_cbc_3way(const void *ctx, u8 *d, const u8 *s)
5640 {
5741 u128 ivs[2];
42
+ u128 *dst = (u128 *)d;
43
+ const u128 *src = (const u128 *)s;
5844
5945 ivs[0] = src[0];
6046 ivs[1] = src[1];
....@@ -66,9 +52,11 @@
6652 }
6753 EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way);
6854
69
-void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
55
+void twofish_enc_blk_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv)
7056 {
7157 be128 ctrblk;
58
+ u128 *dst = (u128 *)d;
59
+ const u128 *src = (const u128 *)s;
7260
7361 if (dst != src)
7462 *dst = *src;
....@@ -81,10 +69,11 @@
8169 }
8270 EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr);
8371
84
-void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
85
- le128 *iv)
72
+void twofish_enc_blk_ctr_3way(const void *ctx, u8 *d, const u8 *s, le128 *iv)
8673 {
8774 be128 ctrblks[3];
75
+ u128 *dst = (u128 *)d;
76
+ const u128 *src = (const u128 *)s;
8877
8978 if (dst != src) {
9079 dst[0] = src[0];
....@@ -109,10 +98,10 @@
10998
11099 .funcs = { {
111100 .num_blocks = 3,
112
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) }
101
+ .fn_u = { .ecb = twofish_enc_blk_3way }
113102 }, {
114103 .num_blocks = 1,
115
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) }
104
+ .fn_u = { .ecb = twofish_enc_blk }
116105 } }
117106 };
118107
....@@ -122,10 +111,10 @@
122111
123112 .funcs = { {
124113 .num_blocks = 3,
125
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr_3way) }
114
+ .fn_u = { .ctr = twofish_enc_blk_ctr_3way }
126115 }, {
127116 .num_blocks = 1,
128
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr) }
117
+ .fn_u = { .ctr = twofish_enc_blk_ctr }
129118 } }
130119 };
131120
....@@ -135,10 +124,10 @@
135124
136125 .funcs = { {
137126 .num_blocks = 3,
138
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) }
127
+ .fn_u = { .ecb = twofish_dec_blk_3way }
139128 }, {
140129 .num_blocks = 1,
141
- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) }
130
+ .fn_u = { .ecb = twofish_dec_blk }
142131 } }
143132 };
144133
....@@ -148,10 +137,10 @@
148137
149138 .funcs = { {
150139 .num_blocks = 3,
151
- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) }
140
+ .fn_u = { .cbc = twofish_dec_blk_cbc_3way }
152141 }, {
153142 .num_blocks = 1,
154
- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) }
143
+ .fn_u = { .cbc = twofish_dec_blk }
155144 } }
156145 };
157146
....@@ -167,8 +156,7 @@
167156
168157 static int cbc_encrypt(struct skcipher_request *req)
169158 {
170
- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(twofish_enc_blk),
171
- req);
159
+ return glue_cbc_encrypt_req_128bit(twofish_enc_blk, req);
172160 }
173161
174162 static int cbc_decrypt(struct skcipher_request *req)