.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Support for OMAP DES and Triple DES HW acceleration. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2013 Texas Instruments Incorporated |
---|
5 | 6 | * Author: Joel Fernandes <joelf@ti.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as published |
---|
9 | | - * by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #define pr_fmt(fmt) "%s: " fmt, __func__ |
---|
.. | .. |
---|
37 | 33 | #include <linux/crypto.h> |
---|
38 | 34 | #include <linux/interrupt.h> |
---|
39 | 35 | #include <crypto/scatterwalk.h> |
---|
40 | | -#include <crypto/des.h> |
---|
| 36 | +#include <crypto/internal/des.h> |
---|
| 37 | +#include <crypto/internal/skcipher.h> |
---|
41 | 38 | #include <crypto/algapi.h> |
---|
42 | 39 | #include <crypto/engine.h> |
---|
43 | 40 | |
---|
.. | .. |
---|
90 | 87 | struct omap_des_dev *dd; |
---|
91 | 88 | |
---|
92 | 89 | int keylen; |
---|
93 | | - u32 key[(3 * DES_KEY_SIZE) / sizeof(u32)]; |
---|
| 90 | + __le32 key[(3 * DES_KEY_SIZE) / sizeof(u32)]; |
---|
94 | 91 | unsigned long flags; |
---|
95 | 92 | }; |
---|
96 | 93 | |
---|
.. | .. |
---|
102 | 99 | #define OMAP_DES_CACHE_SIZE 0 |
---|
103 | 100 | |
---|
104 | 101 | struct omap_des_algs_info { |
---|
105 | | - struct crypto_alg *algs_list; |
---|
| 102 | + struct skcipher_alg *algs_list; |
---|
106 | 103 | unsigned int size; |
---|
107 | 104 | unsigned int registered; |
---|
108 | 105 | }; |
---|
.. | .. |
---|
143 | 140 | |
---|
144 | 141 | struct tasklet_struct done_task; |
---|
145 | 142 | |
---|
146 | | - struct ablkcipher_request *req; |
---|
| 143 | + struct skcipher_request *req; |
---|
147 | 144 | struct crypto_engine *engine; |
---|
148 | 145 | /* |
---|
149 | 146 | * total is used by PIO mode for book keeping so introduce |
---|
.. | .. |
---|
265 | 262 | __le32_to_cpu(dd->ctx->key[i])); |
---|
266 | 263 | } |
---|
267 | 264 | |
---|
268 | | - if ((dd->flags & FLAGS_CBC) && dd->req->info) |
---|
269 | | - omap_des_write_n(dd, DES_REG_IV(dd, 0), dd->req->info, 2); |
---|
| 265 | + if ((dd->flags & FLAGS_CBC) && dd->req->iv) |
---|
| 266 | + omap_des_write_n(dd, DES_REG_IV(dd, 0), (void *)dd->req->iv, 2); |
---|
270 | 267 | |
---|
271 | 268 | if (dd->flags & FLAGS_CBC) |
---|
272 | 269 | val |= DES_REG_CTRL_CBC; |
---|
.. | .. |
---|
460 | 457 | |
---|
461 | 458 | static int omap_des_crypt_dma_start(struct omap_des_dev *dd) |
---|
462 | 459 | { |
---|
463 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm( |
---|
464 | | - crypto_ablkcipher_reqtfm(dd->req)); |
---|
| 460 | + struct crypto_tfm *tfm = crypto_skcipher_tfm( |
---|
| 461 | + crypto_skcipher_reqtfm(dd->req)); |
---|
465 | 462 | int err; |
---|
466 | 463 | |
---|
467 | | - pr_debug("total: %d\n", dd->total); |
---|
| 464 | + pr_debug("total: %zd\n", dd->total); |
---|
468 | 465 | |
---|
469 | 466 | if (!dd->pio_only) { |
---|
470 | 467 | err = dma_map_sg(dd->dev, dd->in_sg, dd->in_sg_len, |
---|
.. | .. |
---|
495 | 492 | |
---|
496 | 493 | static void omap_des_finish_req(struct omap_des_dev *dd, int err) |
---|
497 | 494 | { |
---|
498 | | - struct ablkcipher_request *req = dd->req; |
---|
| 495 | + struct skcipher_request *req = dd->req; |
---|
499 | 496 | |
---|
500 | 497 | pr_debug("err: %d\n", err); |
---|
501 | 498 | |
---|
502 | | - crypto_finalize_ablkcipher_request(dd->engine, req, err); |
---|
| 499 | + crypto_finalize_skcipher_request(dd->engine, req, err); |
---|
503 | 500 | |
---|
504 | 501 | pm_runtime_mark_last_busy(dd->dev); |
---|
505 | 502 | pm_runtime_put_autosuspend(dd->dev); |
---|
.. | .. |
---|
507 | 504 | |
---|
508 | 505 | static int omap_des_crypt_dma_stop(struct omap_des_dev *dd) |
---|
509 | 506 | { |
---|
510 | | - pr_debug("total: %d\n", dd->total); |
---|
| 507 | + pr_debug("total: %zd\n", dd->total); |
---|
511 | 508 | |
---|
512 | 509 | omap_des_dma_stop(dd); |
---|
513 | 510 | |
---|
.. | .. |
---|
518 | 515 | } |
---|
519 | 516 | |
---|
520 | 517 | static int omap_des_handle_queue(struct omap_des_dev *dd, |
---|
521 | | - struct ablkcipher_request *req) |
---|
| 518 | + struct skcipher_request *req) |
---|
522 | 519 | { |
---|
523 | 520 | if (req) |
---|
524 | | - return crypto_transfer_ablkcipher_request_to_engine(dd->engine, req); |
---|
| 521 | + return crypto_transfer_skcipher_request_to_engine(dd->engine, req); |
---|
525 | 522 | |
---|
526 | 523 | return 0; |
---|
527 | 524 | } |
---|
.. | .. |
---|
529 | 526 | static int omap_des_prepare_req(struct crypto_engine *engine, |
---|
530 | 527 | void *areq) |
---|
531 | 528 | { |
---|
532 | | - struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); |
---|
533 | | - struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( |
---|
534 | | - crypto_ablkcipher_reqtfm(req)); |
---|
| 529 | + struct skcipher_request *req = container_of(areq, struct skcipher_request, base); |
---|
| 530 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx( |
---|
| 531 | + crypto_skcipher_reqtfm(req)); |
---|
535 | 532 | struct omap_des_dev *dd = omap_des_find_dev(ctx); |
---|
536 | 533 | struct omap_des_reqctx *rctx; |
---|
537 | 534 | int ret; |
---|
.. | .. |
---|
542 | 539 | |
---|
543 | 540 | /* assign new request to device */ |
---|
544 | 541 | dd->req = req; |
---|
545 | | - dd->total = req->nbytes; |
---|
546 | | - dd->total_save = req->nbytes; |
---|
| 542 | + dd->total = req->cryptlen; |
---|
| 543 | + dd->total_save = req->cryptlen; |
---|
547 | 544 | dd->in_sg = req->src; |
---|
548 | 545 | dd->out_sg = req->dst; |
---|
549 | 546 | dd->orig_out = req->dst; |
---|
.. | .. |
---|
572 | 569 | if (dd->out_sg_len < 0) |
---|
573 | 570 | return dd->out_sg_len; |
---|
574 | 571 | |
---|
575 | | - rctx = ablkcipher_request_ctx(req); |
---|
576 | | - ctx = crypto_ablkcipher_ctx(crypto_ablkcipher_reqtfm(req)); |
---|
| 572 | + rctx = skcipher_request_ctx(req); |
---|
| 573 | + ctx = crypto_skcipher_ctx(crypto_skcipher_reqtfm(req)); |
---|
577 | 574 | rctx->mode &= FLAGS_MODE_MASK; |
---|
578 | 575 | dd->flags = (dd->flags & ~FLAGS_MODE_MASK) | rctx->mode; |
---|
579 | 576 | |
---|
.. | .. |
---|
586 | 583 | static int omap_des_crypt_req(struct crypto_engine *engine, |
---|
587 | 584 | void *areq) |
---|
588 | 585 | { |
---|
589 | | - struct ablkcipher_request *req = container_of(areq, struct ablkcipher_request, base); |
---|
590 | | - struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( |
---|
591 | | - crypto_ablkcipher_reqtfm(req)); |
---|
| 586 | + struct skcipher_request *req = container_of(areq, struct skcipher_request, base); |
---|
| 587 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx( |
---|
| 588 | + crypto_skcipher_reqtfm(req)); |
---|
592 | 589 | struct omap_des_dev *dd = omap_des_find_dev(ctx); |
---|
593 | 590 | |
---|
594 | 591 | if (!dd) |
---|
.. | .. |
---|
600 | 597 | static void omap_des_done_task(unsigned long data) |
---|
601 | 598 | { |
---|
602 | 599 | struct omap_des_dev *dd = (struct omap_des_dev *)data; |
---|
| 600 | + int i; |
---|
603 | 601 | |
---|
604 | 602 | pr_debug("enter done_task\n"); |
---|
605 | 603 | |
---|
.. | .. |
---|
618 | 616 | omap_crypto_cleanup(&dd->out_sgl, dd->orig_out, 0, dd->total_save, |
---|
619 | 617 | FLAGS_OUT_DATA_ST_SHIFT, dd->flags); |
---|
620 | 618 | |
---|
| 619 | + if ((dd->flags & FLAGS_CBC) && dd->req->iv) |
---|
| 620 | + for (i = 0; i < 2; i++) |
---|
| 621 | + ((u32 *)dd->req->iv)[i] = |
---|
| 622 | + omap_des_read(dd, DES_REG_IV(dd, i)); |
---|
| 623 | + |
---|
621 | 624 | omap_des_finish_req(dd, 0); |
---|
622 | 625 | |
---|
623 | 626 | pr_debug("exit\n"); |
---|
624 | 627 | } |
---|
625 | 628 | |
---|
626 | | -static int omap_des_crypt(struct ablkcipher_request *req, unsigned long mode) |
---|
| 629 | +static int omap_des_crypt(struct skcipher_request *req, unsigned long mode) |
---|
627 | 630 | { |
---|
628 | | - struct omap_des_ctx *ctx = crypto_ablkcipher_ctx( |
---|
629 | | - crypto_ablkcipher_reqtfm(req)); |
---|
630 | | - struct omap_des_reqctx *rctx = ablkcipher_request_ctx(req); |
---|
| 631 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx( |
---|
| 632 | + crypto_skcipher_reqtfm(req)); |
---|
| 633 | + struct omap_des_reqctx *rctx = skcipher_request_ctx(req); |
---|
631 | 634 | struct omap_des_dev *dd; |
---|
632 | 635 | |
---|
633 | | - pr_debug("nbytes: %d, enc: %d, cbc: %d\n", req->nbytes, |
---|
| 636 | + pr_debug("nbytes: %d, enc: %d, cbc: %d\n", req->cryptlen, |
---|
634 | 637 | !!(mode & FLAGS_ENCRYPT), |
---|
635 | 638 | !!(mode & FLAGS_CBC)); |
---|
636 | 639 | |
---|
637 | | - if (!IS_ALIGNED(req->nbytes, DES_BLOCK_SIZE)) { |
---|
638 | | - pr_err("request size is not exact amount of DES blocks\n"); |
---|
| 640 | + if (!req->cryptlen) |
---|
| 641 | + return 0; |
---|
| 642 | + |
---|
| 643 | + if (!IS_ALIGNED(req->cryptlen, DES_BLOCK_SIZE)) |
---|
639 | 644 | return -EINVAL; |
---|
640 | | - } |
---|
641 | 645 | |
---|
642 | 646 | dd = omap_des_find_dev(ctx); |
---|
643 | 647 | if (!dd) |
---|
.. | .. |
---|
650 | 654 | |
---|
651 | 655 | /* ********************** ALG API ************************************ */ |
---|
652 | 656 | |
---|
653 | | -static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, |
---|
| 657 | +static int omap_des_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
654 | 658 | unsigned int keylen) |
---|
655 | 659 | { |
---|
656 | | - struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
---|
657 | | - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); |
---|
658 | | - |
---|
659 | | - if (keylen != DES_KEY_SIZE && keylen != (3*DES_KEY_SIZE)) |
---|
660 | | - return -EINVAL; |
---|
| 660 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx(cipher); |
---|
| 661 | + int err; |
---|
661 | 662 | |
---|
662 | 663 | pr_debug("enter, keylen: %d\n", keylen); |
---|
663 | 664 | |
---|
664 | | - /* Do we need to test against weak key? */ |
---|
665 | | - if (tfm->crt_flags & CRYPTO_TFM_REQ_WEAK_KEY) { |
---|
666 | | - u32 tmp[DES_EXPKEY_WORDS]; |
---|
667 | | - int ret = des_ekey(tmp, key); |
---|
668 | | - |
---|
669 | | - if (!ret) { |
---|
670 | | - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; |
---|
671 | | - return -EINVAL; |
---|
672 | | - } |
---|
673 | | - } |
---|
| 665 | + err = verify_skcipher_des_key(cipher, key); |
---|
| 666 | + if (err) |
---|
| 667 | + return err; |
---|
674 | 668 | |
---|
675 | 669 | memcpy(ctx->key, key, keylen); |
---|
676 | 670 | ctx->keylen = keylen; |
---|
.. | .. |
---|
678 | 672 | return 0; |
---|
679 | 673 | } |
---|
680 | 674 | |
---|
681 | | -static int omap_des_ecb_encrypt(struct ablkcipher_request *req) |
---|
| 675 | +static int omap_des3_setkey(struct crypto_skcipher *cipher, const u8 *key, |
---|
| 676 | + unsigned int keylen) |
---|
| 677 | +{ |
---|
| 678 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx(cipher); |
---|
| 679 | + int err; |
---|
| 680 | + |
---|
| 681 | + pr_debug("enter, keylen: %d\n", keylen); |
---|
| 682 | + |
---|
| 683 | + err = verify_skcipher_des3_key(cipher, key); |
---|
| 684 | + if (err) |
---|
| 685 | + return err; |
---|
| 686 | + |
---|
| 687 | + memcpy(ctx->key, key, keylen); |
---|
| 688 | + ctx->keylen = keylen; |
---|
| 689 | + |
---|
| 690 | + return 0; |
---|
| 691 | +} |
---|
| 692 | + |
---|
| 693 | +static int omap_des_ecb_encrypt(struct skcipher_request *req) |
---|
682 | 694 | { |
---|
683 | 695 | return omap_des_crypt(req, FLAGS_ENCRYPT); |
---|
684 | 696 | } |
---|
685 | 697 | |
---|
686 | | -static int omap_des_ecb_decrypt(struct ablkcipher_request *req) |
---|
| 698 | +static int omap_des_ecb_decrypt(struct skcipher_request *req) |
---|
687 | 699 | { |
---|
688 | 700 | return omap_des_crypt(req, 0); |
---|
689 | 701 | } |
---|
690 | 702 | |
---|
691 | | -static int omap_des_cbc_encrypt(struct ablkcipher_request *req) |
---|
| 703 | +static int omap_des_cbc_encrypt(struct skcipher_request *req) |
---|
692 | 704 | { |
---|
693 | 705 | return omap_des_crypt(req, FLAGS_ENCRYPT | FLAGS_CBC); |
---|
694 | 706 | } |
---|
695 | 707 | |
---|
696 | | -static int omap_des_cbc_decrypt(struct ablkcipher_request *req) |
---|
| 708 | +static int omap_des_cbc_decrypt(struct skcipher_request *req) |
---|
697 | 709 | { |
---|
698 | 710 | return omap_des_crypt(req, FLAGS_CBC); |
---|
699 | 711 | } |
---|
.. | .. |
---|
703 | 715 | static int omap_des_crypt_req(struct crypto_engine *engine, |
---|
704 | 716 | void *areq); |
---|
705 | 717 | |
---|
706 | | -static int omap_des_cra_init(struct crypto_tfm *tfm) |
---|
| 718 | +static int omap_des_init_tfm(struct crypto_skcipher *tfm) |
---|
707 | 719 | { |
---|
708 | | - struct omap_des_ctx *ctx = crypto_tfm_ctx(tfm); |
---|
| 720 | + struct omap_des_ctx *ctx = crypto_skcipher_ctx(tfm); |
---|
709 | 721 | |
---|
710 | 722 | pr_debug("enter\n"); |
---|
711 | 723 | |
---|
712 | | - tfm->crt_ablkcipher.reqsize = sizeof(struct omap_des_reqctx); |
---|
| 724 | + crypto_skcipher_set_reqsize(tfm, sizeof(struct omap_des_reqctx)); |
---|
713 | 725 | |
---|
714 | 726 | ctx->enginectx.op.prepare_request = omap_des_prepare_req; |
---|
715 | 727 | ctx->enginectx.op.unprepare_request = NULL; |
---|
.. | .. |
---|
718 | 730 | return 0; |
---|
719 | 731 | } |
---|
720 | 732 | |
---|
721 | | -static void omap_des_cra_exit(struct crypto_tfm *tfm) |
---|
722 | | -{ |
---|
723 | | - pr_debug("enter\n"); |
---|
724 | | -} |
---|
725 | | - |
---|
726 | 733 | /* ********************** ALGS ************************************ */ |
---|
727 | 734 | |
---|
728 | | -static struct crypto_alg algs_ecb_cbc[] = { |
---|
| 735 | +static struct skcipher_alg algs_ecb_cbc[] = { |
---|
729 | 736 | { |
---|
730 | | - .cra_name = "ecb(des)", |
---|
731 | | - .cra_driver_name = "ecb-des-omap", |
---|
732 | | - .cra_priority = 100, |
---|
733 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
734 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 737 | + .base.cra_name = "ecb(des)", |
---|
| 738 | + .base.cra_driver_name = "ecb-des-omap", |
---|
| 739 | + .base.cra_priority = 100, |
---|
| 740 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
735 | 741 | CRYPTO_ALG_ASYNC, |
---|
736 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
737 | | - .cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
738 | | - .cra_alignmask = 0, |
---|
739 | | - .cra_type = &crypto_ablkcipher_type, |
---|
740 | | - .cra_module = THIS_MODULE, |
---|
741 | | - .cra_init = omap_des_cra_init, |
---|
742 | | - .cra_exit = omap_des_cra_exit, |
---|
743 | | - .cra_u.ablkcipher = { |
---|
744 | | - .min_keysize = DES_KEY_SIZE, |
---|
745 | | - .max_keysize = DES_KEY_SIZE, |
---|
746 | | - .setkey = omap_des_setkey, |
---|
747 | | - .encrypt = omap_des_ecb_encrypt, |
---|
748 | | - .decrypt = omap_des_ecb_decrypt, |
---|
749 | | - } |
---|
| 742 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 743 | + .base.cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
| 744 | + .base.cra_module = THIS_MODULE, |
---|
| 745 | + |
---|
| 746 | + .min_keysize = DES_KEY_SIZE, |
---|
| 747 | + .max_keysize = DES_KEY_SIZE, |
---|
| 748 | + .setkey = omap_des_setkey, |
---|
| 749 | + .encrypt = omap_des_ecb_encrypt, |
---|
| 750 | + .decrypt = omap_des_ecb_decrypt, |
---|
| 751 | + .init = omap_des_init_tfm, |
---|
750 | 752 | }, |
---|
751 | 753 | { |
---|
752 | | - .cra_name = "cbc(des)", |
---|
753 | | - .cra_driver_name = "cbc-des-omap", |
---|
754 | | - .cra_priority = 100, |
---|
755 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
756 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 754 | + .base.cra_name = "cbc(des)", |
---|
| 755 | + .base.cra_driver_name = "cbc-des-omap", |
---|
| 756 | + .base.cra_priority = 100, |
---|
| 757 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
757 | 758 | CRYPTO_ALG_ASYNC, |
---|
758 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
759 | | - .cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
760 | | - .cra_alignmask = 0, |
---|
761 | | - .cra_type = &crypto_ablkcipher_type, |
---|
762 | | - .cra_module = THIS_MODULE, |
---|
763 | | - .cra_init = omap_des_cra_init, |
---|
764 | | - .cra_exit = omap_des_cra_exit, |
---|
765 | | - .cra_u.ablkcipher = { |
---|
766 | | - .min_keysize = DES_KEY_SIZE, |
---|
767 | | - .max_keysize = DES_KEY_SIZE, |
---|
768 | | - .ivsize = DES_BLOCK_SIZE, |
---|
769 | | - .setkey = omap_des_setkey, |
---|
770 | | - .encrypt = omap_des_cbc_encrypt, |
---|
771 | | - .decrypt = omap_des_cbc_decrypt, |
---|
772 | | - } |
---|
| 759 | + .base.cra_blocksize = DES_BLOCK_SIZE, |
---|
| 760 | + .base.cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
| 761 | + .base.cra_module = THIS_MODULE, |
---|
| 762 | + |
---|
| 763 | + .min_keysize = DES_KEY_SIZE, |
---|
| 764 | + .max_keysize = DES_KEY_SIZE, |
---|
| 765 | + .ivsize = DES_BLOCK_SIZE, |
---|
| 766 | + .setkey = omap_des_setkey, |
---|
| 767 | + .encrypt = omap_des_cbc_encrypt, |
---|
| 768 | + .decrypt = omap_des_cbc_decrypt, |
---|
| 769 | + .init = omap_des_init_tfm, |
---|
773 | 770 | }, |
---|
774 | 771 | { |
---|
775 | | - .cra_name = "ecb(des3_ede)", |
---|
776 | | - .cra_driver_name = "ecb-des3-omap", |
---|
777 | | - .cra_priority = 100, |
---|
778 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
779 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 772 | + .base.cra_name = "ecb(des3_ede)", |
---|
| 773 | + .base.cra_driver_name = "ecb-des3-omap", |
---|
| 774 | + .base.cra_priority = 100, |
---|
| 775 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
780 | 776 | CRYPTO_ALG_ASYNC, |
---|
781 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
782 | | - .cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
783 | | - .cra_alignmask = 0, |
---|
784 | | - .cra_type = &crypto_ablkcipher_type, |
---|
785 | | - .cra_module = THIS_MODULE, |
---|
786 | | - .cra_init = omap_des_cra_init, |
---|
787 | | - .cra_exit = omap_des_cra_exit, |
---|
788 | | - .cra_u.ablkcipher = { |
---|
789 | | - .min_keysize = 3*DES_KEY_SIZE, |
---|
790 | | - .max_keysize = 3*DES_KEY_SIZE, |
---|
791 | | - .setkey = omap_des_setkey, |
---|
792 | | - .encrypt = omap_des_ecb_encrypt, |
---|
793 | | - .decrypt = omap_des_ecb_decrypt, |
---|
794 | | - } |
---|
| 777 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 778 | + .base.cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
| 779 | + .base.cra_module = THIS_MODULE, |
---|
| 780 | + |
---|
| 781 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 782 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 783 | + .setkey = omap_des3_setkey, |
---|
| 784 | + .encrypt = omap_des_ecb_encrypt, |
---|
| 785 | + .decrypt = omap_des_ecb_decrypt, |
---|
| 786 | + .init = omap_des_init_tfm, |
---|
795 | 787 | }, |
---|
796 | 788 | { |
---|
797 | | - .cra_name = "cbc(des3_ede)", |
---|
798 | | - .cra_driver_name = "cbc-des3-omap", |
---|
799 | | - .cra_priority = 100, |
---|
800 | | - .cra_flags = CRYPTO_ALG_TYPE_ABLKCIPHER | |
---|
801 | | - CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
| 789 | + .base.cra_name = "cbc(des3_ede)", |
---|
| 790 | + .base.cra_driver_name = "cbc-des3-omap", |
---|
| 791 | + .base.cra_priority = 100, |
---|
| 792 | + .base.cra_flags = CRYPTO_ALG_KERN_DRIVER_ONLY | |
---|
802 | 793 | CRYPTO_ALG_ASYNC, |
---|
803 | | - .cra_blocksize = DES_BLOCK_SIZE, |
---|
804 | | - .cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
805 | | - .cra_alignmask = 0, |
---|
806 | | - .cra_type = &crypto_ablkcipher_type, |
---|
807 | | - .cra_module = THIS_MODULE, |
---|
808 | | - .cra_init = omap_des_cra_init, |
---|
809 | | - .cra_exit = omap_des_cra_exit, |
---|
810 | | - .cra_u.ablkcipher = { |
---|
811 | | - .min_keysize = 3*DES_KEY_SIZE, |
---|
812 | | - .max_keysize = 3*DES_KEY_SIZE, |
---|
813 | | - .ivsize = DES_BLOCK_SIZE, |
---|
814 | | - .setkey = omap_des_setkey, |
---|
815 | | - .encrypt = omap_des_cbc_encrypt, |
---|
816 | | - .decrypt = omap_des_cbc_decrypt, |
---|
817 | | - } |
---|
| 794 | + .base.cra_blocksize = DES3_EDE_BLOCK_SIZE, |
---|
| 795 | + .base.cra_ctxsize = sizeof(struct omap_des_ctx), |
---|
| 796 | + .base.cra_module = THIS_MODULE, |
---|
| 797 | + |
---|
| 798 | + .min_keysize = DES3_EDE_KEY_SIZE, |
---|
| 799 | + .max_keysize = DES3_EDE_KEY_SIZE, |
---|
| 800 | + .ivsize = DES3_EDE_BLOCK_SIZE, |
---|
| 801 | + .setkey = omap_des3_setkey, |
---|
| 802 | + .encrypt = omap_des_cbc_encrypt, |
---|
| 803 | + .decrypt = omap_des_cbc_decrypt, |
---|
| 804 | + .init = omap_des_init_tfm, |
---|
818 | 805 | } |
---|
819 | 806 | }; |
---|
820 | 807 | |
---|
.. | .. |
---|
972 | 959 | { |
---|
973 | 960 | struct device *dev = &pdev->dev; |
---|
974 | 961 | struct omap_des_dev *dd; |
---|
975 | | - struct crypto_alg *algp; |
---|
| 962 | + struct skcipher_alg *algp; |
---|
976 | 963 | struct resource *res; |
---|
977 | 964 | int err = -ENOMEM, i, j, irq = -1; |
---|
978 | 965 | u32 reg; |
---|
.. | .. |
---|
1034 | 1021 | |
---|
1035 | 1022 | irq = platform_get_irq(pdev, 0); |
---|
1036 | 1023 | if (irq < 0) { |
---|
1037 | | - dev_err(dev, "can't get IRQ resource: %d\n", irq); |
---|
1038 | 1024 | err = irq; |
---|
1039 | 1025 | goto err_irq; |
---|
1040 | 1026 | } |
---|
.. | .. |
---|
1049 | 1035 | |
---|
1050 | 1036 | |
---|
1051 | 1037 | INIT_LIST_HEAD(&dd->list); |
---|
1052 | | - spin_lock(&list_lock); |
---|
| 1038 | + spin_lock_bh(&list_lock); |
---|
1053 | 1039 | list_add_tail(&dd->list, &dev_list); |
---|
1054 | | - spin_unlock(&list_lock); |
---|
| 1040 | + spin_unlock_bh(&list_lock); |
---|
1055 | 1041 | |
---|
1056 | 1042 | /* Initialize des crypto engine */ |
---|
1057 | 1043 | dd->engine = crypto_engine_alloc_init(dev, 1); |
---|
.. | .. |
---|
1068 | 1054 | for (j = 0; j < dd->pdata->algs_info[i].size; j++) { |
---|
1069 | 1055 | algp = &dd->pdata->algs_info[i].algs_list[j]; |
---|
1070 | 1056 | |
---|
1071 | | - pr_debug("reg alg: %s\n", algp->cra_name); |
---|
1072 | | - INIT_LIST_HEAD(&algp->cra_list); |
---|
| 1057 | + pr_debug("reg alg: %s\n", algp->base.cra_name); |
---|
1073 | 1058 | |
---|
1074 | | - err = crypto_register_alg(algp); |
---|
| 1059 | + err = crypto_register_skcipher(algp); |
---|
1075 | 1060 | if (err) |
---|
1076 | 1061 | goto err_algs; |
---|
1077 | 1062 | |
---|
.. | .. |
---|
1084 | 1069 | err_algs: |
---|
1085 | 1070 | for (i = dd->pdata->algs_info_size - 1; i >= 0; i--) |
---|
1086 | 1071 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
---|
1087 | | - crypto_unregister_alg( |
---|
| 1072 | + crypto_unregister_skcipher( |
---|
1088 | 1073 | &dd->pdata->algs_info[i].algs_list[j]); |
---|
1089 | 1074 | |
---|
1090 | 1075 | err_engine: |
---|
.. | .. |
---|
1111 | 1096 | if (!dd) |
---|
1112 | 1097 | return -ENODEV; |
---|
1113 | 1098 | |
---|
1114 | | - spin_lock(&list_lock); |
---|
| 1099 | + spin_lock_bh(&list_lock); |
---|
1115 | 1100 | list_del(&dd->list); |
---|
1116 | | - spin_unlock(&list_lock); |
---|
| 1101 | + spin_unlock_bh(&list_lock); |
---|
1117 | 1102 | |
---|
1118 | 1103 | for (i = dd->pdata->algs_info_size - 1; i >= 0; i--) |
---|
1119 | 1104 | for (j = dd->pdata->algs_info[i].registered - 1; j >= 0; j--) |
---|
1120 | | - crypto_unregister_alg( |
---|
| 1105 | + crypto_unregister_skcipher( |
---|
1121 | 1106 | &dd->pdata->algs_info[i].algs_list[j]); |
---|
1122 | 1107 | |
---|
1123 | 1108 | tasklet_kill(&dd->done_task); |
---|