.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | |
---|
2 | 3 | /* |
---|
3 | 4 | * Copyright (C) 2016 Cavium, Inc. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify it |
---|
6 | | - * under the terms of version 2 of the GNU General Public License |
---|
7 | | - * as published by the Free Software Foundation. |
---|
8 | 5 | */ |
---|
9 | 6 | |
---|
10 | 7 | #include <crypto/aes.h> |
---|
11 | 8 | #include <crypto/algapi.h> |
---|
12 | 9 | #include <crypto/authenc.h> |
---|
13 | | -#include <crypto/cryptd.h> |
---|
14 | | -#include <crypto/crypto_wq.h> |
---|
15 | | -#include <crypto/des.h> |
---|
| 10 | +#include <crypto/internal/des.h> |
---|
16 | 11 | #include <crypto/xts.h> |
---|
17 | 12 | #include <linux/crypto.h> |
---|
18 | 13 | #include <linux/err.h> |
---|
.. | .. |
---|
97 | 92 | } |
---|
98 | 93 | } |
---|
99 | 94 | |
---|
100 | | -static inline u32 create_ctx_hdr(struct ablkcipher_request *req, u32 enc, |
---|
| 95 | +static inline u32 create_ctx_hdr(struct skcipher_request *req, u32 enc, |
---|
101 | 96 | u32 *argcnt) |
---|
102 | 97 | { |
---|
103 | | - struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); |
---|
104 | | - struct cvm_enc_ctx *ctx = crypto_ablkcipher_ctx(tfm); |
---|
105 | | - struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); |
---|
| 98 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
---|
| 99 | + struct cvm_enc_ctx *ctx = crypto_skcipher_ctx(tfm); |
---|
| 100 | + struct cvm_req_ctx *rctx = skcipher_request_ctx(req); |
---|
106 | 101 | struct fc_context *fctx = &rctx->fctx; |
---|
107 | | - u64 *offset_control = &rctx->control_word; |
---|
108 | | - u32 enc_iv_len = crypto_ablkcipher_ivsize(tfm); |
---|
| 102 | + u32 enc_iv_len = crypto_skcipher_ivsize(tfm); |
---|
109 | 103 | struct cpt_request_info *req_info = &rctx->cpt_req; |
---|
110 | | - u64 *ctrl_flags = NULL; |
---|
| 104 | + __be64 *ctrl_flags = NULL; |
---|
| 105 | + __be64 *offset_control; |
---|
111 | 106 | |
---|
112 | 107 | req_info->ctrl.s.grp = 0; |
---|
113 | 108 | req_info->ctrl.s.dma_mode = DMA_GATHER_SCATTER; |
---|
.. | .. |
---|
120 | 115 | else |
---|
121 | 116 | req_info->req.opcode.s.minor = 3; |
---|
122 | 117 | |
---|
123 | | - req_info->req.param1 = req->nbytes; /* Encryption Data length */ |
---|
| 118 | + req_info->req.param1 = req->cryptlen; /* Encryption Data length */ |
---|
124 | 119 | req_info->req.param2 = 0; /*Auth data length */ |
---|
125 | 120 | |
---|
126 | 121 | fctx->enc.enc_ctrl.e.enc_cipher = ctx->cipher_type; |
---|
.. | .. |
---|
131 | 126 | memcpy(fctx->enc.encr_key, ctx->enc_key, ctx->key_len * 2); |
---|
132 | 127 | else |
---|
133 | 128 | memcpy(fctx->enc.encr_key, ctx->enc_key, ctx->key_len); |
---|
134 | | - ctrl_flags = (u64 *)&fctx->enc.enc_ctrl.flags; |
---|
135 | | - *ctrl_flags = cpu_to_be64(*ctrl_flags); |
---|
| 129 | + ctrl_flags = (__be64 *)&fctx->enc.enc_ctrl.flags; |
---|
| 130 | + *ctrl_flags = cpu_to_be64(fctx->enc.enc_ctrl.flags); |
---|
136 | 131 | |
---|
| 132 | + offset_control = (__be64 *)&rctx->control_word; |
---|
137 | 133 | *offset_control = cpu_to_be64(((u64)(enc_iv_len) << 16)); |
---|
138 | 134 | /* Storing Packet Data Information in offset |
---|
139 | 135 | * Control Word First 8 bytes |
---|
.. | .. |
---|
152 | 148 | return 0; |
---|
153 | 149 | } |
---|
154 | 150 | |
---|
155 | | -static inline u32 create_input_list(struct ablkcipher_request *req, u32 enc, |
---|
| 151 | +static inline u32 create_input_list(struct skcipher_request *req, u32 enc, |
---|
156 | 152 | u32 enc_iv_len) |
---|
157 | 153 | { |
---|
158 | | - struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); |
---|
| 154 | + struct cvm_req_ctx *rctx = skcipher_request_ctx(req); |
---|
159 | 155 | struct cpt_request_info *req_info = &rctx->cpt_req; |
---|
160 | 156 | u32 argcnt = 0; |
---|
161 | 157 | |
---|
162 | 158 | create_ctx_hdr(req, enc, &argcnt); |
---|
163 | | - update_input_iv(req_info, req->info, enc_iv_len, &argcnt); |
---|
164 | | - update_input_data(req_info, req->src, req->nbytes, &argcnt); |
---|
| 159 | + update_input_iv(req_info, req->iv, enc_iv_len, &argcnt); |
---|
| 160 | + update_input_data(req_info, req->src, req->cryptlen, &argcnt); |
---|
165 | 161 | req_info->incnt = argcnt; |
---|
166 | 162 | |
---|
167 | 163 | return 0; |
---|
168 | 164 | } |
---|
169 | 165 | |
---|
170 | | -static inline void store_cb_info(struct ablkcipher_request *req, |
---|
| 166 | +static inline void store_cb_info(struct skcipher_request *req, |
---|
171 | 167 | struct cpt_request_info *req_info) |
---|
172 | 168 | { |
---|
173 | 169 | req_info->callback = (void *)cvm_callback; |
---|
174 | 170 | req_info->callback_arg = (void *)&req->base; |
---|
175 | 171 | } |
---|
176 | 172 | |
---|
177 | | -static inline void create_output_list(struct ablkcipher_request *req, |
---|
| 173 | +static inline void create_output_list(struct skcipher_request *req, |
---|
178 | 174 | u32 enc_iv_len) |
---|
179 | 175 | { |
---|
180 | | - struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); |
---|
| 176 | + struct cvm_req_ctx *rctx = skcipher_request_ctx(req); |
---|
181 | 177 | struct cpt_request_info *req_info = &rctx->cpt_req; |
---|
182 | 178 | u32 argcnt = 0; |
---|
183 | 179 | |
---|
.. | .. |
---|
189 | 185 | * [ 16 Bytes/ [ Request Enc/Dec/ DATA Len AES CBC ] |
---|
190 | 186 | */ |
---|
191 | 187 | /* Reading IV information */ |
---|
192 | | - update_output_iv(req_info, req->info, enc_iv_len, &argcnt); |
---|
193 | | - update_output_data(req_info, req->dst, req->nbytes, &argcnt); |
---|
| 188 | + update_output_iv(req_info, req->iv, enc_iv_len, &argcnt); |
---|
| 189 | + update_output_data(req_info, req->dst, req->cryptlen, &argcnt); |
---|
194 | 190 | req_info->outcnt = argcnt; |
---|
195 | 191 | } |
---|
196 | 192 | |
---|
197 | | -static inline int cvm_enc_dec(struct ablkcipher_request *req, u32 enc) |
---|
| 193 | +static inline int cvm_enc_dec(struct skcipher_request *req, u32 enc) |
---|
198 | 194 | { |
---|
199 | | - struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); |
---|
200 | | - struct cvm_req_ctx *rctx = ablkcipher_request_ctx(req); |
---|
201 | | - u32 enc_iv_len = crypto_ablkcipher_ivsize(tfm); |
---|
| 195 | + struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); |
---|
| 196 | + struct cvm_req_ctx *rctx = skcipher_request_ctx(req); |
---|
| 197 | + u32 enc_iv_len = crypto_skcipher_ivsize(tfm); |
---|
202 | 198 | struct fc_context *fctx = &rctx->fctx; |
---|
203 | 199 | struct cpt_request_info *req_info = &rctx->cpt_req; |
---|
204 | 200 | void *cdev = NULL; |
---|
.. | .. |
---|
223 | 219 | return -EINPROGRESS; |
---|
224 | 220 | } |
---|
225 | 221 | |
---|
226 | | -static int cvm_encrypt(struct ablkcipher_request *req) |
---|
| 222 | +static int cvm_encrypt(struct skcipher_request *req) |
---|
227 | 223 | { |
---|
228 | 224 | return cvm_enc_dec(req, true); |
---|
229 | 225 | } |
---|
230 | 226 | |
---|
231 | | -static int cvm_decrypt(struct ablkcipher_request *req) |
---|
| 227 | +static int cvm_decrypt(struct skcipher_request *req) |
---|
232 | 228 | { |
---|
233 | 229 | return cvm_enc_dec(req, false); |
---|
234 | 230 | } |
---|
235 | 231 | |
---|
236 | | -static int cvm_xts_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 232 | +static int cvm_xts_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
237 | 233 | u32 keylen) |
---|
238 | 234 | { |
---|
239 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
| 235 | + struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); |
---|
240 | 236 | struct cvm_enc_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
241 | 237 | int err; |
---|
242 | 238 | const u8 *key1 = key; |
---|
.. | .. |
---|
290 | 286 | return -EINVAL; |
---|
291 | 287 | } |
---|
292 | 288 | |
---|
293 | | -static int cvm_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 289 | +static int cvm_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
294 | 290 | u32 keylen, u8 cipher_type) |
---|
295 | 291 | { |
---|
296 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
| 292 | + struct crypto_tfm *tfm = crypto_skcipher_tfm(cipher); |
---|
297 | 293 | struct cvm_enc_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
298 | 294 | |
---|
299 | 295 | ctx->cipher_type = cipher_type; |
---|
.. | .. |
---|
301 | 297 | memcpy(ctx->enc_key, key, keylen); |
---|
302 | 298 | return 0; |
---|
303 | 299 | } else { |
---|
304 | | - crypto_ablkcipher_set_flags(cipher, |
---|
305 | | - CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
306 | 300 | return -EINVAL; |
---|
307 | 301 | } |
---|
308 | 302 | } |
---|
309 | 303 | |
---|
310 | | -static int cvm_cbc_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 304 | +static int cvm_cbc_aes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
311 | 305 | u32 keylen) |
---|
312 | 306 | { |
---|
313 | 307 | return cvm_setkey(cipher, key, keylen, AES_CBC); |
---|
314 | 308 | } |
---|
315 | 309 | |
---|
316 | | -static int cvm_ecb_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 310 | +static int cvm_ecb_aes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
317 | 311 | u32 keylen) |
---|
318 | 312 | { |
---|
319 | 313 | return cvm_setkey(cipher, key, keylen, AES_ECB); |
---|
320 | 314 | } |
---|
321 | 315 | |
---|
322 | | -static int cvm_cfb_aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 316 | +static int cvm_cfb_aes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
323 | 317 | u32 keylen) |
---|
324 | 318 | { |
---|
325 | 319 | return cvm_setkey(cipher, key, keylen, AES_CFB); |
---|
326 | 320 | } |
---|
327 | 321 | |
---|
328 | | -static int cvm_cbc_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 322 | +static int cvm_cbc_des3_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
329 | 323 | u32 keylen) |
---|
330 | 324 | { |
---|
331 | | - return cvm_setkey(cipher, key, keylen, DES3_CBC); |
---|
| 325 | + return verify_skcipher_des3_key(cipher, key) ?: |
---|
| 326 | + cvm_setkey(cipher, key, keylen, DES3_CBC); |
---|
332 | 327 | } |
---|
333 | 328 | |
---|
334 | | -static int cvm_ecb_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 329 | +static int cvm_ecb_des3_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
335 | 330 | u32 keylen) |
---|
336 | 331 | { |
---|
337 | | - return cvm_setkey(cipher, key, keylen, DES3_ECB); |
---|
| 332 | + return verify_skcipher_des3_key(cipher, key) ?: |
---|
| 333 | + cvm_setkey(cipher, key, keylen, DES3_ECB); |
---|
338 | 334 | } |
---|
339 | 335 | |
---|
340 | | -static int cvm_enc_dec_init(struct crypto_tfm *tfm) |
---|
| 336 | +static int cvm_enc_dec_init(struct crypto_skcipher *tfm) |
---|
341 | 337 | { |
---|
342 | | - struct cvm_enc_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
343 | | - |
---|
344 | | - memset(ctx, 0, sizeof(*ctx)); |
---|
345 | | - tfm->crt_ablkcipher.reqsize = sizeof(struct cvm_req_ctx) + |
---|
346 | | - sizeof(struct ablkcipher_request); |
---|
347 | | - /* Additional memory for ablkcipher_request is |
---|
348 | | - * allocated since the cryptd daemon uses |
---|
349 | | - * this memory for request_ctx information |
---|
350 | | - */ |
---|
| 338 | + crypto_skcipher_set_reqsize(tfm, sizeof(struct cvm_req_ctx)); |
---|
351 | 339 | |
---|
352 | 340 | return 0; |
---|
353 | 341 | } |
---|
354 | 342 | |
---|
355 | | -static struct crypto_alg algs[] = { { |
---|
356 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
357 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
358 | | - .cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
359 | | - .cra_alignmask = 7, |
---|
360 | | - .cra_priority = 4001, |
---|
361 | | - .cra_name = "xts(aes)", |
---|
362 | | - .cra_driver_name = "cavium-xts-aes", |
---|
363 | | - .cra_type = &crypto_ablkcipher_type, |
---|
364 | | - .cra_u = { |
---|
365 | | - .ablkcipher = { |
---|
366 | | - .ivsize = AES_BLOCK_SIZE, |
---|
367 | | - .min_keysize = 2 * AES_MIN_KEY_SIZE, |
---|
368 | | - .max_keysize = 2 * AES_MAX_KEY_SIZE, |
---|
369 | | - .setkey = cvm_xts_setkey, |
---|
370 | | - .encrypt = cvm_encrypt, |
---|
371 | | - .decrypt = cvm_decrypt, |
---|
372 | | - }, |
---|
373 | | - }, |
---|
374 | | - .cra_init = cvm_enc_dec_init, |
---|
375 | | - .cra_module = THIS_MODULE, |
---|
| 343 | +static struct skcipher_alg algs[] = { { |
---|
| 344 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 345 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 346 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 347 | + .base.cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
| 348 | + .base.cra_alignmask = 7, |
---|
| 349 | + .base.cra_priority = 4001, |
---|
| 350 | + .base.cra_name = "xts(aes)", |
---|
| 351 | + .base.cra_driver_name = "cavium-xts-aes", |
---|
| 352 | + .base.cra_module = THIS_MODULE, |
---|
| 353 | + |
---|
| 354 | + .ivsize = AES_BLOCK_SIZE, |
---|
| 355 | + .min_keysize = 2 * AES_MIN_KEY_SIZE, |
---|
| 356 | + .max_keysize = 2 * AES_MAX_KEY_SIZE, |
---|
| 357 | + .setkey = cvm_xts_setkey, |
---|
| 358 | + .encrypt = cvm_encrypt, |
---|
| 359 | + .decrypt = cvm_decrypt, |
---|
| 360 | + .init = cvm_enc_dec_init, |
---|
376 | 361 | }, { |
---|
377 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
378 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
379 | | - .cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
380 | | - .cra_alignmask = 7, |
---|
381 | | - .cra_priority = 4001, |
---|
382 | | - .cra_name = "cbc(aes)", |
---|
383 | | - .cra_driver_name = "cavium-cbc-aes", |
---|
384 | | - .cra_type = &crypto_ablkcipher_type, |
---|
385 | | - .cra_u = { |
---|
386 | | - .ablkcipher = { |
---|
387 | | - .ivsize = AES_BLOCK_SIZE, |
---|
388 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
389 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
390 | | - .setkey = cvm_cbc_aes_setkey, |
---|
391 | | - .encrypt = cvm_encrypt, |
---|
392 | | - .decrypt = cvm_decrypt, |
---|
393 | | - }, |
---|
394 | | - }, |
---|
395 | | - .cra_init = cvm_enc_dec_init, |
---|
396 | | - .cra_module = THIS_MODULE, |
---|
| 362 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 363 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 364 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 365 | + .base.cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
| 366 | + .base.cra_alignmask = 7, |
---|
| 367 | + .base.cra_priority = 4001, |
---|
| 368 | + .base.cra_name = "cbc(aes)", |
---|
| 369 | + .base.cra_driver_name = "cavium-cbc-aes", |
---|
| 370 | + .base.cra_module = THIS_MODULE, |
---|
| 371 | + |
---|
| 372 | + .ivsize = AES_BLOCK_SIZE, |
---|
| 373 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 374 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 375 | + .setkey = cvm_cbc_aes_setkey, |
---|
| 376 | + .encrypt = cvm_encrypt, |
---|
| 377 | + .decrypt = cvm_decrypt, |
---|
| 378 | + .init = cvm_enc_dec_init, |
---|
397 | 379 | }, { |
---|
398 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
399 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
400 | | - .cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
401 | | - .cra_alignmask = 7, |
---|
402 | | - .cra_priority = 4001, |
---|
403 | | - .cra_name = "ecb(aes)", |
---|
404 | | - .cra_driver_name = "cavium-ecb-aes", |
---|
405 | | - .cra_type = &crypto_ablkcipher_type, |
---|
406 | | - .cra_u = { |
---|
407 | | - .ablkcipher = { |
---|
408 | | - .ivsize = AES_BLOCK_SIZE, |
---|
409 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
410 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
411 | | - .setkey = cvm_ecb_aes_setkey, |
---|
412 | | - .encrypt = cvm_encrypt, |
---|
413 | | - .decrypt = cvm_decrypt, |
---|
414 | | - }, |
---|
415 | | - }, |
---|
416 | | - .cra_init = cvm_enc_dec_init, |
---|
417 | | - .cra_module = THIS_MODULE, |
---|
| 380 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 381 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 382 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 383 | + .base.cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
| 384 | + .base.cra_alignmask = 7, |
---|
| 385 | + .base.cra_priority = 4001, |
---|
| 386 | + .base.cra_name = "ecb(aes)", |
---|
| 387 | + .base.cra_driver_name = "cavium-ecb-aes", |
---|
| 388 | + .base.cra_module = THIS_MODULE, |
---|
| 389 | + |
---|
| 390 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 391 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 392 | + .setkey = cvm_ecb_aes_setkey, |
---|
| 393 | + .encrypt = cvm_encrypt, |
---|
| 394 | + .decrypt = cvm_decrypt, |
---|
| 395 | + .init = cvm_enc_dec_init, |
---|
418 | 396 | }, { |
---|
419 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
420 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
421 | | - .cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
422 | | - .cra_alignmask = 7, |
---|
423 | | - .cra_priority = 4001, |
---|
424 | | - .cra_name = "cfb(aes)", |
---|
425 | | - .cra_driver_name = "cavium-cfb-aes", |
---|
426 | | - .cra_type = &crypto_ablkcipher_type, |
---|
427 | | - .cra_u = { |
---|
428 | | - .ablkcipher = { |
---|
429 | | - .ivsize = AES_BLOCK_SIZE, |
---|
430 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
431 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
432 | | - .setkey = cvm_cfb_aes_setkey, |
---|
433 | | - .encrypt = cvm_encrypt, |
---|
434 | | - .decrypt = cvm_decrypt, |
---|
435 | | - }, |
---|
436 | | - }, |
---|
437 | | - .cra_init = cvm_enc_dec_init, |
---|
438 | | - .cra_module = THIS_MODULE, |
---|
| 397 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 398 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 399 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 400 | + .base.cra_ctxsize = sizeof(struct cvm_enc_ctx), |
---|
| 401 | + .base.cra_alignmask = 7, |
---|
| 402 | + .base.cra_priority = 4001, |
---|
| 403 | + .base.cra_name = "cfb(aes)", |
---|
| 404 | + .base.cra_driver_name = "cavium-cfb-aes", |
---|
| 405 | + .base.cra_module = THIS_MODULE, |
---|
| 406 | + |
---|
| 407 | + .ivsize = AES_BLOCK_SIZE, |
---|
| 408 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 409 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 410 | + .setkey = cvm_cfb_aes_setkey, |
---|
| 411 | + .encrypt = cvm_encrypt, |
---|
| 412 | + .decrypt = cvm_decrypt, |
---|
| 413 | + .init = cvm_enc_dec_init, |
---|
439 | 414 | }, { |
---|
440 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
441 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
442 | | - .cra_ctxsize = sizeof(struct cvm_des3_ctx), |
---|
443 | | - .cra_alignmask = 7, |
---|
444 | | - .cra_priority = 4001, |
---|
445 | | - .cra_name = "cbc(des3_ede)", |
---|
446 | | - .cra_driver_name = "cavium-cbc-des3_ede", |
---|
447 | | - .cra_type = &crypto_ablkcipher_type, |
---|
448 | | - .cra_u = { |
---|
449 | | - .ablkcipher = { |
---|
450 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
451 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
452 | | - .ivsize = DES_BLOCK_SIZE, |
---|
453 | | - .setkey = cvm_cbc_des3_setkey, |
---|
454 | | - .encrypt = cvm_encrypt, |
---|
455 | | - .decrypt = cvm_decrypt, |
---|
456 | | - }, |
---|
457 | | - }, |
---|
458 | | - .cra_init = cvm_enc_dec_init, |
---|
459 | | - .cra_module = THIS_MODULE, |
---|
| 415 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 416 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 417 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 418 | + .base.cra_ctxsize = sizeof(struct cvm_des3_ctx), |
---|
| 419 | + .base.cra_alignmask = 7, |
---|
| 420 | + .base.cra_priority = 4001, |
---|
| 421 | + .base.cra_name = "cbc(des3_ede)", |
---|
| 422 | + .base.cra_driver_name = "cavium-cbc-des3_ede", |
---|
| 423 | + .base.cra_module = THIS_MODULE, |
---|
| 424 | + |
---|
| 425 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 426 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 427 | + .ivsize = DES_BLOCK_SIZE, |
---|
| 428 | + .setkey = cvm_cbc_des3_setkey, |
---|
| 429 | + .encrypt = cvm_encrypt, |
---|
| 430 | + .decrypt = cvm_decrypt, |
---|
| 431 | + .init = cvm_enc_dec_init, |
---|
460 | 432 | }, { |
---|
461 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC, |
---|
462 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
463 | | - .cra_ctxsize = sizeof(struct cvm_des3_ctx), |
---|
464 | | - .cra_alignmask = 7, |
---|
465 | | - .cra_priority = 4001, |
---|
466 | | - .cra_name = "ecb(des3_ede)", |
---|
467 | | - .cra_driver_name = "cavium-ecb-des3_ede", |
---|
468 | | - .cra_type = &crypto_ablkcipher_type, |
---|
469 | | - .cra_u = { |
---|
470 | | - .ablkcipher = { |
---|
471 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
472 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
473 | | - .ivsize = DES_BLOCK_SIZE, |
---|
474 | | - .setkey = cvm_ecb_des3_setkey, |
---|
475 | | - .encrypt = cvm_encrypt, |
---|
476 | | - .decrypt = cvm_decrypt, |
---|
477 | | - }, |
---|
478 | | - }, |
---|
479 | | - .cra_init = cvm_enc_dec_init, |
---|
480 | | - .cra_module = THIS_MODULE, |
---|
| 433 | + .base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 434 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
| 435 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 436 | + .base.cra_ctxsize = sizeof(struct cvm_des3_ctx), |
---|
| 437 | + .base.cra_alignmask = 7, |
---|
| 438 | + .base.cra_priority = 4001, |
---|
| 439 | + .base.cra_name = "ecb(des3_ede)", |
---|
| 440 | + .base.cra_driver_name = "cavium-ecb-des3_ede", |
---|
| 441 | + .base.cra_module = THIS_MODULE, |
---|
| 442 | + |
---|
| 443 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 444 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 445 | + .ivsize = DES_BLOCK_SIZE, |
---|
| 446 | + .setkey = cvm_ecb_des3_setkey, |
---|
| 447 | + .encrypt = cvm_encrypt, |
---|
| 448 | + .decrypt = cvm_decrypt, |
---|
| 449 | + .init = cvm_enc_dec_init, |
---|
481 | 450 | } }; |
---|
482 | 451 | |
---|
483 | 452 | static inline int cav_register_algs(void) |
---|
484 | 453 | { |
---|
485 | | - int err = 0; |
---|
486 | | - |
---|
487 | | - err = crypto_register_algs(algs, ARRAY_SIZE(algs)); |
---|
488 | | - if (err) |
---|
489 | | - return err; |
---|
490 | | - |
---|
491 | | - return 0; |
---|
| 454 | + return crypto_register_skciphers(algs, ARRAY_SIZE(algs)); |
---|
492 | 455 | } |
---|
493 | 456 | |
---|
494 | 457 | static inline void cav_unregister_algs(void) |
---|
495 | 458 | { |
---|
496 | | - crypto_unregister_algs(algs, ARRAY_SIZE(algs)); |
---|
| 459 | + crypto_unregister_skciphers(algs, ARRAY_SIZE(algs)); |
---|
497 | 460 | } |
---|
498 | 461 | |
---|
499 | 462 | int cvm_crypto_init(struct cpt_vf *cptvf) |
---|