summaryrefslogtreecommitdiffstats
path: root/drivers/crypto/omap-des.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-06 23:15:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-06 23:15:06 -0400
commit81ff5d2cba4f86cd850b9ee4a530cd221ee45aa3 (patch)
tree532847c0823dc864e3aa9da6cde863e48157eafa /drivers/crypto/omap-des.c
parent7aefd944f038c7469571adb37769cb6f3924ecfa (diff)
parente59f755ceb6d6f39f90899d2a4e39c3e05837e12 (diff)
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu: "API: - Add support for AEAD in simd - Add fuzz testing to testmgr - Add panic_on_fail module parameter to testmgr - Use per-CPU struct instead multiple variables in scompress - Change verify API for akcipher Algorithms: - Convert x86 AEAD algorithms over to simd - Forbid 2-key 3DES in FIPS mode - Add EC-RDSA (GOST 34.10) algorithm Drivers: - Set output IV with ctr-aes in crypto4xx - Set output IV in rockchip - Fix potential length overflow with hashing in sun4i-ss - Fix computation error with ctr in vmx - Add SM4 protected keys support in ccree - Remove long-broken mxc-scc driver - Add rfc4106(gcm(aes)) cipher support in cavium/nitrox" * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (179 commits) crypto: ccree - use a proper le32 type for le32 val crypto: ccree - remove set but not used variable 'du_size' crypto: ccree - Make cc_sec_disable static crypto: ccree - fix spelling mistake "protedcted" -> "protected" crypto: caam/qi2 - generate hash keys in-place crypto: caam/qi2 - fix DMA mapping of stack memory crypto: caam/qi2 - fix zero-length buffer DMA mapping crypto: stm32/cryp - update to return iv_out crypto: stm32/cryp - remove request mutex protection crypto: stm32/cryp - add weak key check for DES crypto: atmel - remove set but not used variable 'alg_name' crypto: picoxcell - Use dev_get_drvdata() crypto: crypto4xx - get rid of redundant using_sd variable crypto: crypto4xx - use sync skcipher for fallback crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues crypto: crypto4xx - fix ctr-aes missing output IV crypto: ecrdsa - select ASN1 and OID_REGISTRY for EC-RDSA crypto: ux500 - use ccflags-y instead of CFLAGS_<basename>.o crypto: ccree - handle tee fips error during power management resume crypto: ccree - add function to handle cryptocell tee fips error ...
Diffstat (limited to 'drivers/crypto/omap-des.c')
-rw-r--r--drivers/crypto/omap-des.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/drivers/crypto/omap-des.c b/drivers/crypto/omap-des.c
index 1ba2633e90d6..3d82d18ff810 100644
--- a/drivers/crypto/omap-des.c
+++ b/drivers/crypto/omap-des.c
@@ -656,9 +656,6 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
656 struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); 656 struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
657 struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 657 struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
658 658
659 if (keylen != DES_KEY_SIZE && keylen != (3*DES_KEY_SIZE))
660 return -EINVAL;
661
662 pr_debug("enter, keylen: %d\n", keylen); 659 pr_debug("enter, keylen: %d\n", keylen);
663 660
664 /* Do we need to test against weak key? */ 661 /* Do we need to test against weak key? */
@@ -678,6 +675,28 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
678 return 0; 675 return 0;
679} 676}
680 677
678static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
679 unsigned int keylen)
680{
681 struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
682 u32 flags;
683 int err;
684
685 pr_debug("enter, keylen: %d\n", keylen);
686
687 flags = crypto_ablkcipher_get_flags(cipher);
688 err = __des3_verify_key(&flags, key);
689 if (unlikely(err)) {
690 crypto_ablkcipher_set_flags(cipher, flags);
691 return err;
692 }
693
694 memcpy(ctx->key, key, keylen);
695 ctx->keylen = keylen;
696
697 return 0;
698}
699
681static int omap_des_ecb_encrypt(struct ablkcipher_request *req) 700static int omap_des_ecb_encrypt(struct ablkcipher_request *req)
682{ 701{
683 return omap_des_crypt(req, FLAGS_ENCRYPT); 702 return omap_des_crypt(req, FLAGS_ENCRYPT);
@@ -788,7 +807,7 @@ static struct crypto_alg algs_ecb_cbc[] = {
788 .cra_u.ablkcipher = { 807 .cra_u.ablkcipher = {
789 .min_keysize = 3*DES_KEY_SIZE, 808 .min_keysize = 3*DES_KEY_SIZE,
790 .max_keysize = 3*DES_KEY_SIZE, 809 .max_keysize = 3*DES_KEY_SIZE,
791 .setkey = omap_des_setkey, 810 .setkey = omap_des3_setkey,
792 .encrypt = omap_des_ecb_encrypt, 811 .encrypt = omap_des_ecb_encrypt,
793 .decrypt = omap_des_ecb_decrypt, 812 .decrypt = omap_des_ecb_decrypt,
794 } 813 }
@@ -811,7 +830,7 @@ static struct crypto_alg algs_ecb_cbc[] = {
811 .min_keysize = 3*DES_KEY_SIZE, 830 .min_keysize = 3*DES_KEY_SIZE,
812 .max_keysize = 3*DES_KEY_SIZE, 831 .max_keysize = 3*DES_KEY_SIZE,
813 .ivsize = DES_BLOCK_SIZE, 832 .ivsize = DES_BLOCK_SIZE,
814 .setkey = omap_des_setkey, 833 .setkey = omap_des3_setkey,
815 .encrypt = omap_des_cbc_encrypt, 834 .encrypt = omap_des_cbc_encrypt,
816 .decrypt = omap_des_cbc_decrypt, 835 .decrypt = omap_des_cbc_decrypt,
817 } 836 }