forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/x86/crypto/serpent_sse2_glue.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Glue Code for SSE2 assembler versions of Serpent Cipher
34 *
....@@ -11,22 +12,6 @@
1112 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
1213 * CTR part based on code (crypto/ctr.c) by:
1314 * (C) Copyright IBM Corp. 2007 - Joy Latten <latten@us.ibm.com>
14
- *
15
- * This program is free software; you can redistribute it and/or modify
16
- * it under the terms of the GNU General Public License as published by
17
- * the Free Software Foundation; either version 2 of the License, or
18
- * (at your option) any later version.
19
- *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- * GNU General Public License for more details.
24
- *
25
- * You should have received a copy of the GNU General Public License
26
- * along with this program; if not, write to the Free Software
27
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28
- * USA
29
- *
3015 */
3116
3217 #include <linux/module.h>
....@@ -46,9 +31,11 @@
4631 return __serpent_setkey(crypto_skcipher_ctx(tfm), key, keylen);
4732 }
4833
49
-static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src)
34
+static void serpent_decrypt_cbc_xway(const void *ctx, u8 *d, const u8 *s)
5035 {
5136 u128 ivs[SERPENT_PARALLEL_BLOCKS - 1];
37
+ u128 *dst = (u128 *)d;
38
+ const u128 *src = (const u128 *)s;
5239 unsigned int j;
5340
5441 for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++)
....@@ -60,9 +47,11 @@
6047 u128_xor(dst + (j + 1), dst + (j + 1), ivs + j);
6148 }
6249
63
-static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv)
50
+static void serpent_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv)
6451 {
6552 be128 ctrblk;
53
+ u128 *dst = (u128 *)d;
54
+ const u128 *src = (const u128 *)s;
6655
6756 le128_to_be128(&ctrblk, iv);
6857 le128_inc(iv);
....@@ -71,10 +60,12 @@
7160 u128_xor(dst, src, (u128 *)&ctrblk);
7261 }
7362
74
-static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src,
63
+static void serpent_crypt_ctr_xway(const void *ctx, u8 *d, const u8 *s,
7564 le128 *iv)
7665 {
7766 be128 ctrblks[SERPENT_PARALLEL_BLOCKS];
67
+ u128 *dst = (u128 *)d;
68
+ const u128 *src = (const u128 *)s;
7869 unsigned int i;
7970
8071 for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) {
....@@ -94,10 +85,10 @@
9485
9586 .funcs = { {
9687 .num_blocks = SERPENT_PARALLEL_BLOCKS,
97
- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_enc_blk_xway) }
88
+ .fn_u = { .ecb = serpent_enc_blk_xway }
9889 }, {
9990 .num_blocks = 1,
100
- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) }
91
+ .fn_u = { .ecb = __serpent_encrypt }
10192 } }
10293 };
10394
....@@ -107,10 +98,10 @@
10798
10899 .funcs = { {
109100 .num_blocks = SERPENT_PARALLEL_BLOCKS,
110
- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr_xway) }
101
+ .fn_u = { .ctr = serpent_crypt_ctr_xway }
111102 }, {
112103 .num_blocks = 1,
113
- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) }
104
+ .fn_u = { .ctr = serpent_crypt_ctr }
114105 } }
115106 };
116107
....@@ -120,10 +111,10 @@
120111
121112 .funcs = { {
122113 .num_blocks = SERPENT_PARALLEL_BLOCKS,
123
- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_dec_blk_xway) }
114
+ .fn_u = { .ecb = serpent_dec_blk_xway }
124115 }, {
125116 .num_blocks = 1,
126
- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) }
117
+ .fn_u = { .ecb = __serpent_decrypt }
127118 } }
128119 };
129120
....@@ -133,10 +124,10 @@
133124
134125 .funcs = { {
135126 .num_blocks = SERPENT_PARALLEL_BLOCKS,
136
- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_decrypt_cbc_xway) }
127
+ .fn_u = { .cbc = serpent_decrypt_cbc_xway }
137128 }, {
138129 .num_blocks = 1,
139
- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) }
130
+ .fn_u = { .cbc = __serpent_decrypt }
140131 } }
141132 };
142133
....@@ -152,7 +143,7 @@
152143
153144 static int cbc_encrypt(struct skcipher_request *req)
154145 {
155
- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(__serpent_encrypt),
146
+ return glue_cbc_encrypt_req_128bit(__serpent_encrypt,
156147 req);
157148 }
158149