apm821xx: backport and reassign crypto4xx patches
[openwrt/openwrt.git] / target / linux / apm821xx / patches-4.14 / 022-0003-crypto-crypto4xx-convert-to-skcipher.patch
1 From ce05ffe10457bda487fa049016a6ba79934bdece Mon Sep 17 00:00:00 2001
2 From: Christian Lamparter <chunkeey@gmail.com>
3 Date: Thu, 19 Apr 2018 18:41:52 +0200
4 Subject: [PATCH 3/8] crypto: crypto4xx - convert to skcipher
5
6 The ablkcipher APIs have been effectively deprecated since [1].
7 This patch converts the crypto4xx driver to the new skcipher APIs.
8
9 [1] <https://www.spinics.net/lists/linux-crypto/msg18133.html>
10
11 Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
12 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
13 ---
14 drivers/crypto/amcc/crypto4xx_alg.c | 60 ++++---
15 drivers/crypto/amcc/crypto4xx_core.c | 255 +++++++++++++--------------
16 drivers/crypto/amcc/crypto4xx_core.h | 25 +--
17 3 files changed, 163 insertions(+), 177 deletions(-)
18
19 --- a/drivers/crypto/amcc/crypto4xx_alg.c
20 +++ b/drivers/crypto/amcc/crypto4xx_alg.c
21 @@ -31,6 +31,7 @@
22 #include <crypto/gcm.h>
23 #include <crypto/sha.h>
24 #include <crypto/ctr.h>
25 +#include <crypto/skcipher.h>
26 #include "crypto4xx_reg_def.h"
27 #include "crypto4xx_core.h"
28 #include "crypto4xx_sa.h"
29 @@ -74,36 +75,37 @@ static void set_dynamic_sa_command_1(str
30 sa->sa_command_1.bf.copy_hdr = cp_hdr;
31 }
32
33 -static inline int crypto4xx_crypt(struct ablkcipher_request *req,
34 +static inline int crypto4xx_crypt(struct skcipher_request *req,
35 const unsigned int ivlen, bool decrypt)
36 {
37 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
38 + struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
39 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
40 __le32 iv[ivlen];
41
42 if (ivlen)
43 - crypto4xx_memcpy_to_le32(iv, req->info, ivlen);
44 + crypto4xx_memcpy_to_le32(iv, req->iv, ivlen);
45
46 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
47 - req->nbytes, iv, ivlen, decrypt ? ctx->sa_in : ctx->sa_out,
48 + req->cryptlen, iv, ivlen, decrypt ? ctx->sa_in : ctx->sa_out,
49 ctx->sa_len, 0);
50 }
51
52 -int crypto4xx_encrypt_noiv(struct ablkcipher_request *req)
53 +int crypto4xx_encrypt_noiv(struct skcipher_request *req)
54 {
55 return crypto4xx_crypt(req, 0, false);
56 }
57
58 -int crypto4xx_encrypt_iv(struct ablkcipher_request *req)
59 +int crypto4xx_encrypt_iv(struct skcipher_request *req)
60 {
61 return crypto4xx_crypt(req, AES_IV_SIZE, false);
62 }
63
64 -int crypto4xx_decrypt_noiv(struct ablkcipher_request *req)
65 +int crypto4xx_decrypt_noiv(struct skcipher_request *req)
66 {
67 return crypto4xx_crypt(req, 0, true);
68 }
69
70 -int crypto4xx_decrypt_iv(struct ablkcipher_request *req)
71 +int crypto4xx_decrypt_iv(struct skcipher_request *req)
72 {
73 return crypto4xx_crypt(req, AES_IV_SIZE, true);
74 }
75 @@ -111,20 +113,19 @@ int crypto4xx_decrypt_iv(struct ablkciph
76 /**
77 * AES Functions
78 */
79 -static int crypto4xx_setkey_aes(struct crypto_ablkcipher *cipher,
80 +static int crypto4xx_setkey_aes(struct crypto_skcipher *cipher,
81 const u8 *key,
82 unsigned int keylen,
83 unsigned char cm,
84 u8 fb)
85 {
86 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
87 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
88 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
89 struct dynamic_sa_ctl *sa;
90 int rc;
91
92 if (keylen != AES_KEYSIZE_256 &&
93 keylen != AES_KEYSIZE_192 && keylen != AES_KEYSIZE_128) {
94 - crypto_ablkcipher_set_flags(cipher,
95 + crypto_skcipher_set_flags(cipher,
96 CRYPTO_TFM_RES_BAD_KEY_LEN);
97 return -EINVAL;
98 }
99 @@ -164,39 +165,38 @@ static int crypto4xx_setkey_aes(struct c
100 return 0;
101 }
102
103 -int crypto4xx_setkey_aes_cbc(struct crypto_ablkcipher *cipher,
104 +int crypto4xx_setkey_aes_cbc(struct crypto_skcipher *cipher,
105 const u8 *key, unsigned int keylen)
106 {
107 return crypto4xx_setkey_aes(cipher, key, keylen, CRYPTO_MODE_CBC,
108 CRYPTO_FEEDBACK_MODE_NO_FB);
109 }
110
111 -int crypto4xx_setkey_aes_cfb(struct crypto_ablkcipher *cipher,
112 +int crypto4xx_setkey_aes_cfb(struct crypto_skcipher *cipher,
113 const u8 *key, unsigned int keylen)
114 {
115 return crypto4xx_setkey_aes(cipher, key, keylen, CRYPTO_MODE_CFB,
116 CRYPTO_FEEDBACK_MODE_128BIT_CFB);
117 }
118
119 -int crypto4xx_setkey_aes_ecb(struct crypto_ablkcipher *cipher,
120 +int crypto4xx_setkey_aes_ecb(struct crypto_skcipher *cipher,
121 const u8 *key, unsigned int keylen)
122 {
123 return crypto4xx_setkey_aes(cipher, key, keylen, CRYPTO_MODE_ECB,
124 CRYPTO_FEEDBACK_MODE_NO_FB);
125 }
126
127 -int crypto4xx_setkey_aes_ofb(struct crypto_ablkcipher *cipher,
128 +int crypto4xx_setkey_aes_ofb(struct crypto_skcipher *cipher,
129 const u8 *key, unsigned int keylen)
130 {
131 return crypto4xx_setkey_aes(cipher, key, keylen, CRYPTO_MODE_OFB,
132 CRYPTO_FEEDBACK_MODE_64BIT_OFB);
133 }
134
135 -int crypto4xx_setkey_rfc3686(struct crypto_ablkcipher *cipher,
136 +int crypto4xx_setkey_rfc3686(struct crypto_skcipher *cipher,
137 const u8 *key, unsigned int keylen)
138 {
139 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
140 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
141 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
142 int rc;
143
144 rc = crypto4xx_setkey_aes(cipher, key, keylen - CTR_RFC3686_NONCE_SIZE,
145 @@ -210,31 +210,33 @@ int crypto4xx_setkey_rfc3686(struct cryp
146 return 0;
147 }
148
149 -int crypto4xx_rfc3686_encrypt(struct ablkcipher_request *req)
150 +int crypto4xx_rfc3686_encrypt(struct skcipher_request *req)
151 {
152 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
153 + struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
154 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
155 __le32 iv[AES_IV_SIZE / 4] = {
156 ctx->iv_nonce,
157 - cpu_to_le32p((u32 *) req->info),
158 - cpu_to_le32p((u32 *) (req->info + 4)),
159 + cpu_to_le32p((u32 *) req->iv),
160 + cpu_to_le32p((u32 *) (req->iv + 4)),
161 cpu_to_le32(1) };
162
163 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
164 - req->nbytes, iv, AES_IV_SIZE,
165 + req->cryptlen, iv, AES_IV_SIZE,
166 ctx->sa_out, ctx->sa_len, 0);
167 }
168
169 -int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req)
170 +int crypto4xx_rfc3686_decrypt(struct skcipher_request *req)
171 {
172 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(req->base.tfm);
173 + struct crypto_skcipher *cipher = crypto_skcipher_reqtfm(req);
174 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(cipher);
175 __le32 iv[AES_IV_SIZE / 4] = {
176 ctx->iv_nonce,
177 - cpu_to_le32p((u32 *) req->info),
178 - cpu_to_le32p((u32 *) (req->info + 4)),
179 + cpu_to_le32p((u32 *) req->iv),
180 + cpu_to_le32p((u32 *) (req->iv + 4)),
181 cpu_to_le32(1) };
182
183 return crypto4xx_build_pd(&req->base, ctx, req->src, req->dst,
184 - req->nbytes, iv, AES_IV_SIZE,
185 + req->cryptlen, iv, AES_IV_SIZE,
186 ctx->sa_out, ctx->sa_len, 0);
187 }
188
189 --- a/drivers/crypto/amcc/crypto4xx_core.c
190 +++ b/drivers/crypto/amcc/crypto4xx_core.c
191 @@ -41,6 +41,7 @@
192 #include <crypto/gcm.h>
193 #include <crypto/sha.h>
194 #include <crypto/scatterwalk.h>
195 +#include <crypto/skcipher.h>
196 #include <crypto/internal/aead.h>
197 #include <crypto/internal/skcipher.h>
198 #include "crypto4xx_reg_def.h"
199 @@ -526,21 +527,19 @@ static void crypto4xx_ret_sg_desc(struct
200 }
201 }
202
203 -static void crypto4xx_ablkcipher_done(struct crypto4xx_device *dev,
204 +static void crypto4xx_cipher_done(struct crypto4xx_device *dev,
205 struct pd_uinfo *pd_uinfo,
206 struct ce_pd *pd)
207 {
208 - struct crypto4xx_ctx *ctx;
209 - struct ablkcipher_request *ablk_req;
210 + struct skcipher_request *req;
211 struct scatterlist *dst;
212 dma_addr_t addr;
213
214 - ablk_req = ablkcipher_request_cast(pd_uinfo->async_req);
215 - ctx = crypto_tfm_ctx(ablk_req->base.tfm);
216 + req = skcipher_request_cast(pd_uinfo->async_req);
217
218 if (pd_uinfo->using_sd) {
219 - crypto4xx_copy_pkt_to_dst(dev, pd, pd_uinfo, ablk_req->nbytes,
220 - ablk_req->dst);
221 + crypto4xx_copy_pkt_to_dst(dev, pd, pd_uinfo,
222 + req->cryptlen, req->dst);
223 } else {
224 dst = pd_uinfo->dest_va;
225 addr = dma_map_page(dev->core_dev->device, sg_page(dst),
226 @@ -549,8 +548,8 @@ static void crypto4xx_ablkcipher_done(st
227 crypto4xx_ret_sg_desc(dev, pd_uinfo);
228
229 if (pd_uinfo->state & PD_ENTRY_BUSY)
230 - ablkcipher_request_complete(ablk_req, -EINPROGRESS);
231 - ablkcipher_request_complete(ablk_req, 0);
232 + skcipher_request_complete(req, -EINPROGRESS);
233 + skcipher_request_complete(req, 0);
234 }
235
236 static void crypto4xx_ahash_done(struct crypto4xx_device *dev,
237 @@ -641,8 +640,8 @@ static void crypto4xx_pd_done(struct cry
238 struct pd_uinfo *pd_uinfo = &dev->pdr_uinfo[idx];
239
240 switch (crypto_tfm_alg_type(pd_uinfo->async_req->tfm)) {
241 - case CRYPTO_ALG_TYPE_ABLKCIPHER:
242 - crypto4xx_ablkcipher_done(dev, pd_uinfo, pd);
243 + case CRYPTO_ALG_TYPE_SKCIPHER:
244 + crypto4xx_cipher_done(dev, pd_uinfo, pd);
245 break;
246 case CRYPTO_ALG_TYPE_AEAD:
247 crypto4xx_aead_done(dev, pd_uinfo, pd);
248 @@ -936,15 +935,14 @@ static void crypto4xx_ctx_init(struct cr
249 ctx->sa_len = 0;
250 }
251
252 -static int crypto4xx_ablk_init(struct crypto_tfm *tfm)
253 +static int crypto4xx_sk_init(struct crypto_skcipher *sk)
254 {
255 - struct crypto_alg *alg = tfm->__crt_alg;
256 + struct skcipher_alg *alg = crypto_skcipher_alg(sk);
257 struct crypto4xx_alg *amcc_alg;
258 - struct crypto4xx_ctx *ctx = crypto_tfm_ctx(tfm);
259 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(sk);
260
261 amcc_alg = container_of(alg, struct crypto4xx_alg, alg.u.cipher);
262 crypto4xx_ctx_init(amcc_alg, ctx);
263 - tfm->crt_ablkcipher.reqsize = sizeof(struct crypto4xx_ctx);
264 return 0;
265 }
266
267 @@ -953,9 +951,11 @@ static void crypto4xx_common_exit(struct
268 crypto4xx_free_sa(ctx);
269 }
270
271 -static void crypto4xx_ablk_exit(struct crypto_tfm *tfm)
272 +static void crypto4xx_sk_exit(struct crypto_skcipher *sk)
273 {
274 - crypto4xx_common_exit(crypto_tfm_ctx(tfm));
275 + struct crypto4xx_ctx *ctx = crypto_skcipher_ctx(sk);
276 +
277 + crypto4xx_common_exit(ctx);
278 }
279
280 static int crypto4xx_aead_init(struct crypto_aead *tfm)
281 @@ -1012,7 +1012,7 @@ static int crypto4xx_register_alg(struct
282 break;
283
284 default:
285 - rc = crypto_register_alg(&alg->alg.u.cipher);
286 + rc = crypto_register_skcipher(&alg->alg.u.cipher);
287 break;
288 }
289
290 @@ -1041,7 +1041,7 @@ static void crypto4xx_unregister_alg(str
291 break;
292
293 default:
294 - crypto_unregister_alg(&alg->alg.u.cipher);
295 + crypto_unregister_skcipher(&alg->alg.u.cipher);
296 }
297 kfree(alg);
298 }
299 @@ -1103,126 +1103,109 @@ static irqreturn_t crypto4xx_ce_interrup
300 */
301 static struct crypto4xx_alg_common crypto4xx_alg[] = {
302 /* Crypto AES modes */
303 - { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
304 - .cra_name = "cbc(aes)",
305 - .cra_driver_name = "cbc-aes-ppc4xx",
306 - .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
307 - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
308 - CRYPTO_ALG_ASYNC |
309 - CRYPTO_ALG_KERN_DRIVER_ONLY,
310 - .cra_blocksize = AES_BLOCK_SIZE,
311 - .cra_ctxsize = sizeof(struct crypto4xx_ctx),
312 - .cra_type = &crypto_ablkcipher_type,
313 - .cra_init = crypto4xx_ablk_init,
314 - .cra_exit = crypto4xx_ablk_exit,
315 - .cra_module = THIS_MODULE,
316 - .cra_u = {
317 - .ablkcipher = {
318 - .min_keysize = AES_MIN_KEY_SIZE,
319 - .max_keysize = AES_MAX_KEY_SIZE,
320 - .ivsize = AES_IV_SIZE,
321 - .setkey = crypto4xx_setkey_aes_cbc,
322 - .encrypt = crypto4xx_encrypt_iv,
323 - .decrypt = crypto4xx_decrypt_iv,
324 - }
325 - }
326 - }},
327 - { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
328 - .cra_name = "cfb(aes)",
329 - .cra_driver_name = "cfb-aes-ppc4xx",
330 - .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
331 - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
332 - CRYPTO_ALG_ASYNC |
333 - CRYPTO_ALG_KERN_DRIVER_ONLY,
334 - .cra_blocksize = AES_BLOCK_SIZE,
335 - .cra_ctxsize = sizeof(struct crypto4xx_ctx),
336 - .cra_type = &crypto_ablkcipher_type,
337 - .cra_init = crypto4xx_ablk_init,
338 - .cra_exit = crypto4xx_ablk_exit,
339 - .cra_module = THIS_MODULE,
340 - .cra_u = {
341 - .ablkcipher = {
342 - .min_keysize = AES_MIN_KEY_SIZE,
343 - .max_keysize = AES_MAX_KEY_SIZE,
344 - .ivsize = AES_IV_SIZE,
345 - .setkey = crypto4xx_setkey_aes_cfb,
346 - .encrypt = crypto4xx_encrypt_iv,
347 - .decrypt = crypto4xx_decrypt_iv,
348 - }
349 - }
350 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, .u.cipher = {
351 + .base = {
352 + .cra_name = "cbc(aes)",
353 + .cra_driver_name = "cbc-aes-ppc4xx",
354 + .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
355 + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER |
356 + CRYPTO_ALG_ASYNC |
357 + CRYPTO_ALG_KERN_DRIVER_ONLY,
358 + .cra_blocksize = AES_BLOCK_SIZE,
359 + .cra_ctxsize = sizeof(struct crypto4xx_ctx),
360 + .cra_module = THIS_MODULE,
361 + },
362 + .min_keysize = AES_MIN_KEY_SIZE,
363 + .max_keysize = AES_MAX_KEY_SIZE,
364 + .ivsize = AES_IV_SIZE,
365 + .setkey = crypto4xx_setkey_aes_cbc,
366 + .encrypt = crypto4xx_encrypt_iv,
367 + .decrypt = crypto4xx_decrypt_iv,
368 + .init = crypto4xx_sk_init,
369 + .exit = crypto4xx_sk_exit,
370 } },
371 - { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
372 - .cra_name = "rfc3686(ctr(aes))",
373 - .cra_driver_name = "rfc3686-ctr-aes-ppc4xx",
374 - .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
375 - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
376 - CRYPTO_ALG_ASYNC |
377 - CRYPTO_ALG_KERN_DRIVER_ONLY,
378 - .cra_blocksize = AES_BLOCK_SIZE,
379 - .cra_ctxsize = sizeof(struct crypto4xx_ctx),
380 - .cra_type = &crypto_ablkcipher_type,
381 - .cra_init = crypto4xx_ablk_init,
382 - .cra_exit = crypto4xx_ablk_exit,
383 - .cra_module = THIS_MODULE,
384 - .cra_u = {
385 - .ablkcipher = {
386 - .min_keysize = AES_MIN_KEY_SIZE +
387 - CTR_RFC3686_NONCE_SIZE,
388 - .max_keysize = AES_MAX_KEY_SIZE +
389 - CTR_RFC3686_NONCE_SIZE,
390 - .ivsize = CTR_RFC3686_IV_SIZE,
391 - .setkey = crypto4xx_setkey_rfc3686,
392 - .encrypt = crypto4xx_rfc3686_encrypt,
393 - .decrypt = crypto4xx_rfc3686_decrypt,
394 - }
395 - }
396 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, .u.cipher = {
397 + .base = {
398 + .cra_name = "cfb(aes)",
399 + .cra_driver_name = "cfb-aes-ppc4xx",
400 + .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
401 + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER |
402 + CRYPTO_ALG_ASYNC |
403 + CRYPTO_ALG_KERN_DRIVER_ONLY,
404 + .cra_blocksize = AES_BLOCK_SIZE,
405 + .cra_ctxsize = sizeof(struct crypto4xx_ctx),
406 + .cra_module = THIS_MODULE,
407 + },
408 + .min_keysize = AES_MIN_KEY_SIZE,
409 + .max_keysize = AES_MAX_KEY_SIZE,
410 + .ivsize = AES_IV_SIZE,
411 + .setkey = crypto4xx_setkey_aes_cfb,
412 + .encrypt = crypto4xx_encrypt_iv,
413 + .decrypt = crypto4xx_decrypt_iv,
414 + .init = crypto4xx_sk_init,
415 + .exit = crypto4xx_sk_exit,
416 } },
417 - { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
418 - .cra_name = "ecb(aes)",
419 - .cra_driver_name = "ecb-aes-ppc4xx",
420 - .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
421 - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
422 - CRYPTO_ALG_ASYNC |
423 - CRYPTO_ALG_KERN_DRIVER_ONLY,
424 - .cra_blocksize = AES_BLOCK_SIZE,
425 - .cra_ctxsize = sizeof(struct crypto4xx_ctx),
426 - .cra_type = &crypto_ablkcipher_type,
427 - .cra_init = crypto4xx_ablk_init,
428 - .cra_exit = crypto4xx_ablk_exit,
429 - .cra_module = THIS_MODULE,
430 - .cra_u = {
431 - .ablkcipher = {
432 - .min_keysize = AES_MIN_KEY_SIZE,
433 - .max_keysize = AES_MAX_KEY_SIZE,
434 - .setkey = crypto4xx_setkey_aes_ecb,
435 - .encrypt = crypto4xx_encrypt_noiv,
436 - .decrypt = crypto4xx_decrypt_noiv,
437 - }
438 - }
439 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, .u.cipher = {
440 + .base = {
441 + .cra_name = "rfc3686(ctr(aes))",
442 + .cra_driver_name = "rfc3686-ctr-aes-ppc4xx",
443 + .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
444 + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER |
445 + CRYPTO_ALG_ASYNC |
446 + CRYPTO_ALG_KERN_DRIVER_ONLY,
447 + .cra_blocksize = AES_BLOCK_SIZE,
448 + .cra_ctxsize = sizeof(struct crypto4xx_ctx),
449 + .cra_module = THIS_MODULE,
450 + },
451 + .min_keysize = AES_MIN_KEY_SIZE + CTR_RFC3686_NONCE_SIZE,
452 + .max_keysize = AES_MAX_KEY_SIZE + CTR_RFC3686_NONCE_SIZE,
453 + .ivsize = CTR_RFC3686_IV_SIZE,
454 + .setkey = crypto4xx_setkey_rfc3686,
455 + .encrypt = crypto4xx_rfc3686_encrypt,
456 + .decrypt = crypto4xx_rfc3686_decrypt,
457 + .init = crypto4xx_sk_init,
458 + .exit = crypto4xx_sk_exit,
459 } },
460 - { .type = CRYPTO_ALG_TYPE_ABLKCIPHER, .u.cipher = {
461 - .cra_name = "ofb(aes)",
462 - .cra_driver_name = "ofb-aes-ppc4xx",
463 - .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
464 - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER |
465 - CRYPTO_ALG_ASYNC |
466 - CRYPTO_ALG_KERN_DRIVER_ONLY,
467 - .cra_blocksize = AES_BLOCK_SIZE,
468 - .cra_ctxsize = sizeof(struct crypto4xx_ctx),
469 - .cra_type = &crypto_ablkcipher_type,
470 - .cra_init = crypto4xx_ablk_init,
471 - .cra_exit = crypto4xx_ablk_exit,
472 - .cra_module = THIS_MODULE,
473 - .cra_u = {
474 - .ablkcipher = {
475 - .min_keysize = AES_MIN_KEY_SIZE,
476 - .max_keysize = AES_MAX_KEY_SIZE,
477 - .ivsize = AES_IV_SIZE,
478 - .setkey = crypto4xx_setkey_aes_ofb,
479 - .encrypt = crypto4xx_encrypt_iv,
480 - .decrypt = crypto4xx_decrypt_iv,
481 - }
482 - }
483 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, .u.cipher = {
484 + .base = {
485 + .cra_name = "ecb(aes)",
486 + .cra_driver_name = "ecb-aes-ppc4xx",
487 + .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
488 + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER |
489 + CRYPTO_ALG_ASYNC |
490 + CRYPTO_ALG_KERN_DRIVER_ONLY,
491 + .cra_blocksize = AES_BLOCK_SIZE,
492 + .cra_ctxsize = sizeof(struct crypto4xx_ctx),
493 + .cra_module = THIS_MODULE,
494 + },
495 + .min_keysize = AES_MIN_KEY_SIZE,
496 + .max_keysize = AES_MAX_KEY_SIZE,
497 + .setkey = crypto4xx_setkey_aes_ecb,
498 + .encrypt = crypto4xx_encrypt_noiv,
499 + .decrypt = crypto4xx_decrypt_noiv,
500 + .init = crypto4xx_sk_init,
501 + .exit = crypto4xx_sk_exit,
502 + } },
503 + { .type = CRYPTO_ALG_TYPE_SKCIPHER, .u.cipher = {
504 + .base = {
505 + .cra_name = "ofb(aes)",
506 + .cra_driver_name = "ofb-aes-ppc4xx",
507 + .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY,
508 + .cra_flags = CRYPTO_ALG_TYPE_SKCIPHER |
509 + CRYPTO_ALG_ASYNC |
510 + CRYPTO_ALG_KERN_DRIVER_ONLY,
511 + .cra_blocksize = AES_BLOCK_SIZE,
512 + .cra_ctxsize = sizeof(struct crypto4xx_ctx),
513 + .cra_module = THIS_MODULE,
514 + },
515 + .min_keysize = AES_MIN_KEY_SIZE,
516 + .max_keysize = AES_MAX_KEY_SIZE,
517 + .ivsize = AES_IV_SIZE,
518 + .setkey = crypto4xx_setkey_aes_ofb,
519 + .encrypt = crypto4xx_encrypt_iv,
520 + .decrypt = crypto4xx_decrypt_iv,
521 + .init = crypto4xx_sk_init,
522 + .exit = crypto4xx_sk_exit,
523 } },
524
525 /* AEAD */
526 --- a/drivers/crypto/amcc/crypto4xx_core.h
527 +++ b/drivers/crypto/amcc/crypto4xx_core.h
528 @@ -25,6 +25,7 @@
529 #include <linux/ratelimit.h>
530 #include <crypto/internal/hash.h>
531 #include <crypto/internal/aead.h>
532 +#include <crypto/internal/skcipher.h>
533 #include "crypto4xx_reg_def.h"
534 #include "crypto4xx_sa.h"
535
536 @@ -134,7 +135,7 @@ struct crypto4xx_ctx {
537 struct crypto4xx_alg_common {
538 u32 type;
539 union {
540 - struct crypto_alg cipher;
541 + struct skcipher_alg cipher;
542 struct ahash_alg hash;
543 struct aead_alg aead;
544 } u;
545 @@ -158,22 +159,22 @@ int crypto4xx_build_pd(struct crypto_asy
546 const struct dynamic_sa_ctl *sa,
547 const unsigned int sa_len,
548 const unsigned int assoclen);
549 -int crypto4xx_setkey_aes_cbc(struct crypto_ablkcipher *cipher,
550 +int crypto4xx_setkey_aes_cbc(struct crypto_skcipher *cipher,
551 const u8 *key, unsigned int keylen);
552 -int crypto4xx_setkey_aes_cfb(struct crypto_ablkcipher *cipher,
553 +int crypto4xx_setkey_aes_cfb(struct crypto_skcipher *cipher,
554 const u8 *key, unsigned int keylen);
555 -int crypto4xx_setkey_aes_ecb(struct crypto_ablkcipher *cipher,
556 +int crypto4xx_setkey_aes_ecb(struct crypto_skcipher *cipher,
557 const u8 *key, unsigned int keylen);
558 -int crypto4xx_setkey_aes_ofb(struct crypto_ablkcipher *cipher,
559 +int crypto4xx_setkey_aes_ofb(struct crypto_skcipher *cipher,
560 const u8 *key, unsigned int keylen);
561 -int crypto4xx_setkey_rfc3686(struct crypto_ablkcipher *cipher,
562 +int crypto4xx_setkey_rfc3686(struct crypto_skcipher *cipher,
563 const u8 *key, unsigned int keylen);
564 -int crypto4xx_encrypt_iv(struct ablkcipher_request *req);
565 -int crypto4xx_decrypt_iv(struct ablkcipher_request *req);
566 -int crypto4xx_encrypt_noiv(struct ablkcipher_request *req);
567 -int crypto4xx_decrypt_noiv(struct ablkcipher_request *req);
568 -int crypto4xx_rfc3686_encrypt(struct ablkcipher_request *req);
569 -int crypto4xx_rfc3686_decrypt(struct ablkcipher_request *req);
570 +int crypto4xx_encrypt_iv(struct skcipher_request *req);
571 +int crypto4xx_decrypt_iv(struct skcipher_request *req);
572 +int crypto4xx_encrypt_noiv(struct skcipher_request *req);
573 +int crypto4xx_decrypt_noiv(struct skcipher_request *req);
574 +int crypto4xx_rfc3686_encrypt(struct skcipher_request *req);
575 +int crypto4xx_rfc3686_decrypt(struct skcipher_request *req);
576 int crypto4xx_sha1_alg_init(struct crypto_tfm *tfm);
577 int crypto4xx_hash_digest(struct ahash_request *req);
578 int crypto4xx_hash_final(struct ahash_request *req);