.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Copyright 2016 Broadcom |
---|
3 | | - * |
---|
4 | | - * This program is free software; you can redistribute it and/or modify |
---|
5 | | - * it under the terms of the GNU General Public License, version 2, as |
---|
6 | | - * published by the Free Software Foundation (the "GPL"). |
---|
7 | | - * |
---|
8 | | - * This program is distributed in the hope that it will be useful, but |
---|
9 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
11 | | - * General Public License version 2 (GPLv2) for more details. |
---|
12 | | - * |
---|
13 | | - * You should have received a copy of the GNU General Public License |
---|
14 | | - * version 2 (GPLv2) along with this source code. |
---|
15 | 4 | */ |
---|
16 | 5 | |
---|
17 | 6 | #include <linux/err.h> |
---|
.. | .. |
---|
35 | 24 | #include <crypto/aead.h> |
---|
36 | 25 | #include <crypto/internal/aead.h> |
---|
37 | 26 | #include <crypto/aes.h> |
---|
38 | | -#include <crypto/des.h> |
---|
| 27 | +#include <crypto/internal/des.h> |
---|
39 | 28 | #include <crypto/hmac.h> |
---|
40 | 29 | #include <crypto/sha.h> |
---|
41 | 30 | #include <crypto/md5.h> |
---|
.. | .. |
---|
96 | 85 | * 0x70 - ring 2 |
---|
97 | 86 | * 0x78 - ring 3 |
---|
98 | 87 | */ |
---|
99 | | -char BCMHEADER[] = { 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28 }; |
---|
| 88 | +static char BCMHEADER[] = { 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28 }; |
---|
100 | 89 | /* |
---|
101 | 90 | * Some SPU hw does not use BCM header on SPU messages. So BCM_HDR_LEN |
---|
102 | 91 | * is set dynamically after reading SPU type from device tree. |
---|
.. | .. |
---|
121 | 110 | } |
---|
122 | 111 | |
---|
123 | 112 | /** |
---|
124 | | - * spu_ablkcipher_rx_sg_create() - Build up the scatterlist of buffers used to |
---|
125 | | - * receive a SPU response message for an ablkcipher request. Includes buffers to |
---|
| 113 | + * spu_skcipher_rx_sg_create() - Build up the scatterlist of buffers used to |
---|
| 114 | + * receive a SPU response message for an skcipher request. Includes buffers to |
---|
126 | 115 | * catch SPU message headers and the response data. |
---|
127 | 116 | * @mssg: mailbox message containing the receive sg |
---|
128 | 117 | * @rctx: crypto request context |
---|
.. | .. |
---|
141 | 130 | * < 0 if an error |
---|
142 | 131 | */ |
---|
143 | 132 | static int |
---|
144 | | -spu_ablkcipher_rx_sg_create(struct brcm_message *mssg, |
---|
| 133 | +spu_skcipher_rx_sg_create(struct brcm_message *mssg, |
---|
145 | 134 | struct iproc_reqctx_s *rctx, |
---|
146 | 135 | u8 rx_frag_num, |
---|
147 | 136 | unsigned int chunksize, u32 stat_pad_len) |
---|
.. | .. |
---|
176 | 165 | return -EFAULT; |
---|
177 | 166 | } |
---|
178 | 167 | |
---|
179 | | - if (ctx->cipher.alg == CIPHER_ALG_RC4) |
---|
180 | | - /* Add buffer to catch 260-byte SUPDT field for RC4 */ |
---|
181 | | - sg_set_buf(sg++, rctx->msg_buf.c.supdt_tweak, SPU_SUPDT_LEN); |
---|
182 | | - |
---|
183 | 168 | if (stat_pad_len) |
---|
184 | 169 | sg_set_buf(sg++, rctx->msg_buf.rx_stat_pad, stat_pad_len); |
---|
185 | 170 | |
---|
.. | .. |
---|
190 | 175 | } |
---|
191 | 176 | |
---|
192 | 177 | /** |
---|
193 | | - * spu_ablkcipher_tx_sg_create() - Build up the scatterlist of buffers used to |
---|
194 | | - * send a SPU request message for an ablkcipher request. Includes SPU message |
---|
| 178 | + * spu_skcipher_tx_sg_create() - Build up the scatterlist of buffers used to |
---|
| 179 | + * send a SPU request message for an skcipher request. Includes SPU message |
---|
195 | 180 | * headers and the request data. |
---|
196 | 181 | * @mssg: mailbox message containing the transmit sg |
---|
197 | 182 | * @rctx: crypto request context |
---|
.. | .. |
---|
209 | 194 | * < 0 if an error |
---|
210 | 195 | */ |
---|
211 | 196 | static int |
---|
212 | | -spu_ablkcipher_tx_sg_create(struct brcm_message *mssg, |
---|
| 197 | +spu_skcipher_tx_sg_create(struct brcm_message *mssg, |
---|
213 | 198 | struct iproc_reqctx_s *rctx, |
---|
214 | 199 | u8 tx_frag_num, unsigned int chunksize, u32 pad_len) |
---|
215 | 200 | { |
---|
.. | .. |
---|
294 | 279 | } |
---|
295 | 280 | |
---|
296 | 281 | /** |
---|
297 | | - * handle_ablkcipher_req() - Submit as much of a block cipher request as fits in |
---|
| 282 | + * handle_skcipher_req() - Submit as much of a block cipher request as fits in |
---|
298 | 283 | * a single SPU request message, starting at the current position in the request |
---|
299 | 284 | * data. |
---|
300 | 285 | * @rctx: Crypto request context |
---|
.. | .. |
---|
311 | 296 | * asynchronously |
---|
312 | 297 | * Any other value indicates an error |
---|
313 | 298 | */ |
---|
314 | | -static int handle_ablkcipher_req(struct iproc_reqctx_s *rctx) |
---|
| 299 | +static int handle_skcipher_req(struct iproc_reqctx_s *rctx) |
---|
315 | 300 | { |
---|
316 | 301 | struct spu_hw *spu = &iproc_priv.spu; |
---|
317 | 302 | struct crypto_async_request *areq = rctx->parent; |
---|
318 | | - struct ablkcipher_request *req = |
---|
319 | | - container_of(areq, struct ablkcipher_request, base); |
---|
| 303 | + struct skcipher_request *req = |
---|
| 304 | + container_of(areq, struct skcipher_request, base); |
---|
320 | 305 | struct iproc_ctx_s *ctx = rctx->ctx; |
---|
321 | 306 | struct spu_cipher_parms cipher_parms; |
---|
322 | | - int err = 0; |
---|
323 | | - unsigned int chunksize = 0; /* Num bytes of request to submit */ |
---|
324 | | - int remaining = 0; /* Bytes of request still to process */ |
---|
| 307 | + int err; |
---|
| 308 | + unsigned int chunksize; /* Num bytes of request to submit */ |
---|
| 309 | + int remaining; /* Bytes of request still to process */ |
---|
325 | 310 | int chunk_start; /* Beginning of data for current SPU msg */ |
---|
326 | 311 | |
---|
327 | 312 | /* IV or ctr value to use in this SPU msg */ |
---|
328 | 313 | u8 local_iv_ctr[MAX_IV_SIZE]; |
---|
329 | 314 | u32 stat_pad_len; /* num bytes to align status field */ |
---|
330 | 315 | u32 pad_len; /* total length of all padding */ |
---|
331 | | - bool update_key = false; |
---|
332 | 316 | struct brcm_message *mssg; /* mailbox message */ |
---|
333 | 317 | |
---|
334 | 318 | /* number of entries in src and dst sg in mailbox message. */ |
---|
.. | .. |
---|
402 | 386 | } |
---|
403 | 387 | } |
---|
404 | 388 | |
---|
405 | | - if (ctx->cipher.alg == CIPHER_ALG_RC4) { |
---|
406 | | - rx_frag_num++; |
---|
407 | | - if (chunk_start) { |
---|
408 | | - /* |
---|
409 | | - * for non-first RC4 chunks, use SUPDT from previous |
---|
410 | | - * response as key for this chunk. |
---|
411 | | - */ |
---|
412 | | - cipher_parms.key_buf = rctx->msg_buf.c.supdt_tweak; |
---|
413 | | - update_key = true; |
---|
414 | | - cipher_parms.type = CIPHER_TYPE_UPDT; |
---|
415 | | - } else if (!rctx->is_encrypt) { |
---|
416 | | - /* |
---|
417 | | - * First RC4 chunk. For decrypt, key in pre-built msg |
---|
418 | | - * header may have been changed if encrypt required |
---|
419 | | - * multiple chunks. So revert the key to the |
---|
420 | | - * ctx->enckey value. |
---|
421 | | - */ |
---|
422 | | - update_key = true; |
---|
423 | | - cipher_parms.type = CIPHER_TYPE_INIT; |
---|
424 | | - } |
---|
425 | | - } |
---|
426 | | - |
---|
427 | 389 | if (ctx->max_payload == SPU_MAX_PAYLOAD_INF) |
---|
428 | 390 | flow_log("max_payload infinite\n"); |
---|
429 | 391 | else |
---|
.. | .. |
---|
436 | 398 | memcpy(rctx->msg_buf.bcm_spu_req_hdr, ctx->bcm_spu_req_hdr, |
---|
437 | 399 | sizeof(rctx->msg_buf.bcm_spu_req_hdr)); |
---|
438 | 400 | |
---|
439 | | - /* |
---|
440 | | - * Pass SUPDT field as key. Key field in finish() call is only used |
---|
441 | | - * when update_key has been set above for RC4. Will be ignored in |
---|
442 | | - * all other cases. |
---|
443 | | - */ |
---|
444 | 401 | spu->spu_cipher_req_finish(rctx->msg_buf.bcm_spu_req_hdr + BCM_HDR_LEN, |
---|
445 | 402 | ctx->spu_req_hdr_len, !(rctx->is_encrypt), |
---|
446 | | - &cipher_parms, update_key, chunksize); |
---|
| 403 | + &cipher_parms, chunksize); |
---|
447 | 404 | |
---|
448 | 405 | atomic64_add(chunksize, &iproc_priv.bytes_out); |
---|
449 | 406 | |
---|
.. | .. |
---|
479 | 436 | spu->spu_xts_tweak_in_payload()) |
---|
480 | 437 | rx_frag_num++; /* extra sg to insert tweak */ |
---|
481 | 438 | |
---|
482 | | - err = spu_ablkcipher_rx_sg_create(mssg, rctx, rx_frag_num, chunksize, |
---|
| 439 | + err = spu_skcipher_rx_sg_create(mssg, rctx, rx_frag_num, chunksize, |
---|
483 | 440 | stat_pad_len); |
---|
484 | 441 | if (err) |
---|
485 | 442 | return err; |
---|
.. | .. |
---|
493 | 450 | spu->spu_xts_tweak_in_payload()) |
---|
494 | 451 | tx_frag_num++; /* extra sg to insert tweak */ |
---|
495 | 452 | |
---|
496 | | - err = spu_ablkcipher_tx_sg_create(mssg, rctx, tx_frag_num, chunksize, |
---|
| 453 | + err = spu_skcipher_tx_sg_create(mssg, rctx, tx_frag_num, chunksize, |
---|
497 | 454 | pad_len); |
---|
498 | 455 | if (err) |
---|
499 | 456 | return err; |
---|
.. | .. |
---|
506 | 463 | } |
---|
507 | 464 | |
---|
508 | 465 | /** |
---|
509 | | - * handle_ablkcipher_resp() - Process a block cipher SPU response. Updates the |
---|
| 466 | + * handle_skcipher_resp() - Process a block cipher SPU response. Updates the |
---|
510 | 467 | * total received count for the request and updates global stats. |
---|
511 | 468 | * @rctx: Crypto request context |
---|
512 | 469 | */ |
---|
513 | | -static void handle_ablkcipher_resp(struct iproc_reqctx_s *rctx) |
---|
| 470 | +static void handle_skcipher_resp(struct iproc_reqctx_s *rctx) |
---|
514 | 471 | { |
---|
515 | 472 | struct spu_hw *spu = &iproc_priv.spu; |
---|
516 | 473 | #ifdef DEBUG |
---|
517 | 474 | struct crypto_async_request *areq = rctx->parent; |
---|
518 | | - struct ablkcipher_request *req = ablkcipher_request_cast(areq); |
---|
| 475 | + struct skcipher_request *req = skcipher_request_cast(areq); |
---|
519 | 476 | #endif |
---|
520 | 477 | struct iproc_ctx_s *ctx = rctx->ctx; |
---|
521 | 478 | u32 payload_len; |
---|
.. | .. |
---|
538 | 495 | __func__, rctx->total_received, payload_len); |
---|
539 | 496 | |
---|
540 | 497 | dump_sg(req->dst, rctx->total_received, payload_len); |
---|
541 | | - if (ctx->cipher.alg == CIPHER_ALG_RC4) |
---|
542 | | - packet_dump(" supdt ", rctx->msg_buf.c.supdt_tweak, |
---|
543 | | - SPU_SUPDT_LEN); |
---|
544 | 498 | |
---|
545 | 499 | rctx->total_received += payload_len; |
---|
546 | 500 | if (rctx->total_received == rctx->total_todo) { |
---|
.. | .. |
---|
709 | 663 | |
---|
710 | 664 | /* number of bytes still to be hashed in this req */ |
---|
711 | 665 | unsigned int nbytes_to_hash = 0; |
---|
712 | | - int err = 0; |
---|
| 666 | + int err; |
---|
713 | 667 | unsigned int chunksize = 0; /* length of hash carry + new data */ |
---|
714 | 668 | /* |
---|
715 | 669 | * length of new data, not from hash carry, to be submitted in |
---|
.. | .. |
---|
1675 | 1629 | struct spu_hw *spu = &iproc_priv.spu; |
---|
1676 | 1630 | struct brcm_message *mssg = msg; |
---|
1677 | 1631 | struct iproc_reqctx_s *rctx; |
---|
1678 | | - int err = 0; |
---|
| 1632 | + int err; |
---|
1679 | 1633 | |
---|
1680 | 1634 | rctx = mssg->ctx; |
---|
1681 | 1635 | if (unlikely(!rctx)) { |
---|
.. | .. |
---|
1696 | 1650 | |
---|
1697 | 1651 | /* Process the SPU response message */ |
---|
1698 | 1652 | switch (rctx->ctx->alg->type) { |
---|
1699 | | - case CRYPTO_ALG_TYPE_ABLKCIPHER: |
---|
1700 | | - handle_ablkcipher_resp(rctx); |
---|
| 1653 | + case CRYPTO_ALG_TYPE_SKCIPHER: |
---|
| 1654 | + handle_skcipher_resp(rctx); |
---|
1701 | 1655 | break; |
---|
1702 | 1656 | case CRYPTO_ALG_TYPE_AHASH: |
---|
1703 | 1657 | handle_ahash_resp(rctx); |
---|
.. | .. |
---|
1719 | 1673 | spu_chunk_cleanup(rctx); |
---|
1720 | 1674 | |
---|
1721 | 1675 | switch (rctx->ctx->alg->type) { |
---|
1722 | | - case CRYPTO_ALG_TYPE_ABLKCIPHER: |
---|
1723 | | - err = handle_ablkcipher_req(rctx); |
---|
| 1676 | + case CRYPTO_ALG_TYPE_SKCIPHER: |
---|
| 1677 | + err = handle_skcipher_req(rctx); |
---|
1724 | 1678 | break; |
---|
1725 | 1679 | case CRYPTO_ALG_TYPE_AHASH: |
---|
1726 | 1680 | err = handle_ahash_req(rctx); |
---|
.. | .. |
---|
1750 | 1704 | /* ==================== Kernel Cryptographic API ==================== */ |
---|
1751 | 1705 | |
---|
1752 | 1706 | /** |
---|
1753 | | - * ablkcipher_enqueue() - Handle ablkcipher encrypt or decrypt request. |
---|
| 1707 | + * skcipher_enqueue() - Handle skcipher encrypt or decrypt request. |
---|
1754 | 1708 | * @req: Crypto API request |
---|
1755 | 1709 | * @encrypt: true if encrypting; false if decrypting |
---|
1756 | 1710 | * |
---|
.. | .. |
---|
1758 | 1712 | * asynchronously |
---|
1759 | 1713 | * < 0 if an error |
---|
1760 | 1714 | */ |
---|
1761 | | -static int ablkcipher_enqueue(struct ablkcipher_request *req, bool encrypt) |
---|
| 1715 | +static int skcipher_enqueue(struct skcipher_request *req, bool encrypt) |
---|
1762 | 1716 | { |
---|
1763 | | - struct iproc_reqctx_s *rctx = ablkcipher_request_ctx(req); |
---|
| 1717 | + struct iproc_reqctx_s *rctx = skcipher_request_ctx(req); |
---|
1764 | 1718 | struct iproc_ctx_s *ctx = |
---|
1765 | | - crypto_ablkcipher_ctx(crypto_ablkcipher_reqtfm(req)); |
---|
| 1719 | + crypto_skcipher_ctx(crypto_skcipher_reqtfm(req)); |
---|
1766 | 1720 | int err; |
---|
1767 | 1721 | |
---|
1768 | 1722 | flow_log("%s() enc:%u\n", __func__, encrypt); |
---|
.. | .. |
---|
1772 | 1726 | rctx->parent = &req->base; |
---|
1773 | 1727 | rctx->is_encrypt = encrypt; |
---|
1774 | 1728 | rctx->bd_suppress = false; |
---|
1775 | | - rctx->total_todo = req->nbytes; |
---|
| 1729 | + rctx->total_todo = req->cryptlen; |
---|
1776 | 1730 | rctx->src_sent = 0; |
---|
1777 | 1731 | rctx->total_sent = 0; |
---|
1778 | 1732 | rctx->total_received = 0; |
---|
.. | .. |
---|
1793 | 1747 | ctx->cipher.mode == CIPHER_MODE_GCM || |
---|
1794 | 1748 | ctx->cipher.mode == CIPHER_MODE_CCM) { |
---|
1795 | 1749 | rctx->iv_ctr_len = |
---|
1796 | | - crypto_ablkcipher_ivsize(crypto_ablkcipher_reqtfm(req)); |
---|
1797 | | - memcpy(rctx->msg_buf.iv_ctr, req->info, rctx->iv_ctr_len); |
---|
| 1750 | + crypto_skcipher_ivsize(crypto_skcipher_reqtfm(req)); |
---|
| 1751 | + memcpy(rctx->msg_buf.iv_ctr, req->iv, rctx->iv_ctr_len); |
---|
1798 | 1752 | } else { |
---|
1799 | 1753 | rctx->iv_ctr_len = 0; |
---|
1800 | 1754 | } |
---|
1801 | 1755 | |
---|
1802 | 1756 | /* Choose a SPU to process this request */ |
---|
1803 | 1757 | rctx->chan_idx = select_channel(); |
---|
1804 | | - err = handle_ablkcipher_req(rctx); |
---|
| 1758 | + err = handle_skcipher_req(rctx); |
---|
1805 | 1759 | if (err != -EINPROGRESS) |
---|
1806 | 1760 | /* synchronous result */ |
---|
1807 | 1761 | spu_chunk_cleanup(rctx); |
---|
.. | .. |
---|
1809 | 1763 | return err; |
---|
1810 | 1764 | } |
---|
1811 | 1765 | |
---|
1812 | | -static int des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 1766 | +static int des_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
1813 | 1767 | unsigned int keylen) |
---|
1814 | 1768 | { |
---|
1815 | | - struct iproc_ctx_s *ctx = crypto_ablkcipher_ctx(cipher); |
---|
1816 | | - u32 tmp[DES_EXPKEY_WORDS]; |
---|
| 1769 | + struct iproc_ctx_s *ctx = crypto_skcipher_ctx(cipher); |
---|
| 1770 | + int err; |
---|
1817 | 1771 | |
---|
1818 | | - if (keylen == DES_KEY_SIZE) { |
---|
1819 | | - if (des_ekey(tmp, key) == 0) { |
---|
1820 | | - if (crypto_ablkcipher_get_flags(cipher) & |
---|
1821 | | - CRYPTO_TFM_REQ_WEAK_KEY) { |
---|
1822 | | - u32 flags = CRYPTO_TFM_RES_WEAK_KEY; |
---|
| 1772 | + err = verify_skcipher_des_key(cipher, key); |
---|
| 1773 | + if (err) |
---|
| 1774 | + return err; |
---|
1823 | 1775 | |
---|
1824 | | - crypto_ablkcipher_set_flags(cipher, flags); |
---|
1825 | | - return -EINVAL; |
---|
1826 | | - } |
---|
1827 | | - } |
---|
1828 | | - |
---|
1829 | | - ctx->cipher_type = CIPHER_TYPE_DES; |
---|
1830 | | - } else { |
---|
1831 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
1832 | | - return -EINVAL; |
---|
1833 | | - } |
---|
| 1776 | + ctx->cipher_type = CIPHER_TYPE_DES; |
---|
1834 | 1777 | return 0; |
---|
1835 | 1778 | } |
---|
1836 | 1779 | |
---|
1837 | | -static int threedes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 1780 | +static int threedes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
1838 | 1781 | unsigned int keylen) |
---|
1839 | 1782 | { |
---|
1840 | | - struct iproc_ctx_s *ctx = crypto_ablkcipher_ctx(cipher); |
---|
| 1783 | + struct iproc_ctx_s *ctx = crypto_skcipher_ctx(cipher); |
---|
| 1784 | + int err; |
---|
1841 | 1785 | |
---|
1842 | | - if (keylen == (DES_KEY_SIZE * 3)) { |
---|
1843 | | - const u32 *K = (const u32 *)key; |
---|
1844 | | - u32 flags = CRYPTO_TFM_RES_BAD_KEY_SCHED; |
---|
| 1786 | + err = verify_skcipher_des3_key(cipher, key); |
---|
| 1787 | + if (err) |
---|
| 1788 | + return err; |
---|
1845 | 1789 | |
---|
1846 | | - if (!((K[0] ^ K[2]) | (K[1] ^ K[3])) || |
---|
1847 | | - !((K[2] ^ K[4]) | (K[3] ^ K[5]))) { |
---|
1848 | | - crypto_ablkcipher_set_flags(cipher, flags); |
---|
1849 | | - return -EINVAL; |
---|
1850 | | - } |
---|
1851 | | - |
---|
1852 | | - ctx->cipher_type = CIPHER_TYPE_3DES; |
---|
1853 | | - } else { |
---|
1854 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
1855 | | - return -EINVAL; |
---|
1856 | | - } |
---|
| 1790 | + ctx->cipher_type = CIPHER_TYPE_3DES; |
---|
1857 | 1791 | return 0; |
---|
1858 | 1792 | } |
---|
1859 | 1793 | |
---|
1860 | | -static int aes_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 1794 | +static int aes_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
1861 | 1795 | unsigned int keylen) |
---|
1862 | 1796 | { |
---|
1863 | | - struct iproc_ctx_s *ctx = crypto_ablkcipher_ctx(cipher); |
---|
| 1797 | + struct iproc_ctx_s *ctx = crypto_skcipher_ctx(cipher); |
---|
1864 | 1798 | |
---|
1865 | 1799 | if (ctx->cipher.mode == CIPHER_MODE_XTS) |
---|
1866 | 1800 | /* XTS includes two keys of equal length */ |
---|
.. | .. |
---|
1877 | 1811 | ctx->cipher_type = CIPHER_TYPE_AES256; |
---|
1878 | 1812 | break; |
---|
1879 | 1813 | default: |
---|
1880 | | - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
1881 | 1814 | return -EINVAL; |
---|
1882 | 1815 | } |
---|
1883 | 1816 | WARN_ON((ctx->max_payload != SPU_MAX_PAYLOAD_INF) && |
---|
.. | .. |
---|
1885 | 1818 | return 0; |
---|
1886 | 1819 | } |
---|
1887 | 1820 | |
---|
1888 | | -static int rc4_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
1889 | | - unsigned int keylen) |
---|
1890 | | -{ |
---|
1891 | | - struct iproc_ctx_s *ctx = crypto_ablkcipher_ctx(cipher); |
---|
1892 | | - int i; |
---|
1893 | | - |
---|
1894 | | - ctx->enckeylen = ARC4_MAX_KEY_SIZE + ARC4_STATE_SIZE; |
---|
1895 | | - |
---|
1896 | | - ctx->enckey[0] = 0x00; /* 0x00 */ |
---|
1897 | | - ctx->enckey[1] = 0x00; /* i */ |
---|
1898 | | - ctx->enckey[2] = 0x00; /* 0x00 */ |
---|
1899 | | - ctx->enckey[3] = 0x00; /* j */ |
---|
1900 | | - for (i = 0; i < ARC4_MAX_KEY_SIZE; i++) |
---|
1901 | | - ctx->enckey[i + ARC4_STATE_SIZE] = key[i % keylen]; |
---|
1902 | | - |
---|
1903 | | - ctx->cipher_type = CIPHER_TYPE_INIT; |
---|
1904 | | - |
---|
1905 | | - return 0; |
---|
1906 | | -} |
---|
1907 | | - |
---|
1908 | | -static int ablkcipher_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 1821 | +static int skcipher_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
1909 | 1822 | unsigned int keylen) |
---|
1910 | 1823 | { |
---|
1911 | 1824 | struct spu_hw *spu = &iproc_priv.spu; |
---|
1912 | | - struct iproc_ctx_s *ctx = crypto_ablkcipher_ctx(cipher); |
---|
| 1825 | + struct iproc_ctx_s *ctx = crypto_skcipher_ctx(cipher); |
---|
1913 | 1826 | struct spu_cipher_parms cipher_parms; |
---|
1914 | 1827 | u32 alloc_len = 0; |
---|
1915 | 1828 | int err; |
---|
1916 | 1829 | |
---|
1917 | | - flow_log("ablkcipher_setkey() keylen: %d\n", keylen); |
---|
| 1830 | + flow_log("skcipher_setkey() keylen: %d\n", keylen); |
---|
1918 | 1831 | flow_dump(" key: ", key, keylen); |
---|
1919 | 1832 | |
---|
1920 | 1833 | switch (ctx->cipher.alg) { |
---|
.. | .. |
---|
1927 | 1840 | case CIPHER_ALG_AES: |
---|
1928 | 1841 | err = aes_setkey(cipher, key, keylen); |
---|
1929 | 1842 | break; |
---|
1930 | | - case CIPHER_ALG_RC4: |
---|
1931 | | - err = rc4_setkey(cipher, key, keylen); |
---|
1932 | | - break; |
---|
1933 | 1843 | default: |
---|
1934 | 1844 | pr_err("%s() Error: unknown cipher alg\n", __func__); |
---|
1935 | 1845 | err = -EINVAL; |
---|
.. | .. |
---|
1937 | 1847 | if (err) |
---|
1938 | 1848 | return err; |
---|
1939 | 1849 | |
---|
1940 | | - /* RC4 already populated ctx->enkey */ |
---|
1941 | | - if (ctx->cipher.alg != CIPHER_ALG_RC4) { |
---|
1942 | | - memcpy(ctx->enckey, key, keylen); |
---|
1943 | | - ctx->enckeylen = keylen; |
---|
1944 | | - } |
---|
| 1850 | + memcpy(ctx->enckey, key, keylen); |
---|
| 1851 | + ctx->enckeylen = keylen; |
---|
| 1852 | + |
---|
1945 | 1853 | /* SPU needs XTS keys in the reverse order the crypto API presents */ |
---|
1946 | 1854 | if ((ctx->cipher.alg == CIPHER_ALG_AES) && |
---|
1947 | 1855 | (ctx->cipher.mode == CIPHER_MODE_XTS)) { |
---|
.. | .. |
---|
1957 | 1865 | alloc_len = BCM_HDR_LEN + SPU2_HEADER_ALLOC_LEN; |
---|
1958 | 1866 | memset(ctx->bcm_spu_req_hdr, 0, alloc_len); |
---|
1959 | 1867 | cipher_parms.iv_buf = NULL; |
---|
1960 | | - cipher_parms.iv_len = crypto_ablkcipher_ivsize(cipher); |
---|
| 1868 | + cipher_parms.iv_len = crypto_skcipher_ivsize(cipher); |
---|
1961 | 1869 | flow_log("%s: iv_len %u\n", __func__, cipher_parms.iv_len); |
---|
1962 | 1870 | |
---|
1963 | 1871 | cipher_parms.alg = ctx->cipher.alg; |
---|
.. | .. |
---|
1981 | 1889 | return 0; |
---|
1982 | 1890 | } |
---|
1983 | 1891 | |
---|
1984 | | -static int ablkcipher_encrypt(struct ablkcipher_request *req) |
---|
| 1892 | +static int skcipher_encrypt(struct skcipher_request *req) |
---|
1985 | 1893 | { |
---|
1986 | | - flow_log("ablkcipher_encrypt() nbytes:%u\n", req->nbytes); |
---|
| 1894 | + flow_log("skcipher_encrypt() nbytes:%u\n", req->cryptlen); |
---|
1987 | 1895 | |
---|
1988 | | - return ablkcipher_enqueue(req, true); |
---|
| 1896 | + return skcipher_enqueue(req, true); |
---|
1989 | 1897 | } |
---|
1990 | 1898 | |
---|
1991 | | -static int ablkcipher_decrypt(struct ablkcipher_request *req) |
---|
| 1899 | +static int skcipher_decrypt(struct skcipher_request *req) |
---|
1992 | 1900 | { |
---|
1993 | | - flow_log("ablkcipher_decrypt() nbytes:%u\n", req->nbytes); |
---|
1994 | | - return ablkcipher_enqueue(req, false); |
---|
| 1901 | + flow_log("skcipher_decrypt() nbytes:%u\n", req->cryptlen); |
---|
| 1902 | + return skcipher_enqueue(req, false); |
---|
1995 | 1903 | } |
---|
1996 | 1904 | |
---|
1997 | 1905 | static int ahash_enqueue(struct ahash_request *req) |
---|
.. | .. |
---|
1999 | 1907 | struct iproc_reqctx_s *rctx = ahash_request_ctx(req); |
---|
2000 | 1908 | struct crypto_ahash *tfm = crypto_ahash_reqtfm(req); |
---|
2001 | 1909 | struct iproc_ctx_s *ctx = crypto_ahash_ctx(tfm); |
---|
2002 | | - int err = 0; |
---|
| 1910 | + int err; |
---|
2003 | 1911 | const char *alg_name; |
---|
2004 | 1912 | |
---|
2005 | 1913 | flow_log("ahash_enqueue() nbytes:%u\n", req->nbytes); |
---|
.. | .. |
---|
2093 | 2001 | * Return: true if incremental hashing is not supported |
---|
2094 | 2002 | * false otherwise |
---|
2095 | 2003 | */ |
---|
2096 | | -bool spu_no_incr_hash(struct iproc_ctx_s *ctx) |
---|
| 2004 | +static bool spu_no_incr_hash(struct iproc_ctx_s *ctx) |
---|
2097 | 2005 | { |
---|
2098 | 2006 | struct spu_hw *spu = &iproc_priv.spu; |
---|
2099 | 2007 | |
---|
.. | .. |
---|
2139 | 2047 | goto err_hash; |
---|
2140 | 2048 | } |
---|
2141 | 2049 | ctx->shash->tfm = hash; |
---|
2142 | | - ctx->shash->flags = 0; |
---|
2143 | 2050 | |
---|
2144 | 2051 | /* Set the key using data we already have from setkey */ |
---|
2145 | 2052 | if (ctx->authkeylen > 0) { |
---|
.. | .. |
---|
2332 | 2239 | |
---|
2333 | 2240 | static int ahash_digest(struct ahash_request *req) |
---|
2334 | 2241 | { |
---|
2335 | | - int err = 0; |
---|
| 2242 | + int err; |
---|
2336 | 2243 | |
---|
2337 | 2244 | flow_log("ahash_digest() nbytes:%u\n", req->nbytes); |
---|
2338 | 2245 | |
---|
.. | .. |
---|
2640 | 2547 | return 1; |
---|
2641 | 2548 | } |
---|
2642 | 2549 | |
---|
| 2550 | + /* |
---|
| 2551 | + * RFC4106 and RFC4543 cannot handle the case where AAD is other than |
---|
| 2552 | + * 16 or 20 bytes long. So use fallback in this case. |
---|
| 2553 | + */ |
---|
| 2554 | + if (ctx->cipher.mode == CIPHER_MODE_GCM && |
---|
| 2555 | + ctx->cipher.alg == CIPHER_ALG_AES && |
---|
| 2556 | + rctx->iv_ctr_len == GCM_RFC4106_IV_SIZE && |
---|
| 2557 | + req->assoclen != 16 && req->assoclen != 20) { |
---|
| 2558 | + flow_log("RFC4106/RFC4543 needs fallback for assoclen" |
---|
| 2559 | + " other than 16 or 20 bytes\n"); |
---|
| 2560 | + return 1; |
---|
| 2561 | + } |
---|
| 2562 | + |
---|
2643 | 2563 | payload_len = req->cryptlen; |
---|
2644 | 2564 | if (spu->spu_type == SPU_TYPE_SPUM) |
---|
2645 | 2565 | payload_len += req->assoclen; |
---|
.. | .. |
---|
2866 | 2786 | |
---|
2867 | 2787 | switch (ctx->alg->cipher_info.alg) { |
---|
2868 | 2788 | case CIPHER_ALG_DES: |
---|
2869 | | - if (ctx->enckeylen == DES_KEY_SIZE) { |
---|
2870 | | - u32 tmp[DES_EXPKEY_WORDS]; |
---|
2871 | | - u32 flags = CRYPTO_TFM_RES_WEAK_KEY; |
---|
| 2789 | + if (verify_aead_des_key(cipher, keys.enckey, keys.enckeylen)) |
---|
| 2790 | + return -EINVAL; |
---|
2872 | 2791 | |
---|
2873 | | - if (des_ekey(tmp, keys.enckey) == 0) { |
---|
2874 | | - if (crypto_aead_get_flags(cipher) & |
---|
2875 | | - CRYPTO_TFM_REQ_WEAK_KEY) { |
---|
2876 | | - crypto_aead_set_flags(cipher, flags); |
---|
2877 | | - return -EINVAL; |
---|
2878 | | - } |
---|
2879 | | - } |
---|
2880 | | - |
---|
2881 | | - ctx->cipher_type = CIPHER_TYPE_DES; |
---|
2882 | | - } else { |
---|
2883 | | - goto badkey; |
---|
2884 | | - } |
---|
| 2792 | + ctx->cipher_type = CIPHER_TYPE_DES; |
---|
2885 | 2793 | break; |
---|
2886 | 2794 | case CIPHER_ALG_3DES: |
---|
2887 | | - if (ctx->enckeylen == (DES_KEY_SIZE * 3)) { |
---|
2888 | | - const u32 *K = (const u32 *)keys.enckey; |
---|
2889 | | - u32 flags = CRYPTO_TFM_RES_BAD_KEY_SCHED; |
---|
2890 | | - |
---|
2891 | | - if (!((K[0] ^ K[2]) | (K[1] ^ K[3])) || |
---|
2892 | | - !((K[2] ^ K[4]) | (K[3] ^ K[5]))) { |
---|
2893 | | - crypto_aead_set_flags(cipher, flags); |
---|
2894 | | - return -EINVAL; |
---|
2895 | | - } |
---|
2896 | | - |
---|
2897 | | - ctx->cipher_type = CIPHER_TYPE_3DES; |
---|
2898 | | - } else { |
---|
2899 | | - crypto_aead_set_flags(cipher, |
---|
2900 | | - CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
| 2795 | + if (verify_aead_des3_key(cipher, keys.enckey, keys.enckeylen)) |
---|
2901 | 2796 | return -EINVAL; |
---|
2902 | | - } |
---|
| 2797 | + |
---|
| 2798 | + ctx->cipher_type = CIPHER_TYPE_3DES; |
---|
2903 | 2799 | break; |
---|
2904 | 2800 | case CIPHER_ALG_AES: |
---|
2905 | 2801 | switch (ctx->enckeylen) { |
---|
.. | .. |
---|
2915 | 2811 | default: |
---|
2916 | 2812 | goto badkey; |
---|
2917 | 2813 | } |
---|
2918 | | - break; |
---|
2919 | | - case CIPHER_ALG_RC4: |
---|
2920 | | - ctx->cipher_type = CIPHER_TYPE_INIT; |
---|
2921 | 2814 | break; |
---|
2922 | 2815 | default: |
---|
2923 | 2816 | pr_err("%s() Error: Unknown cipher alg\n", __func__); |
---|
.. | .. |
---|
2937 | 2830 | ctx->fallback_cipher->base.crt_flags |= |
---|
2938 | 2831 | tfm->crt_flags & CRYPTO_TFM_REQ_MASK; |
---|
2939 | 2832 | ret = crypto_aead_setkey(ctx->fallback_cipher, key, keylen); |
---|
2940 | | - if (ret) { |
---|
| 2833 | + if (ret) |
---|
2941 | 2834 | flow_log(" fallback setkey() returned:%d\n", ret); |
---|
2942 | | - tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; |
---|
2943 | | - tfm->crt_flags |= |
---|
2944 | | - (ctx->fallback_cipher->base.crt_flags & |
---|
2945 | | - CRYPTO_TFM_RES_MASK); |
---|
2946 | | - } |
---|
2947 | 2835 | } |
---|
2948 | 2836 | |
---|
2949 | 2837 | ctx->spu_resp_hdr_len = spu->spu_response_hdr_len(ctx->authkeylen, |
---|
.. | .. |
---|
2959 | 2847 | ctx->authkeylen = 0; |
---|
2960 | 2848 | ctx->digestsize = 0; |
---|
2961 | 2849 | |
---|
2962 | | - crypto_aead_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
2963 | 2850 | return -EINVAL; |
---|
2964 | 2851 | } |
---|
2965 | 2852 | |
---|
.. | .. |
---|
3011 | 2898 | tfm->crt_flags & CRYPTO_TFM_REQ_MASK; |
---|
3012 | 2899 | ret = crypto_aead_setkey(ctx->fallback_cipher, key, |
---|
3013 | 2900 | keylen + ctx->salt_len); |
---|
3014 | | - if (ret) { |
---|
| 2901 | + if (ret) |
---|
3015 | 2902 | flow_log(" fallback setkey() returned:%d\n", ret); |
---|
3016 | | - tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK; |
---|
3017 | | - tfm->crt_flags |= |
---|
3018 | | - (ctx->fallback_cipher->base.crt_flags & |
---|
3019 | | - CRYPTO_TFM_RES_MASK); |
---|
3020 | | - } |
---|
3021 | 2903 | } |
---|
3022 | 2904 | |
---|
3023 | 2905 | ctx->spu_resp_hdr_len = spu->spu_response_hdr_len(ctx->authkeylen, |
---|
.. | .. |
---|
3036 | 2918 | ctx->authkeylen = 0; |
---|
3037 | 2919 | ctx->digestsize = 0; |
---|
3038 | 2920 | |
---|
3039 | | - crypto_aead_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); |
---|
3040 | 2921 | return -EINVAL; |
---|
3041 | 2922 | } |
---|
3042 | 2923 | |
---|
.. | .. |
---|
3302 | 3183 | .cra_name = "authenc(hmac(md5),cbc(aes))", |
---|
3303 | 3184 | .cra_driver_name = "authenc-hmac-md5-cbc-aes-iproc", |
---|
3304 | 3185 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
3305 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3186 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3187 | + CRYPTO_ALG_ASYNC | |
---|
| 3188 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3306 | 3189 | }, |
---|
3307 | 3190 | .setkey = aead_authenc_setkey, |
---|
3308 | 3191 | .ivsize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
3325 | 3208 | .cra_name = "authenc(hmac(sha1),cbc(aes))", |
---|
3326 | 3209 | .cra_driver_name = "authenc-hmac-sha1-cbc-aes-iproc", |
---|
3327 | 3210 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
3328 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3211 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3212 | + CRYPTO_ALG_ASYNC | |
---|
| 3213 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3329 | 3214 | }, |
---|
3330 | 3215 | .setkey = aead_authenc_setkey, |
---|
3331 | 3216 | .ivsize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
3348 | 3233 | .cra_name = "authenc(hmac(sha256),cbc(aes))", |
---|
3349 | 3234 | .cra_driver_name = "authenc-hmac-sha256-cbc-aes-iproc", |
---|
3350 | 3235 | .cra_blocksize = AES_BLOCK_SIZE, |
---|
3351 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3236 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3237 | + CRYPTO_ALG_ASYNC | |
---|
| 3238 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3352 | 3239 | }, |
---|
3353 | 3240 | .setkey = aead_authenc_setkey, |
---|
3354 | 3241 | .ivsize = AES_BLOCK_SIZE, |
---|
.. | .. |
---|
3371 | 3258 | .cra_name = "authenc(hmac(md5),cbc(des))", |
---|
3372 | 3259 | .cra_driver_name = "authenc-hmac-md5-cbc-des-iproc", |
---|
3373 | 3260 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3374 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3261 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3262 | + CRYPTO_ALG_ASYNC | |
---|
| 3263 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3375 | 3264 | }, |
---|
3376 | 3265 | .setkey = aead_authenc_setkey, |
---|
3377 | 3266 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3394 | 3283 | .cra_name = "authenc(hmac(sha1),cbc(des))", |
---|
3395 | 3284 | .cra_driver_name = "authenc-hmac-sha1-cbc-des-iproc", |
---|
3396 | 3285 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3397 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3286 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3287 | + CRYPTO_ALG_ASYNC | |
---|
| 3288 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3398 | 3289 | }, |
---|
3399 | 3290 | .setkey = aead_authenc_setkey, |
---|
3400 | 3291 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3417 | 3308 | .cra_name = "authenc(hmac(sha224),cbc(des))", |
---|
3418 | 3309 | .cra_driver_name = "authenc-hmac-sha224-cbc-des-iproc", |
---|
3419 | 3310 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3420 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3311 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3312 | + CRYPTO_ALG_ASYNC | |
---|
| 3313 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3421 | 3314 | }, |
---|
3422 | 3315 | .setkey = aead_authenc_setkey, |
---|
3423 | 3316 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3440 | 3333 | .cra_name = "authenc(hmac(sha256),cbc(des))", |
---|
3441 | 3334 | .cra_driver_name = "authenc-hmac-sha256-cbc-des-iproc", |
---|
3442 | 3335 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3443 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3336 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3337 | + CRYPTO_ALG_ASYNC | |
---|
| 3338 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3444 | 3339 | }, |
---|
3445 | 3340 | .setkey = aead_authenc_setkey, |
---|
3446 | 3341 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3463 | 3358 | .cra_name = "authenc(hmac(sha384),cbc(des))", |
---|
3464 | 3359 | .cra_driver_name = "authenc-hmac-sha384-cbc-des-iproc", |
---|
3465 | 3360 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3466 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3361 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3362 | + CRYPTO_ALG_ASYNC | |
---|
| 3363 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3467 | 3364 | }, |
---|
3468 | 3365 | .setkey = aead_authenc_setkey, |
---|
3469 | 3366 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3486 | 3383 | .cra_name = "authenc(hmac(sha512),cbc(des))", |
---|
3487 | 3384 | .cra_driver_name = "authenc-hmac-sha512-cbc-des-iproc", |
---|
3488 | 3385 | .cra_blocksize = DES_BLOCK_SIZE, |
---|
3489 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3386 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3387 | + CRYPTO_ALG_ASYNC | |
---|
| 3388 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3490 | 3389 | }, |
---|
3491 | 3390 | .setkey = aead_authenc_setkey, |
---|
3492 | 3391 | .ivsize = DES_BLOCK_SIZE, |
---|
.. | .. |
---|
3509 | 3408 | .cra_name = "authenc(hmac(md5),cbc(des3_ede))", |
---|
3510 | 3409 | .cra_driver_name = "authenc-hmac-md5-cbc-des3-iproc", |
---|
3511 | 3410 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3512 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3411 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3412 | + CRYPTO_ALG_ASYNC | |
---|
| 3413 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3513 | 3414 | }, |
---|
3514 | 3415 | .setkey = aead_authenc_setkey, |
---|
3515 | 3416 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3532 | 3433 | .cra_name = "authenc(hmac(sha1),cbc(des3_ede))", |
---|
3533 | 3434 | .cra_driver_name = "authenc-hmac-sha1-cbc-des3-iproc", |
---|
3534 | 3435 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3535 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3436 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3437 | + CRYPTO_ALG_ASYNC | |
---|
| 3438 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3536 | 3439 | }, |
---|
3537 | 3440 | .setkey = aead_authenc_setkey, |
---|
3538 | 3441 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3555 | 3458 | .cra_name = "authenc(hmac(sha224),cbc(des3_ede))", |
---|
3556 | 3459 | .cra_driver_name = "authenc-hmac-sha224-cbc-des3-iproc", |
---|
3557 | 3460 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3558 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3461 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3462 | + CRYPTO_ALG_ASYNC | |
---|
| 3463 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3559 | 3464 | }, |
---|
3560 | 3465 | .setkey = aead_authenc_setkey, |
---|
3561 | 3466 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3578 | 3483 | .cra_name = "authenc(hmac(sha256),cbc(des3_ede))", |
---|
3579 | 3484 | .cra_driver_name = "authenc-hmac-sha256-cbc-des3-iproc", |
---|
3580 | 3485 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3581 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3486 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3487 | + CRYPTO_ALG_ASYNC | |
---|
| 3488 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3582 | 3489 | }, |
---|
3583 | 3490 | .setkey = aead_authenc_setkey, |
---|
3584 | 3491 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3601 | 3508 | .cra_name = "authenc(hmac(sha384),cbc(des3_ede))", |
---|
3602 | 3509 | .cra_driver_name = "authenc-hmac-sha384-cbc-des3-iproc", |
---|
3603 | 3510 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3604 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3511 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3512 | + CRYPTO_ALG_ASYNC | |
---|
| 3513 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3605 | 3514 | }, |
---|
3606 | 3515 | .setkey = aead_authenc_setkey, |
---|
3607 | 3516 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3624 | 3533 | .cra_name = "authenc(hmac(sha512),cbc(des3_ede))", |
---|
3625 | 3534 | .cra_driver_name = "authenc-hmac-sha512-cbc-des3-iproc", |
---|
3626 | 3535 | .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3627 | | - .cra_flags = CRYPTO_ALG_NEED_FALLBACK | CRYPTO_ALG_ASYNC |
---|
| 3536 | + .cra_flags = CRYPTO_ALG_NEED_FALLBACK | |
---|
| 3537 | + CRYPTO_ALG_ASYNC | |
---|
| 3538 | + CRYPTO_ALG_ALLOCATES_MEMORY |
---|
3628 | 3539 | }, |
---|
3629 | 3540 | .setkey = aead_authenc_setkey, |
---|
3630 | 3541 | .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
.. | .. |
---|
3641 | 3552 | .auth_first = 0, |
---|
3642 | 3553 | }, |
---|
3643 | 3554 | |
---|
3644 | | -/* ABLKCIPHER algorithms. */ |
---|
| 3555 | +/* SKCIPHER algorithms. */ |
---|
3645 | 3556 | { |
---|
3646 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3647 | | - .alg.crypto = { |
---|
3648 | | - .cra_name = "ecb(arc4)", |
---|
3649 | | - .cra_driver_name = "ecb-arc4-iproc", |
---|
3650 | | - .cra_blocksize = ARC4_BLOCK_SIZE, |
---|
3651 | | - .cra_ablkcipher = { |
---|
3652 | | - .min_keysize = ARC4_MIN_KEY_SIZE, |
---|
3653 | | - .max_keysize = ARC4_MAX_KEY_SIZE, |
---|
3654 | | - .ivsize = 0, |
---|
3655 | | - } |
---|
3656 | | - }, |
---|
3657 | | - .cipher_info = { |
---|
3658 | | - .alg = CIPHER_ALG_RC4, |
---|
3659 | | - .mode = CIPHER_MODE_NONE, |
---|
3660 | | - }, |
---|
3661 | | - .auth_info = { |
---|
3662 | | - .alg = HASH_ALG_NONE, |
---|
3663 | | - .mode = HASH_MODE_NONE, |
---|
3664 | | - }, |
---|
3665 | | - }, |
---|
3666 | | - { |
---|
3667 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3668 | | - .alg.crypto = { |
---|
3669 | | - .cra_name = "ofb(des)", |
---|
3670 | | - .cra_driver_name = "ofb-des-iproc", |
---|
3671 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
3672 | | - .cra_ablkcipher = { |
---|
3673 | | - .min_keysize = DES_KEY_SIZE, |
---|
3674 | | - .max_keysize = DES_KEY_SIZE, |
---|
3675 | | - .ivsize = DES_BLOCK_SIZE, |
---|
3676 | | - } |
---|
| 3557 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3558 | + .alg.skcipher = { |
---|
| 3559 | + .base.cra_name = "ofb(des)", |
---|
| 3560 | + .base.cra_driver_name = "ofb-des-iproc", |
---|
| 3561 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 3562 | + .min_keysize = DES_KEY_SIZE, |
---|
| 3563 | + .max_keysize = DES_KEY_SIZE, |
---|
| 3564 | + .ivsize = DES_BLOCK_SIZE, |
---|
3677 | 3565 | }, |
---|
3678 | 3566 | .cipher_info = { |
---|
3679 | 3567 | .alg = CIPHER_ALG_DES, |
---|
.. | .. |
---|
3685 | 3573 | }, |
---|
3686 | 3574 | }, |
---|
3687 | 3575 | { |
---|
3688 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3689 | | - .alg.crypto = { |
---|
3690 | | - .cra_name = "cbc(des)", |
---|
3691 | | - .cra_driver_name = "cbc-des-iproc", |
---|
3692 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
3693 | | - .cra_ablkcipher = { |
---|
3694 | | - .min_keysize = DES_KEY_SIZE, |
---|
3695 | | - .max_keysize = DES_KEY_SIZE, |
---|
3696 | | - .ivsize = DES_BLOCK_SIZE, |
---|
3697 | | - } |
---|
| 3576 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3577 | + .alg.skcipher = { |
---|
| 3578 | + .base.cra_name = "cbc(des)", |
---|
| 3579 | + .base.cra_driver_name = "cbc-des-iproc", |
---|
| 3580 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 3581 | + .min_keysize = DES_KEY_SIZE, |
---|
| 3582 | + .max_keysize = DES_KEY_SIZE, |
---|
| 3583 | + .ivsize = DES_BLOCK_SIZE, |
---|
3698 | 3584 | }, |
---|
3699 | 3585 | .cipher_info = { |
---|
3700 | 3586 | .alg = CIPHER_ALG_DES, |
---|
.. | .. |
---|
3706 | 3592 | }, |
---|
3707 | 3593 | }, |
---|
3708 | 3594 | { |
---|
3709 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3710 | | - .alg.crypto = { |
---|
3711 | | - .cra_name = "ecb(des)", |
---|
3712 | | - .cra_driver_name = "ecb-des-iproc", |
---|
3713 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
3714 | | - .cra_ablkcipher = { |
---|
3715 | | - .min_keysize = DES_KEY_SIZE, |
---|
3716 | | - .max_keysize = DES_KEY_SIZE, |
---|
3717 | | - .ivsize = 0, |
---|
3718 | | - } |
---|
| 3595 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3596 | + .alg.skcipher = { |
---|
| 3597 | + .base.cra_name = "ecb(des)", |
---|
| 3598 | + .base.cra_driver_name = "ecb-des-iproc", |
---|
| 3599 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 3600 | + .min_keysize = DES_KEY_SIZE, |
---|
| 3601 | + .max_keysize = DES_KEY_SIZE, |
---|
| 3602 | + .ivsize = 0, |
---|
3719 | 3603 | }, |
---|
3720 | 3604 | .cipher_info = { |
---|
3721 | 3605 | .alg = CIPHER_ALG_DES, |
---|
.. | .. |
---|
3727 | 3611 | }, |
---|
3728 | 3612 | }, |
---|
3729 | 3613 | { |
---|
3730 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3731 | | - .alg.crypto = { |
---|
3732 | | - .cra_name = "ofb(des3_ede)", |
---|
3733 | | - .cra_driver_name = "ofb-des3-iproc", |
---|
3734 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3735 | | - .cra_ablkcipher = { |
---|
3736 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
3737 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
3738 | | - .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
3739 | | - } |
---|
| 3614 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3615 | + .alg.skcipher = { |
---|
| 3616 | + .base.cra_name = "ofb(des3_ede)", |
---|
| 3617 | + .base.cra_driver_name = "ofb-des3-iproc", |
---|
| 3618 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 3619 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3620 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3621 | + .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
3740 | 3622 | }, |
---|
3741 | 3623 | .cipher_info = { |
---|
3742 | 3624 | .alg = CIPHER_ALG_3DES, |
---|
.. | .. |
---|
3748 | 3630 | }, |
---|
3749 | 3631 | }, |
---|
3750 | 3632 | { |
---|
3751 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3752 | | - .alg.crypto = { |
---|
3753 | | - .cra_name = "cbc(des3_ede)", |
---|
3754 | | - .cra_driver_name = "cbc-des3-iproc", |
---|
3755 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3756 | | - .cra_ablkcipher = { |
---|
3757 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
3758 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
3759 | | - .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
3760 | | - } |
---|
| 3633 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3634 | + .alg.skcipher = { |
---|
| 3635 | + .base.cra_name = "cbc(des3_ede)", |
---|
| 3636 | + .base.cra_driver_name = "cbc-des3-iproc", |
---|
| 3637 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 3638 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3639 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3640 | + .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
3761 | 3641 | }, |
---|
3762 | 3642 | .cipher_info = { |
---|
3763 | 3643 | .alg = CIPHER_ALG_3DES, |
---|
.. | .. |
---|
3769 | 3649 | }, |
---|
3770 | 3650 | }, |
---|
3771 | 3651 | { |
---|
3772 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3773 | | - .alg.crypto = { |
---|
3774 | | - .cra_name = "ecb(des3_ede)", |
---|
3775 | | - .cra_driver_name = "ecb-des3-iproc", |
---|
3776 | | - .cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
3777 | | - .cra_ablkcipher = { |
---|
3778 | | - .min_keysize = DES3_EDE_KEY_SIZE, |
---|
3779 | | - .max_keysize = DES3_EDE_KEY_SIZE, |
---|
3780 | | - .ivsize = 0, |
---|
3781 | | - } |
---|
| 3652 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3653 | + .alg.skcipher = { |
---|
| 3654 | + .base.cra_name = "ecb(des3_ede)", |
---|
| 3655 | + .base.cra_driver_name = "ecb-des3-iproc", |
---|
| 3656 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 3657 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3658 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 3659 | + .ivsize = 0, |
---|
3782 | 3660 | }, |
---|
3783 | 3661 | .cipher_info = { |
---|
3784 | 3662 | .alg = CIPHER_ALG_3DES, |
---|
.. | .. |
---|
3790 | 3668 | }, |
---|
3791 | 3669 | }, |
---|
3792 | 3670 | { |
---|
3793 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3794 | | - .alg.crypto = { |
---|
3795 | | - .cra_name = "ofb(aes)", |
---|
3796 | | - .cra_driver_name = "ofb-aes-iproc", |
---|
3797 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
3798 | | - .cra_ablkcipher = { |
---|
3799 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
3800 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
3801 | | - .ivsize = AES_BLOCK_SIZE, |
---|
3802 | | - } |
---|
| 3671 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3672 | + .alg.skcipher = { |
---|
| 3673 | + .base.cra_name = "ofb(aes)", |
---|
| 3674 | + .base.cra_driver_name = "ofb-aes-iproc", |
---|
| 3675 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 3676 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 3677 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 3678 | + .ivsize = AES_BLOCK_SIZE, |
---|
3803 | 3679 | }, |
---|
3804 | 3680 | .cipher_info = { |
---|
3805 | 3681 | .alg = CIPHER_ALG_AES, |
---|
.. | .. |
---|
3811 | 3687 | }, |
---|
3812 | 3688 | }, |
---|
3813 | 3689 | { |
---|
3814 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3815 | | - .alg.crypto = { |
---|
3816 | | - .cra_name = "cbc(aes)", |
---|
3817 | | - .cra_driver_name = "cbc-aes-iproc", |
---|
3818 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
3819 | | - .cra_ablkcipher = { |
---|
3820 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
3821 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
3822 | | - .ivsize = AES_BLOCK_SIZE, |
---|
3823 | | - } |
---|
| 3690 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3691 | + .alg.skcipher = { |
---|
| 3692 | + .base.cra_name = "cbc(aes)", |
---|
| 3693 | + .base.cra_driver_name = "cbc-aes-iproc", |
---|
| 3694 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 3695 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 3696 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 3697 | + .ivsize = AES_BLOCK_SIZE, |
---|
3824 | 3698 | }, |
---|
3825 | 3699 | .cipher_info = { |
---|
3826 | 3700 | .alg = CIPHER_ALG_AES, |
---|
.. | .. |
---|
3832 | 3706 | }, |
---|
3833 | 3707 | }, |
---|
3834 | 3708 | { |
---|
3835 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3836 | | - .alg.crypto = { |
---|
3837 | | - .cra_name = "ecb(aes)", |
---|
3838 | | - .cra_driver_name = "ecb-aes-iproc", |
---|
3839 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
3840 | | - .cra_ablkcipher = { |
---|
3841 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
3842 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
3843 | | - .ivsize = 0, |
---|
3844 | | - } |
---|
| 3709 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3710 | + .alg.skcipher = { |
---|
| 3711 | + .base.cra_name = "ecb(aes)", |
---|
| 3712 | + .base.cra_driver_name = "ecb-aes-iproc", |
---|
| 3713 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 3714 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 3715 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 3716 | + .ivsize = 0, |
---|
3845 | 3717 | }, |
---|
3846 | 3718 | .cipher_info = { |
---|
3847 | 3719 | .alg = CIPHER_ALG_AES, |
---|
.. | .. |
---|
3853 | 3725 | }, |
---|
3854 | 3726 | }, |
---|
3855 | 3727 | { |
---|
3856 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3857 | | - .alg.crypto = { |
---|
3858 | | - .cra_name = "ctr(aes)", |
---|
3859 | | - .cra_driver_name = "ctr-aes-iproc", |
---|
3860 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
3861 | | - .cra_ablkcipher = { |
---|
3862 | | - /* .geniv = "chainiv", */ |
---|
3863 | | - .min_keysize = AES_MIN_KEY_SIZE, |
---|
3864 | | - .max_keysize = AES_MAX_KEY_SIZE, |
---|
3865 | | - .ivsize = AES_BLOCK_SIZE, |
---|
3866 | | - } |
---|
| 3728 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3729 | + .alg.skcipher = { |
---|
| 3730 | + .base.cra_name = "ctr(aes)", |
---|
| 3731 | + .base.cra_driver_name = "ctr-aes-iproc", |
---|
| 3732 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 3733 | + .min_keysize = AES_MIN_KEY_SIZE, |
---|
| 3734 | + .max_keysize = AES_MAX_KEY_SIZE, |
---|
| 3735 | + .ivsize = AES_BLOCK_SIZE, |
---|
3867 | 3736 | }, |
---|
3868 | 3737 | .cipher_info = { |
---|
3869 | 3738 | .alg = CIPHER_ALG_AES, |
---|
.. | .. |
---|
3875 | 3744 | }, |
---|
3876 | 3745 | }, |
---|
3877 | 3746 | { |
---|
3878 | | - .type = CRYPTO_ALG_TYPE_ABLKCIPHER, |
---|
3879 | | - .alg.crypto = { |
---|
3880 | | - .cra_name = "xts(aes)", |
---|
3881 | | - .cra_driver_name = "xts-aes-iproc", |
---|
3882 | | - .cra_blocksize = AES_BLOCK_SIZE, |
---|
3883 | | - .cra_ablkcipher = { |
---|
3884 | | - .min_keysize = 2 * AES_MIN_KEY_SIZE, |
---|
3885 | | - .max_keysize = 2 * AES_MAX_KEY_SIZE, |
---|
3886 | | - .ivsize = AES_BLOCK_SIZE, |
---|
3887 | | - } |
---|
| 3747 | + .type = CRYPTO_ALG_TYPE_SKCIPHER, |
---|
| 3748 | + .alg.skcipher = { |
---|
| 3749 | + .base.cra_name = "xts(aes)", |
---|
| 3750 | + .base.cra_driver_name = "xts-aes-iproc", |
---|
| 3751 | + .base.cra_blocksize = AES_BLOCK_SIZE, |
---|
| 3752 | + .min_keysize = 2 * AES_MIN_KEY_SIZE, |
---|
| 3753 | + .max_keysize = 2 * AES_MAX_KEY_SIZE, |
---|
| 3754 | + .ivsize = AES_BLOCK_SIZE, |
---|
3888 | 3755 | }, |
---|
3889 | 3756 | .cipher_info = { |
---|
3890 | 3757 | .alg = CIPHER_ALG_AES, |
---|
.. | .. |
---|
3905 | 3772 | .cra_name = "md5", |
---|
3906 | 3773 | .cra_driver_name = "md5-iproc", |
---|
3907 | 3774 | .cra_blocksize = MD5_BLOCK_WORDS * 4, |
---|
3908 | | - .cra_flags = CRYPTO_ALG_ASYNC, |
---|
| 3775 | + .cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 3776 | + CRYPTO_ALG_ALLOCATES_MEMORY, |
---|
3909 | 3777 | } |
---|
3910 | 3778 | }, |
---|
3911 | 3779 | .cipher_info = { |
---|
.. | .. |
---|
4339 | 4207 | return 0; |
---|
4340 | 4208 | } |
---|
4341 | 4209 | |
---|
4342 | | -static int ablkcipher_cra_init(struct crypto_tfm *tfm) |
---|
| 4210 | +static int skcipher_init_tfm(struct crypto_skcipher *skcipher) |
---|
4343 | 4211 | { |
---|
4344 | | - struct crypto_alg *alg = tfm->__crt_alg; |
---|
| 4212 | + struct crypto_tfm *tfm = crypto_skcipher_tfm(skcipher); |
---|
| 4213 | + struct skcipher_alg *alg = crypto_skcipher_alg(skcipher); |
---|
4345 | 4214 | struct iproc_alg_s *cipher_alg; |
---|
4346 | 4215 | |
---|
4347 | 4216 | flow_log("%s()\n", __func__); |
---|
4348 | 4217 | |
---|
4349 | | - tfm->crt_ablkcipher.reqsize = sizeof(struct iproc_reqctx_s); |
---|
| 4218 | + crypto_skcipher_set_reqsize(skcipher, sizeof(struct iproc_reqctx_s)); |
---|
4350 | 4219 | |
---|
4351 | | - cipher_alg = container_of(alg, struct iproc_alg_s, alg.crypto); |
---|
| 4220 | + cipher_alg = container_of(alg, struct iproc_alg_s, alg.skcipher); |
---|
4352 | 4221 | return generic_cra_init(tfm, cipher_alg); |
---|
4353 | 4222 | } |
---|
4354 | 4223 | |
---|
.. | .. |
---|
4418 | 4287 | static void generic_cra_exit(struct crypto_tfm *tfm) |
---|
4419 | 4288 | { |
---|
4420 | 4289 | atomic_dec(&iproc_priv.session_count); |
---|
| 4290 | +} |
---|
| 4291 | + |
---|
| 4292 | +static void skcipher_exit_tfm(struct crypto_skcipher *tfm) |
---|
| 4293 | +{ |
---|
| 4294 | + generic_cra_exit(crypto_skcipher_tfm(tfm)); |
---|
4421 | 4295 | } |
---|
4422 | 4296 | |
---|
4423 | 4297 | static void aead_cra_exit(struct crypto_aead *aead) |
---|
.. | .. |
---|
4524 | 4398 | for (i = 0; i < iproc_priv.spu.num_chan; i++) { |
---|
4525 | 4399 | iproc_priv.mbox[i] = mbox_request_channel(mcl, i); |
---|
4526 | 4400 | if (IS_ERR(iproc_priv.mbox[i])) { |
---|
4527 | | - err = (int)PTR_ERR(iproc_priv.mbox[i]); |
---|
| 4401 | + err = PTR_ERR(iproc_priv.mbox[i]); |
---|
4528 | 4402 | dev_err(dev, |
---|
4529 | 4403 | "Mbox channel %d request failed with err %d", |
---|
4530 | 4404 | i, err); |
---|
.. | .. |
---|
4581 | 4455 | atomic_set(&iproc_priv.bad_icv, 0); |
---|
4582 | 4456 | } |
---|
4583 | 4457 | |
---|
4584 | | -static int spu_register_ablkcipher(struct iproc_alg_s *driver_alg) |
---|
| 4458 | +static int spu_register_skcipher(struct iproc_alg_s *driver_alg) |
---|
4585 | 4459 | { |
---|
4586 | | - struct spu_hw *spu = &iproc_priv.spu; |
---|
4587 | | - struct crypto_alg *crypto = &driver_alg->alg.crypto; |
---|
| 4460 | + struct skcipher_alg *crypto = &driver_alg->alg.skcipher; |
---|
4588 | 4461 | int err; |
---|
4589 | 4462 | |
---|
4590 | | - /* SPU2 does not support RC4 */ |
---|
4591 | | - if ((driver_alg->cipher_info.alg == CIPHER_ALG_RC4) && |
---|
4592 | | - (spu->spu_type == SPU_TYPE_SPU2)) |
---|
4593 | | - return 0; |
---|
| 4463 | + crypto->base.cra_module = THIS_MODULE; |
---|
| 4464 | + crypto->base.cra_priority = cipher_pri; |
---|
| 4465 | + crypto->base.cra_alignmask = 0; |
---|
| 4466 | + crypto->base.cra_ctxsize = sizeof(struct iproc_ctx_s); |
---|
| 4467 | + crypto->base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 4468 | + CRYPTO_ALG_ALLOCATES_MEMORY | |
---|
| 4469 | + CRYPTO_ALG_KERN_DRIVER_ONLY; |
---|
4594 | 4470 | |
---|
4595 | | - crypto->cra_module = THIS_MODULE; |
---|
4596 | | - crypto->cra_priority = cipher_pri; |
---|
4597 | | - crypto->cra_alignmask = 0; |
---|
4598 | | - crypto->cra_ctxsize = sizeof(struct iproc_ctx_s); |
---|
4599 | | - INIT_LIST_HEAD(&crypto->cra_list); |
---|
| 4471 | + crypto->init = skcipher_init_tfm; |
---|
| 4472 | + crypto->exit = skcipher_exit_tfm; |
---|
| 4473 | + crypto->setkey = skcipher_setkey; |
---|
| 4474 | + crypto->encrypt = skcipher_encrypt; |
---|
| 4475 | + crypto->decrypt = skcipher_decrypt; |
---|
4600 | 4476 | |
---|
4601 | | - crypto->cra_init = ablkcipher_cra_init; |
---|
4602 | | - crypto->cra_exit = generic_cra_exit; |
---|
4603 | | - crypto->cra_type = &crypto_ablkcipher_type; |
---|
4604 | | - crypto->cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | CRYPTO_ALG_ASYNC | |
---|
4605 | | - CRYPTO_ALG_KERN_DRIVER_ONLY; |
---|
4606 | | - |
---|
4607 | | - crypto->cra_ablkcipher.setkey = ablkcipher_setkey; |
---|
4608 | | - crypto->cra_ablkcipher.encrypt = ablkcipher_encrypt; |
---|
4609 | | - crypto->cra_ablkcipher.decrypt = ablkcipher_decrypt; |
---|
4610 | | - |
---|
4611 | | - err = crypto_register_alg(crypto); |
---|
| 4477 | + err = crypto_register_skcipher(crypto); |
---|
4612 | 4478 | /* Mark alg as having been registered, if successful */ |
---|
4613 | 4479 | if (err == 0) |
---|
4614 | 4480 | driver_alg->registered = true; |
---|
4615 | | - pr_debug(" registered ablkcipher %s\n", crypto->cra_driver_name); |
---|
| 4481 | + pr_debug(" registered skcipher %s\n", crypto->base.cra_driver_name); |
---|
4616 | 4482 | return err; |
---|
4617 | 4483 | } |
---|
4618 | 4484 | |
---|
.. | .. |
---|
4639 | 4505 | hash->halg.base.cra_ctxsize = sizeof(struct iproc_ctx_s); |
---|
4640 | 4506 | hash->halg.base.cra_init = ahash_cra_init; |
---|
4641 | 4507 | hash->halg.base.cra_exit = generic_cra_exit; |
---|
4642 | | - hash->halg.base.cra_flags = CRYPTO_ALG_ASYNC; |
---|
| 4508 | + hash->halg.base.cra_flags = CRYPTO_ALG_ASYNC | |
---|
| 4509 | + CRYPTO_ALG_ALLOCATES_MEMORY; |
---|
4643 | 4510 | hash->halg.statesize = sizeof(struct spu_hash_export_s); |
---|
4644 | 4511 | |
---|
4645 | 4512 | if (driver_alg->auth_info.mode != HASH_MODE_HMAC) { |
---|
.. | .. |
---|
4682 | 4549 | aead->base.cra_priority = aead_pri; |
---|
4683 | 4550 | aead->base.cra_alignmask = 0; |
---|
4684 | 4551 | aead->base.cra_ctxsize = sizeof(struct iproc_ctx_s); |
---|
4685 | | - INIT_LIST_HEAD(&aead->base.cra_list); |
---|
4686 | 4552 | |
---|
4687 | | - aead->base.cra_flags |= CRYPTO_ALG_ASYNC; |
---|
| 4553 | + aead->base.cra_flags |= CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY; |
---|
4688 | 4554 | /* setkey set in alg initialization */ |
---|
4689 | 4555 | aead->setauthsize = aead_setauthsize; |
---|
4690 | 4556 | aead->encrypt = aead_encrypt; |
---|
.. | .. |
---|
4708 | 4574 | |
---|
4709 | 4575 | for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { |
---|
4710 | 4576 | switch (driver_algs[i].type) { |
---|
4711 | | - case CRYPTO_ALG_TYPE_ABLKCIPHER: |
---|
4712 | | - err = spu_register_ablkcipher(&driver_algs[i]); |
---|
| 4577 | + case CRYPTO_ALG_TYPE_SKCIPHER: |
---|
| 4578 | + err = spu_register_skcipher(&driver_algs[i]); |
---|
4713 | 4579 | break; |
---|
4714 | 4580 | case CRYPTO_ALG_TYPE_AHASH: |
---|
4715 | 4581 | err = spu_register_ahash(&driver_algs[i]); |
---|
.. | .. |
---|
4739 | 4605 | if (!driver_algs[j].registered) |
---|
4740 | 4606 | continue; |
---|
4741 | 4607 | switch (driver_algs[j].type) { |
---|
4742 | | - case CRYPTO_ALG_TYPE_ABLKCIPHER: |
---|
4743 | | - crypto_unregister_alg(&driver_algs[j].alg.crypto); |
---|
| 4608 | + case CRYPTO_ALG_TYPE_SKCIPHER: |
---|
| 4609 | + crypto_unregister_skcipher(&driver_algs[j].alg.skcipher); |
---|
4744 | 4610 | driver_algs[j].registered = false; |
---|
4745 | 4611 | break; |
---|
4746 | 4612 | case CRYPTO_ALG_TYPE_AHASH: |
---|
.. | .. |
---|
4810 | 4676 | |
---|
4811 | 4677 | matched_spu_type = of_device_get_match_data(dev); |
---|
4812 | 4678 | if (!matched_spu_type) { |
---|
4813 | | - dev_err(&pdev->dev, "Failed to match device\n"); |
---|
| 4679 | + dev_err(dev, "Failed to match device\n"); |
---|
4814 | 4680 | return -ENODEV; |
---|
4815 | 4681 | } |
---|
4816 | 4682 | |
---|
4817 | 4683 | spu->spu_type = matched_spu_type->type; |
---|
4818 | 4684 | spu->spu_subtype = matched_spu_type->subtype; |
---|
4819 | 4685 | |
---|
4820 | | - i = 0; |
---|
4821 | 4686 | for (i = 0; (i < MAX_SPUS) && ((spu_ctrl_regs = |
---|
4822 | 4687 | platform_get_resource(pdev, IORESOURCE_MEM, i)) != NULL); i++) { |
---|
4823 | 4688 | |
---|
4824 | 4689 | spu->reg_vbase[i] = devm_ioremap_resource(dev, spu_ctrl_regs); |
---|
4825 | 4690 | if (IS_ERR(spu->reg_vbase[i])) { |
---|
4826 | 4691 | err = PTR_ERR(spu->reg_vbase[i]); |
---|
4827 | | - dev_err(&pdev->dev, "Failed to map registers: %d\n", |
---|
| 4692 | + dev_err(dev, "Failed to map registers: %d\n", |
---|
4828 | 4693 | err); |
---|
4829 | 4694 | spu->reg_vbase[i] = NULL; |
---|
4830 | 4695 | return err; |
---|
.. | .. |
---|
4836 | 4701 | return 0; |
---|
4837 | 4702 | } |
---|
4838 | 4703 | |
---|
4839 | | -int bcm_spu_probe(struct platform_device *pdev) |
---|
| 4704 | +static int bcm_spu_probe(struct platform_device *pdev) |
---|
4840 | 4705 | { |
---|
4841 | 4706 | struct device *dev = &pdev->dev; |
---|
4842 | 4707 | struct spu_hw *spu = &iproc_priv.spu; |
---|
4843 | | - int err = 0; |
---|
| 4708 | + int err; |
---|
4844 | 4709 | |
---|
4845 | 4710 | iproc_priv.pdev = pdev; |
---|
4846 | 4711 | platform_set_drvdata(iproc_priv.pdev, |
---|
.. | .. |
---|
4850 | 4715 | if (err < 0) |
---|
4851 | 4716 | goto failure; |
---|
4852 | 4717 | |
---|
4853 | | - err = spu_mb_init(&pdev->dev); |
---|
| 4718 | + err = spu_mb_init(dev); |
---|
4854 | 4719 | if (err < 0) |
---|
4855 | 4720 | goto failure; |
---|
4856 | 4721 | |
---|
.. | .. |
---|
4859 | 4724 | else if (spu->spu_type == SPU_TYPE_SPU2) |
---|
4860 | 4725 | iproc_priv.bcm_hdr_len = 0; |
---|
4861 | 4726 | |
---|
4862 | | - spu_functions_register(&pdev->dev, spu->spu_type, spu->spu_subtype); |
---|
| 4727 | + spu_functions_register(dev, spu->spu_type, spu->spu_subtype); |
---|
4863 | 4728 | |
---|
4864 | 4729 | spu_counters_init(); |
---|
4865 | 4730 | |
---|
.. | .. |
---|
4880 | 4745 | return err; |
---|
4881 | 4746 | } |
---|
4882 | 4747 | |
---|
4883 | | -int bcm_spu_remove(struct platform_device *pdev) |
---|
| 4748 | +static int bcm_spu_remove(struct platform_device *pdev) |
---|
4884 | 4749 | { |
---|
4885 | 4750 | int i; |
---|
4886 | 4751 | struct device *dev = &pdev->dev; |
---|
.. | .. |
---|
4896 | 4761 | continue; |
---|
4897 | 4762 | |
---|
4898 | 4763 | switch (driver_algs[i].type) { |
---|
4899 | | - case CRYPTO_ALG_TYPE_ABLKCIPHER: |
---|
4900 | | - crypto_unregister_alg(&driver_algs[i].alg.crypto); |
---|
| 4764 | + case CRYPTO_ALG_TYPE_SKCIPHER: |
---|
| 4765 | + crypto_unregister_skcipher(&driver_algs[i].alg.skcipher); |
---|
4901 | 4766 | dev_dbg(dev, " unregistered cipher %s\n", |
---|
4902 | | - driver_algs[i].alg.crypto.cra_driver_name); |
---|
| 4767 | + driver_algs[i].alg.skcipher.base.cra_driver_name); |
---|
4903 | 4768 | driver_algs[i].registered = false; |
---|
4904 | 4769 | break; |
---|
4905 | 4770 | case CRYPTO_ALG_TYPE_AHASH: |
---|