hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/crypto/cast6_generic.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Kernel cryptographic api.
23 * cast6.c - Cast6 cipher algorithm [rfc2612].
34 *
....@@ -6,14 +7,6 @@
67 * algorithm.
78 *
89 * Copyright (C) 2003 Kartikey Mahendra Bhatt <kartik_me@hotmail.com>.
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of 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
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1710 */
1811
1912
....@@ -110,17 +103,14 @@
110103 key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
111104 }
112105
113
-int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key,
114
- unsigned key_len, u32 *flags)
106
+int __cast6_setkey(struct cast6_ctx *c, const u8 *in_key, unsigned int key_len)
115107 {
116108 int i;
117109 u32 key[8];
118110 __be32 p_key[8]; /* padded key */
119111
120
- if (key_len % 4 != 0) {
121
- *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
112
+ if (key_len % 4 != 0)
122113 return -EINVAL;
123
- }
124114
125115 memset(p_key, 0, 32);
126116 memcpy(p_key, in_key, key_len);
....@@ -155,13 +145,12 @@
155145
156146 int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
157147 {
158
- return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen,
159
- &tfm->crt_flags);
148
+ return __cast6_setkey(crypto_tfm_ctx(tfm), key, keylen);
160149 }
161150 EXPORT_SYMBOL_GPL(cast6_setkey);
162151
163152 /*forward quad round*/
164
-static inline void Q(u32 *block, u8 *Kr, u32 *Km)
153
+static inline void Q(u32 *block, const u8 *Kr, const u32 *Km)
165154 {
166155 u32 I;
167156 block[2] ^= F1(block[3], Kr[0], Km[0]);
....@@ -171,7 +160,7 @@
171160 }
172161
173162 /*reverse quad round*/
174
-static inline void QBAR(u32 *block, u8 *Kr, u32 *Km)
163
+static inline void QBAR(u32 *block, const u8 *Kr, const u32 *Km)
175164 {
176165 u32 I;
177166 block[3] ^= F1(block[0], Kr[3], Km[3]);
....@@ -180,13 +169,14 @@
180169 block[2] ^= F1(block[3], Kr[0], Km[0]);
181170 }
182171
183
-void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf)
172
+void __cast6_encrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
184173 {
174
+ const struct cast6_ctx *c = ctx;
185175 const __be32 *src = (const __be32 *)inbuf;
186176 __be32 *dst = (__be32 *)outbuf;
187177 u32 block[4];
188
- u32 *Km;
189
- u8 *Kr;
178
+ const u32 *Km;
179
+ const u8 *Kr;
190180
191181 block[0] = be32_to_cpu(src[0]);
192182 block[1] = be32_to_cpu(src[1]);
....@@ -218,13 +208,14 @@
218208 __cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf);
219209 }
220210
221
-void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf)
211
+void __cast6_decrypt(const void *ctx, u8 *outbuf, const u8 *inbuf)
222212 {
213
+ const struct cast6_ctx *c = ctx;
223214 const __be32 *src = (const __be32 *)inbuf;
224215 __be32 *dst = (__be32 *)outbuf;
225216 u32 block[4];
226
- u32 *Km;
227
- u8 *Kr;
217
+ const u32 *Km;
218
+ const u8 *Kr;
228219
229220 block[0] = be32_to_cpu(src[0]);
230221 block[1] = be32_to_cpu(src[1]);
....@@ -285,7 +276,7 @@
285276 crypto_unregister_alg(&alg);
286277 }
287278
288
-module_init(cast6_mod_init);
279
+subsys_initcall(cast6_mod_init);
289280 module_exit(cast6_mod_fini);
290281
291282 MODULE_LICENSE("GPL");