diff options
| -rw-r--r-- | arch/arm/crypto/Makefile | 12 | ||||
| -rw-r--r-- | arch/arm/crypto/crc32-ce-core.S | 2 | ||||
| -rw-r--r-- | crypto/ccm.c | 5 | ||||
| -rw-r--r-- | crypto/testmgr.h | 2 | ||||
| -rw-r--r-- | crypto/xts.c | 14 | ||||
| -rw-r--r-- | drivers/crypto/Kconfig | 3 | ||||
| -rw-r--r-- | drivers/crypto/cavium/cpt/cptvf_main.c | 5 | ||||
| -rw-r--r-- | drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 4 | ||||
| -rw-r--r-- | drivers/crypto/vmx/aes_cbc.c | 47 | ||||
| -rw-r--r-- | drivers/crypto/vmx/aes_xts.c | 32 | ||||
| -rw-r--r-- | include/crypto/algapi.h | 7 |
11 files changed, 79 insertions, 54 deletions
diff --git a/arch/arm/crypto/Makefile b/arch/arm/crypto/Makefile index 1822c4697278..f2215fbeed13 100644 --- a/arch/arm/crypto/Makefile +++ b/arch/arm/crypto/Makefile | |||
| @@ -15,7 +15,17 @@ ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o | |||
| 15 | ce-obj-$(CONFIG_CRYPTO_SHA2_ARM_CE) += sha2-arm-ce.o | 15 | ce-obj-$(CONFIG_CRYPTO_SHA2_ARM_CE) += sha2-arm-ce.o |
| 16 | ce-obj-$(CONFIG_CRYPTO_GHASH_ARM_CE) += ghash-arm-ce.o | 16 | ce-obj-$(CONFIG_CRYPTO_GHASH_ARM_CE) += ghash-arm-ce.o |
| 17 | ce-obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM_CE) += crct10dif-arm-ce.o | 17 | ce-obj-$(CONFIG_CRYPTO_CRCT10DIF_ARM_CE) += crct10dif-arm-ce.o |
| 18 | ce-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o | 18 | crc-obj-$(CONFIG_CRYPTO_CRC32_ARM_CE) += crc32-arm-ce.o |
| 19 | |||
| 20 | ifneq ($(crc-obj-y)$(crc-obj-m),) | ||
| 21 | ifeq ($(call as-instr,.arch armv8-a\n.arch_extension crc,y,n),y) | ||
| 22 | ce-obj-y += $(crc-obj-y) | ||
| 23 | ce-obj-m += $(crc-obj-m) | ||
| 24 | else | ||
| 25 | $(warning These CRC Extensions modules need binutils 2.23 or higher) | ||
| 26 | $(warning $(crc-obj-y) $(crc-obj-m)) | ||
| 27 | endif | ||
| 28 | endif | ||
| 19 | 29 | ||
| 20 | ifneq ($(ce-obj-y)$(ce-obj-m),) | 30 | ifneq ($(ce-obj-y)$(ce-obj-m),) |
| 21 | ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y) | 31 | ifeq ($(call as-instr,.fpu crypto-neon-fp-armv8,y,n),y) |
diff --git a/arch/arm/crypto/crc32-ce-core.S b/arch/arm/crypto/crc32-ce-core.S index e63d400dc5c1..5cbd4a6fedad 100644 --- a/arch/arm/crypto/crc32-ce-core.S +++ b/arch/arm/crypto/crc32-ce-core.S | |||
| @@ -135,7 +135,7 @@ ENTRY(crc32c_pmull_le) | |||
| 135 | vld1.8 {q3-q4}, [BUF, :128]! | 135 | vld1.8 {q3-q4}, [BUF, :128]! |
| 136 | vmov.i8 qzr, #0 | 136 | vmov.i8 qzr, #0 |
| 137 | vmov.i8 qCONSTANT, #0 | 137 | vmov.i8 qCONSTANT, #0 |
| 138 | vmov dCONSTANTl[0], CRC | 138 | vmov.32 dCONSTANTl[0], CRC |
| 139 | veor.8 d2, d2, dCONSTANTl | 139 | veor.8 d2, d2, dCONSTANTl |
| 140 | sub LEN, LEN, #0x40 | 140 | sub LEN, LEN, #0x40 |
| 141 | cmp LEN, #0x40 | 141 | cmp LEN, #0x40 |
diff --git a/crypto/ccm.c b/crypto/ccm.c index 442848807a52..1ce37ae0ce56 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c | |||
| @@ -45,6 +45,7 @@ struct crypto_rfc4309_req_ctx { | |||
| 45 | 45 | ||
| 46 | struct crypto_ccm_req_priv_ctx { | 46 | struct crypto_ccm_req_priv_ctx { |
| 47 | u8 odata[16]; | 47 | u8 odata[16]; |
| 48 | u8 idata[16]; | ||
| 48 | u8 auth_tag[16]; | 49 | u8 auth_tag[16]; |
| 49 | u32 flags; | 50 | u32 flags; |
| 50 | struct scatterlist src[3]; | 51 | struct scatterlist src[3]; |
| @@ -183,8 +184,8 @@ static int crypto_ccm_auth(struct aead_request *req, struct scatterlist *plain, | |||
| 183 | AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); | 184 | AHASH_REQUEST_ON_STACK(ahreq, ctx->mac); |
| 184 | unsigned int assoclen = req->assoclen; | 185 | unsigned int assoclen = req->assoclen; |
| 185 | struct scatterlist sg[3]; | 186 | struct scatterlist sg[3]; |
| 186 | u8 odata[16]; | 187 | u8 *odata = pctx->odata; |
| 187 | u8 idata[16]; | 188 | u8 *idata = pctx->idata; |
| 188 | int ilen, err; | 189 | int ilen, err; |
| 189 | 190 | ||
| 190 | /* format control data for input */ | 191 | /* format control data for input */ |
diff --git a/crypto/testmgr.h b/crypto/testmgr.h index 006ecc434351..03f473116f78 100644 --- a/crypto/testmgr.h +++ b/crypto/testmgr.h | |||
| @@ -22691,7 +22691,7 @@ static struct aead_testvec aes_ccm_enc_tv_template[] = { | |||
| 22691 | "\x09\x75\x9a\x9b\x3c\x9b\x27\x39", | 22691 | "\x09\x75\x9a\x9b\x3c\x9b\x27\x39", |
| 22692 | .klen = 32, | 22692 | .klen = 32, |
| 22693 | .iv = "\x03\xf9\xd9\x4e\x63\xb5\x3d\x9d" | 22693 | .iv = "\x03\xf9\xd9\x4e\x63\xb5\x3d\x9d" |
| 22694 | "\x43\xf6\x1e\x50", | 22694 | "\x43\xf6\x1e\x50\0\0\0\0", |
| 22695 | .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b" | 22695 | .assoc = "\x57\xf5\x6b\x8b\x57\x5c\x3d\x3b" |
| 22696 | "\x13\x02\x01\x0c\x83\x4c\x96\x35" | 22696 | "\x13\x02\x01\x0c\x83\x4c\x96\x35" |
| 22697 | "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94" | 22697 | "\x8e\xd6\x39\xcf\x7d\x14\x9b\x94" |
diff --git a/crypto/xts.c b/crypto/xts.c index 410a2e299085..baeb34dd8582 100644 --- a/crypto/xts.c +++ b/crypto/xts.c | |||
| @@ -463,6 +463,7 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb) | |||
| 463 | struct xts_instance_ctx *ctx; | 463 | struct xts_instance_ctx *ctx; |
| 464 | struct skcipher_alg *alg; | 464 | struct skcipher_alg *alg; |
| 465 | const char *cipher_name; | 465 | const char *cipher_name; |
| 466 | u32 mask; | ||
| 466 | int err; | 467 | int err; |
| 467 | 468 | ||
| 468 | algt = crypto_get_attr_type(tb); | 469 | algt = crypto_get_attr_type(tb); |
| @@ -483,18 +484,19 @@ static int create(struct crypto_template *tmpl, struct rtattr **tb) | |||
| 483 | ctx = skcipher_instance_ctx(inst); | 484 | ctx = skcipher_instance_ctx(inst); |
| 484 | 485 | ||
| 485 | crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst)); | 486 | crypto_set_skcipher_spawn(&ctx->spawn, skcipher_crypto_instance(inst)); |
| 486 | err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, | 487 | |
| 487 | crypto_requires_sync(algt->type, | 488 | mask = crypto_requires_off(algt->type, algt->mask, |
| 488 | algt->mask)); | 489 | CRYPTO_ALG_NEED_FALLBACK | |
| 490 | CRYPTO_ALG_ASYNC); | ||
| 491 | |||
| 492 | err = crypto_grab_skcipher(&ctx->spawn, cipher_name, 0, mask); | ||
| 489 | if (err == -ENOENT) { | 493 | if (err == -ENOENT) { |
| 490 | err = -ENAMETOOLONG; | 494 | err = -ENAMETOOLONG; |
| 491 | if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)", | 495 | if (snprintf(ctx->name, CRYPTO_MAX_ALG_NAME, "ecb(%s)", |
| 492 | cipher_name) >= CRYPTO_MAX_ALG_NAME) | 496 | cipher_name) >= CRYPTO_MAX_ALG_NAME) |
| 493 | goto err_free_inst; | 497 | goto err_free_inst; |
| 494 | 498 | ||
| 495 | err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, | 499 | err = crypto_grab_skcipher(&ctx->spawn, ctx->name, 0, mask); |
| 496 | crypto_requires_sync(algt->type, | ||
| 497 | algt->mask)); | ||
| 498 | } | 500 | } |
| 499 | 501 | ||
| 500 | if (err) | 502 | if (err) |
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 0b49dbc423e2..473d31288ad8 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig | |||
| @@ -459,6 +459,7 @@ config CRYPTO_DEV_ATMEL_AES | |||
| 459 | 459 | ||
| 460 | config CRYPTO_DEV_ATMEL_TDES | 460 | config CRYPTO_DEV_ATMEL_TDES |
| 461 | tristate "Support for Atmel DES/TDES hw accelerator" | 461 | tristate "Support for Atmel DES/TDES hw accelerator" |
| 462 | depends on HAS_DMA | ||
| 462 | depends on ARCH_AT91 || COMPILE_TEST | 463 | depends on ARCH_AT91 || COMPILE_TEST |
| 463 | select CRYPTO_DES | 464 | select CRYPTO_DES |
| 464 | select CRYPTO_BLKCIPHER | 465 | select CRYPTO_BLKCIPHER |
| @@ -472,6 +473,7 @@ config CRYPTO_DEV_ATMEL_TDES | |||
| 472 | 473 | ||
| 473 | config CRYPTO_DEV_ATMEL_SHA | 474 | config CRYPTO_DEV_ATMEL_SHA |
| 474 | tristate "Support for Atmel SHA hw accelerator" | 475 | tristate "Support for Atmel SHA hw accelerator" |
| 476 | depends on HAS_DMA | ||
| 475 | depends on ARCH_AT91 || COMPILE_TEST | 477 | depends on ARCH_AT91 || COMPILE_TEST |
| 476 | select CRYPTO_HASH | 478 | select CRYPTO_HASH |
| 477 | help | 479 | help |
| @@ -583,6 +585,7 @@ config CRYPTO_DEV_ROCKCHIP | |||
| 583 | 585 | ||
| 584 | config CRYPTO_DEV_MEDIATEK | 586 | config CRYPTO_DEV_MEDIATEK |
| 585 | tristate "MediaTek's EIP97 Cryptographic Engine driver" | 587 | tristate "MediaTek's EIP97 Cryptographic Engine driver" |
| 588 | depends on HAS_DMA | ||
| 586 | depends on (ARM && ARCH_MEDIATEK) || COMPILE_TEST | 589 | depends on (ARM && ARCH_MEDIATEK) || COMPILE_TEST |
| 587 | select CRYPTO_AES | 590 | select CRYPTO_AES |
| 588 | select CRYPTO_AEAD | 591 | select CRYPTO_AEAD |
diff --git a/drivers/crypto/cavium/cpt/cptvf_main.c b/drivers/crypto/cavium/cpt/cptvf_main.c index aac2966ff8d9..6ffc740c7431 100644 --- a/drivers/crypto/cavium/cpt/cptvf_main.c +++ b/drivers/crypto/cavium/cpt/cptvf_main.c | |||
| @@ -242,6 +242,7 @@ static int alloc_command_queues(struct cpt_vf *cptvf, | |||
| 242 | if (!curr->head) { | 242 | if (!curr->head) { |
| 243 | dev_err(&pdev->dev, "Command Q (%d) chunk (%d) allocation failed\n", | 243 | dev_err(&pdev->dev, "Command Q (%d) chunk (%d) allocation failed\n", |
| 244 | i, queue->nchunks); | 244 | i, queue->nchunks); |
| 245 | kfree(curr); | ||
| 245 | goto cmd_qfail; | 246 | goto cmd_qfail; |
| 246 | } | 247 | } |
| 247 | 248 | ||
| @@ -815,8 +816,10 @@ static void cptvf_remove(struct pci_dev *pdev) | |||
| 815 | { | 816 | { |
| 816 | struct cpt_vf *cptvf = pci_get_drvdata(pdev); | 817 | struct cpt_vf *cptvf = pci_get_drvdata(pdev); |
| 817 | 818 | ||
| 818 | if (!cptvf) | 819 | if (!cptvf) { |
| 819 | dev_err(&pdev->dev, "Invalid CPT-VF device\n"); | 820 | dev_err(&pdev->dev, "Invalid CPT-VF device\n"); |
| 821 | return; | ||
| 822 | } | ||
| 820 | 823 | ||
| 821 | /* Convey DOWN to PF */ | 824 | /* Convey DOWN to PF */ |
| 822 | if (cptvf_send_vf_down(cptvf)) { | 825 | if (cptvf_send_vf_down(cptvf)) { |
diff --git a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c index 7f57f30f8863..169e66231bcf 100644 --- a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c +++ b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c | |||
| @@ -330,8 +330,8 @@ void do_post_process(struct cpt_vf *cptvf, struct cpt_info_buffer *info) | |||
| 330 | { | 330 | { |
| 331 | struct pci_dev *pdev = cptvf->pdev; | 331 | struct pci_dev *pdev = cptvf->pdev; |
| 332 | 332 | ||
| 333 | if (!info || !cptvf) { | 333 | if (!info) { |
| 334 | dev_err(&pdev->dev, "Input params are incorrect for post processing\n"); | 334 | dev_err(&pdev->dev, "incorrect cpt_info_buffer for post processing\n"); |
| 335 | return; | 335 | return; |
| 336 | } | 336 | } |
| 337 | 337 | ||
diff --git a/drivers/crypto/vmx/aes_cbc.c b/drivers/crypto/vmx/aes_cbc.c index 94ad5c0adbcb..72a26eb4e954 100644 --- a/drivers/crypto/vmx/aes_cbc.c +++ b/drivers/crypto/vmx/aes_cbc.c | |||
| @@ -27,11 +27,12 @@ | |||
| 27 | #include <asm/switch_to.h> | 27 | #include <asm/switch_to.h> |
| 28 | #include <crypto/aes.h> | 28 | #include <crypto/aes.h> |
| 29 | #include <crypto/scatterwalk.h> | 29 | #include <crypto/scatterwalk.h> |
| 30 | #include <crypto/skcipher.h> | ||
| 30 | 31 | ||
| 31 | #include "aesp8-ppc.h" | 32 | #include "aesp8-ppc.h" |
| 32 | 33 | ||
| 33 | struct p8_aes_cbc_ctx { | 34 | struct p8_aes_cbc_ctx { |
| 34 | struct crypto_blkcipher *fallback; | 35 | struct crypto_skcipher *fallback; |
| 35 | struct aes_key enc_key; | 36 | struct aes_key enc_key; |
| 36 | struct aes_key dec_key; | 37 | struct aes_key dec_key; |
| 37 | }; | 38 | }; |
| @@ -39,7 +40,7 @@ struct p8_aes_cbc_ctx { | |||
| 39 | static int p8_aes_cbc_init(struct crypto_tfm *tfm) | 40 | static int p8_aes_cbc_init(struct crypto_tfm *tfm) |
| 40 | { | 41 | { |
| 41 | const char *alg; | 42 | const char *alg; |
| 42 | struct crypto_blkcipher *fallback; | 43 | struct crypto_skcipher *fallback; |
| 43 | struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); | 44 | struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); |
| 44 | 45 | ||
| 45 | if (!(alg = crypto_tfm_alg_name(tfm))) { | 46 | if (!(alg = crypto_tfm_alg_name(tfm))) { |
| @@ -47,8 +48,9 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm) | |||
| 47 | return -ENOENT; | 48 | return -ENOENT; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | fallback = | 51 | fallback = crypto_alloc_skcipher(alg, 0, |
| 51 | crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); | 52 | CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); |
| 53 | |||
| 52 | if (IS_ERR(fallback)) { | 54 | if (IS_ERR(fallback)) { |
| 53 | printk(KERN_ERR | 55 | printk(KERN_ERR |
| 54 | "Failed to allocate transformation for '%s': %ld\n", | 56 | "Failed to allocate transformation for '%s': %ld\n", |
| @@ -56,11 +58,12 @@ static int p8_aes_cbc_init(struct crypto_tfm *tfm) | |||
| 56 | return PTR_ERR(fallback); | 58 | return PTR_ERR(fallback); |
| 57 | } | 59 | } |
| 58 | printk(KERN_INFO "Using '%s' as fallback implementation.\n", | 60 | printk(KERN_INFO "Using '%s' as fallback implementation.\n", |
| 59 | crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback)); | 61 | crypto_skcipher_driver_name(fallback)); |
| 62 | |||
| 60 | 63 | ||
| 61 | crypto_blkcipher_set_flags( | 64 | crypto_skcipher_set_flags( |
| 62 | fallback, | 65 | fallback, |
| 63 | crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); | 66 | crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); |
| 64 | ctx->fallback = fallback; | 67 | ctx->fallback = fallback; |
| 65 | 68 | ||
| 66 | return 0; | 69 | return 0; |
| @@ -71,7 +74,7 @@ static void p8_aes_cbc_exit(struct crypto_tfm *tfm) | |||
| 71 | struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); | 74 | struct p8_aes_cbc_ctx *ctx = crypto_tfm_ctx(tfm); |
| 72 | 75 | ||
| 73 | if (ctx->fallback) { | 76 | if (ctx->fallback) { |
| 74 | crypto_free_blkcipher(ctx->fallback); | 77 | crypto_free_skcipher(ctx->fallback); |
| 75 | ctx->fallback = NULL; | 78 | ctx->fallback = NULL; |
| 76 | } | 79 | } |
| 77 | } | 80 | } |
| @@ -91,7 +94,7 @@ static int p8_aes_cbc_setkey(struct crypto_tfm *tfm, const u8 *key, | |||
| 91 | pagefault_enable(); | 94 | pagefault_enable(); |
| 92 | preempt_enable(); | 95 | preempt_enable(); |
| 93 | 96 | ||
| 94 | ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); | 97 | ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); |
| 95 | return ret; | 98 | return ret; |
| 96 | } | 99 | } |
| 97 | 100 | ||
| @@ -103,15 +106,14 @@ static int p8_aes_cbc_encrypt(struct blkcipher_desc *desc, | |||
| 103 | struct blkcipher_walk walk; | 106 | struct blkcipher_walk walk; |
| 104 | struct p8_aes_cbc_ctx *ctx = | 107 | struct p8_aes_cbc_ctx *ctx = |
| 105 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); | 108 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); |
| 106 | struct blkcipher_desc fallback_desc = { | ||
| 107 | .tfm = ctx->fallback, | ||
| 108 | .info = desc->info, | ||
| 109 | .flags = desc->flags | ||
| 110 | }; | ||
| 111 | 109 | ||
| 112 | if (in_interrupt()) { | 110 | if (in_interrupt()) { |
| 113 | ret = crypto_blkcipher_encrypt(&fallback_desc, dst, src, | 111 | SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); |
| 114 | nbytes); | 112 | skcipher_request_set_tfm(req, ctx->fallback); |
| 113 | skcipher_request_set_callback(req, desc->flags, NULL, NULL); | ||
| 114 | skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); | ||
| 115 | ret = crypto_skcipher_encrypt(req); | ||
| 116 | skcipher_request_zero(req); | ||
| 115 | } else { | 117 | } else { |
| 116 | preempt_disable(); | 118 | preempt_disable(); |
| 117 | pagefault_disable(); | 119 | pagefault_disable(); |
| @@ -144,15 +146,14 @@ static int p8_aes_cbc_decrypt(struct blkcipher_desc *desc, | |||
| 144 | struct blkcipher_walk walk; | 146 | struct blkcipher_walk walk; |
| 145 | struct p8_aes_cbc_ctx *ctx = | 147 | struct p8_aes_cbc_ctx *ctx = |
| 146 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); | 148 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); |
| 147 | struct blkcipher_desc fallback_desc = { | ||
| 148 | .tfm = ctx->fallback, | ||
| 149 | .info = desc->info, | ||
| 150 | .flags = desc->flags | ||
| 151 | }; | ||
| 152 | 149 | ||
| 153 | if (in_interrupt()) { | 150 | if (in_interrupt()) { |
| 154 | ret = crypto_blkcipher_decrypt(&fallback_desc, dst, src, | 151 | SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); |
| 155 | nbytes); | 152 | skcipher_request_set_tfm(req, ctx->fallback); |
| 153 | skcipher_request_set_callback(req, desc->flags, NULL, NULL); | ||
| 154 | skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); | ||
| 155 | ret = crypto_skcipher_decrypt(req); | ||
| 156 | skcipher_request_zero(req); | ||
| 156 | } else { | 157 | } else { |
| 157 | preempt_disable(); | 158 | preempt_disable(); |
| 158 | pagefault_disable(); | 159 | pagefault_disable(); |
diff --git a/drivers/crypto/vmx/aes_xts.c b/drivers/crypto/vmx/aes_xts.c index 24353ec336c5..6adc9290557a 100644 --- a/drivers/crypto/vmx/aes_xts.c +++ b/drivers/crypto/vmx/aes_xts.c | |||
| @@ -28,11 +28,12 @@ | |||
| 28 | #include <crypto/aes.h> | 28 | #include <crypto/aes.h> |
| 29 | #include <crypto/scatterwalk.h> | 29 | #include <crypto/scatterwalk.h> |
| 30 | #include <crypto/xts.h> | 30 | #include <crypto/xts.h> |
| 31 | #include <crypto/skcipher.h> | ||
| 31 | 32 | ||
| 32 | #include "aesp8-ppc.h" | 33 | #include "aesp8-ppc.h" |
| 33 | 34 | ||
| 34 | struct p8_aes_xts_ctx { | 35 | struct p8_aes_xts_ctx { |
| 35 | struct crypto_blkcipher *fallback; | 36 | struct crypto_skcipher *fallback; |
| 36 | struct aes_key enc_key; | 37 | struct aes_key enc_key; |
| 37 | struct aes_key dec_key; | 38 | struct aes_key dec_key; |
| 38 | struct aes_key tweak_key; | 39 | struct aes_key tweak_key; |
| @@ -41,7 +42,7 @@ struct p8_aes_xts_ctx { | |||
| 41 | static int p8_aes_xts_init(struct crypto_tfm *tfm) | 42 | static int p8_aes_xts_init(struct crypto_tfm *tfm) |
| 42 | { | 43 | { |
| 43 | const char *alg; | 44 | const char *alg; |
| 44 | struct crypto_blkcipher *fallback; | 45 | struct crypto_skcipher *fallback; |
| 45 | struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); | 46 | struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); |
| 46 | 47 | ||
| 47 | if (!(alg = crypto_tfm_alg_name(tfm))) { | 48 | if (!(alg = crypto_tfm_alg_name(tfm))) { |
| @@ -49,8 +50,8 @@ static int p8_aes_xts_init(struct crypto_tfm *tfm) | |||
| 49 | return -ENOENT; | 50 | return -ENOENT; |
| 50 | } | 51 | } |
| 51 | 52 | ||
| 52 | fallback = | 53 | fallback = crypto_alloc_skcipher(alg, 0, |
| 53 | crypto_alloc_blkcipher(alg, 0, CRYPTO_ALG_NEED_FALLBACK); | 54 | CRYPTO_ALG_ASYNC | CRYPTO_ALG_NEED_FALLBACK); |
| 54 | if (IS_ERR(fallback)) { | 55 | if (IS_ERR(fallback)) { |
| 55 | printk(KERN_ERR | 56 | printk(KERN_ERR |
| 56 | "Failed to allocate transformation for '%s': %ld\n", | 57 | "Failed to allocate transformation for '%s': %ld\n", |
| @@ -58,11 +59,11 @@ static int p8_aes_xts_init(struct crypto_tfm *tfm) | |||
| 58 | return PTR_ERR(fallback); | 59 | return PTR_ERR(fallback); |
| 59 | } | 60 | } |
| 60 | printk(KERN_INFO "Using '%s' as fallback implementation.\n", | 61 | printk(KERN_INFO "Using '%s' as fallback implementation.\n", |
| 61 | crypto_tfm_alg_driver_name((struct crypto_tfm *) fallback)); | 62 | crypto_skcipher_driver_name(fallback)); |
| 62 | 63 | ||
| 63 | crypto_blkcipher_set_flags( | 64 | crypto_skcipher_set_flags( |
| 64 | fallback, | 65 | fallback, |
| 65 | crypto_blkcipher_get_flags((struct crypto_blkcipher *)tfm)); | 66 | crypto_skcipher_get_flags((struct crypto_skcipher *)tfm)); |
| 66 | ctx->fallback = fallback; | 67 | ctx->fallback = fallback; |
| 67 | 68 | ||
| 68 | return 0; | 69 | return 0; |
| @@ -73,7 +74,7 @@ static void p8_aes_xts_exit(struct crypto_tfm *tfm) | |||
| 73 | struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); | 74 | struct p8_aes_xts_ctx *ctx = crypto_tfm_ctx(tfm); |
| 74 | 75 | ||
| 75 | if (ctx->fallback) { | 76 | if (ctx->fallback) { |
| 76 | crypto_free_blkcipher(ctx->fallback); | 77 | crypto_free_skcipher(ctx->fallback); |
| 77 | ctx->fallback = NULL; | 78 | ctx->fallback = NULL; |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| @@ -98,7 +99,7 @@ static int p8_aes_xts_setkey(struct crypto_tfm *tfm, const u8 *key, | |||
| 98 | pagefault_enable(); | 99 | pagefault_enable(); |
| 99 | preempt_enable(); | 100 | preempt_enable(); |
| 100 | 101 | ||
| 101 | ret += crypto_blkcipher_setkey(ctx->fallback, key, keylen); | 102 | ret += crypto_skcipher_setkey(ctx->fallback, key, keylen); |
| 102 | return ret; | 103 | return ret; |
| 103 | } | 104 | } |
| 104 | 105 | ||
| @@ -113,15 +114,14 @@ static int p8_aes_xts_crypt(struct blkcipher_desc *desc, | |||
| 113 | struct blkcipher_walk walk; | 114 | struct blkcipher_walk walk; |
| 114 | struct p8_aes_xts_ctx *ctx = | 115 | struct p8_aes_xts_ctx *ctx = |
| 115 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); | 116 | crypto_tfm_ctx(crypto_blkcipher_tfm(desc->tfm)); |
| 116 | struct blkcipher_desc fallback_desc = { | ||
| 117 | .tfm = ctx->fallback, | ||
| 118 | .info = desc->info, | ||
| 119 | .flags = desc->flags | ||
| 120 | }; | ||
| 121 | 117 | ||
| 122 | if (in_interrupt()) { | 118 | if (in_interrupt()) { |
| 123 | ret = enc ? crypto_blkcipher_encrypt(&fallback_desc, dst, src, nbytes) : | 119 | SKCIPHER_REQUEST_ON_STACK(req, ctx->fallback); |
| 124 | crypto_blkcipher_decrypt(&fallback_desc, dst, src, nbytes); | 120 | skcipher_request_set_tfm(req, ctx->fallback); |
| 121 | skcipher_request_set_callback(req, desc->flags, NULL, NULL); | ||
| 122 | skcipher_request_set_crypt(req, src, dst, nbytes, desc->info); | ||
| 123 | ret = enc? crypto_skcipher_encrypt(req) : crypto_skcipher_decrypt(req); | ||
| 124 | skcipher_request_zero(req); | ||
| 125 | } else { | 125 | } else { |
| 126 | preempt_disable(); | 126 | preempt_disable(); |
| 127 | pagefault_disable(); | 127 | pagefault_disable(); |
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index ebe4ded0c55d..436c4c2683c7 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h | |||
| @@ -360,13 +360,18 @@ static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, | |||
| 360 | return crypto_attr_alg(tb[1], type, mask); | 360 | return crypto_attr_alg(tb[1], type, mask); |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | static inline int crypto_requires_off(u32 type, u32 mask, u32 off) | ||
| 364 | { | ||
| 365 | return (type ^ off) & mask & off; | ||
| 366 | } | ||
| 367 | |||
| 363 | /* | 368 | /* |
| 364 | * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms. | 369 | * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms. |
| 365 | * Otherwise returns zero. | 370 | * Otherwise returns zero. |
| 366 | */ | 371 | */ |
| 367 | static inline int crypto_requires_sync(u32 type, u32 mask) | 372 | static inline int crypto_requires_sync(u32 type, u32 mask) |
| 368 | { | 373 | { |
| 369 | return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC; | 374 | return crypto_requires_off(type, mask, CRYPTO_ALG_ASYNC); |
| 370 | } | 375 | } |
| 371 | 376 | ||
| 372 | noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size); | 377 | noinline unsigned long __crypto_memneq(const void *a, const void *b, size_t size); |
