diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-25 18:56:15 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-25 18:56:15 -0500 |
| commit | 32dc43e40a2707d0cb1ab8768d080c3e9bcfed52 (patch) | |
| tree | 415f3a1935fba0db2f0410360983587bf65ee712 /crypto | |
| parent | d414c104e26fd3b597f855cc29473a8b1527fb4c (diff) | |
| parent | 8fd61d34226014fe7886babfca6f45a7eff89d25 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto update from Herbert Xu:
"Here is the crypto update for 3.9:
- Added accelerated implementation of crc32 using pclmulqdq.
- Added test vector for fcrypt.
- Added support for OMAP4/AM33XX cipher and hash.
- Fixed loose crypto_user input checks.
- Misc fixes"
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (43 commits)
crypto: user - ensure user supplied strings are nul-terminated
crypto: user - fix empty string test in report API
crypto: user - fix info leaks in report API
crypto: caam - Added property fsl,sec-era in SEC4.0 device tree binding.
crypto: use ERR_CAST
crypto: atmel-aes - adjust duplicate test
crypto: crc32-pclmul - Kill warning on x86-32
crypto: x86/twofish - assembler clean-ups: use ENTRY/ENDPROC, localize jump labels
crypto: x86/sha1 - assembler clean-ups: use ENTRY/ENDPROC
crypto: x86/serpent - use ENTRY/ENDPROC for assember functions and localize jump targets
crypto: x86/salsa20 - assembler cleanup, use ENTRY/ENDPROC for assember functions and rename ECRYPT_* to salsa20_*
crypto: x86/ghash - assembler clean-up: use ENDPROC at end of assember functions
crypto: x86/crc32c - assembler clean-up: use ENTRY/ENDPROC
crypto: cast6-avx: use ENTRY()/ENDPROC() for assembler functions
crypto: cast5-avx: use ENTRY()/ENDPROC() for assembler functions and localize jump targets
crypto: camellia-x86_64/aes-ni: use ENTRY()/ENDPROC() for assembler functions and localize jump targets
crypto: blowfish-x86_64: use ENTRY()/ENDPROC() for assembler functions and localize jump targets
crypto: aesni-intel - add ENDPROC statements for assembler functions
crypto: x86/aes - assembler clean-ups: use ENTRY/ENDPROC, localize jump targets
crypto: testmgr - add test vector for fcrypt
...
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/Kconfig | 21 | ||||
| -rw-r--r-- | crypto/Makefile | 1 | ||||
| -rw-r--r-- | crypto/ablkcipher.c | 12 | ||||
| -rw-r--r-- | crypto/aead.c | 15 | ||||
| -rw-r--r-- | crypto/ahash.c | 2 | ||||
| -rw-r--r-- | crypto/algapi.c | 4 | ||||
| -rw-r--r-- | crypto/authenc.c | 3 | ||||
| -rw-r--r-- | crypto/authencesn.c | 3 | ||||
| -rw-r--r-- | crypto/blkcipher.c | 12 | ||||
| -rw-r--r-- | crypto/ccm.c | 23 | ||||
| -rw-r--r-- | crypto/chainiv.c | 3 | ||||
| -rw-r--r-- | crypto/crc32.c | 158 | ||||
| -rw-r--r-- | crypto/crypto_user.c | 38 | ||||
| -rw-r--r-- | crypto/ctr.c | 6 | ||||
| -rw-r--r-- | crypto/cts.c | 3 | ||||
| -rw-r--r-- | crypto/gcm.c | 29 | ||||
| -rw-r--r-- | crypto/pcompress.c | 3 | ||||
| -rw-r--r-- | crypto/rng.c | 2 | ||||
| -rw-r--r-- | crypto/seqiv.c | 3 | ||||
| -rw-r--r-- | crypto/shash.c | 3 | ||||
| -rw-r--r-- | crypto/testmgr.c | 15 |
21 files changed, 267 insertions, 92 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig index 0880a14834aa..05c0ce52f96d 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig | |||
| @@ -353,6 +353,27 @@ config CRYPTO_CRC32C_SPARC64 | |||
| 353 | CRC32c CRC algorithm implemented using sparc64 crypto instructions, | 353 | CRC32c CRC algorithm implemented using sparc64 crypto instructions, |
| 354 | when available. | 354 | when available. |
| 355 | 355 | ||
| 356 | config CRYPTO_CRC32 | ||
| 357 | tristate "CRC32 CRC algorithm" | ||
| 358 | select CRYPTO_HASH | ||
| 359 | select CRC32 | ||
| 360 | help | ||
| 361 | CRC-32-IEEE 802.3 cyclic redundancy-check algorithm. | ||
| 362 | Shash crypto api wrappers to crc32_le function. | ||
| 363 | |||
| 364 | config CRYPTO_CRC32_PCLMUL | ||
| 365 | tristate "CRC32 PCLMULQDQ hardware acceleration" | ||
| 366 | depends on X86 | ||
| 367 | select CRYPTO_HASH | ||
| 368 | select CRC32 | ||
| 369 | help | ||
| 370 | From Intel Westmere and AMD Bulldozer processor with SSE4.2 | ||
| 371 | and PCLMULQDQ supported, the processor will support | ||
| 372 | CRC32 PCLMULQDQ implementation using hardware accelerated PCLMULQDQ | ||
| 373 | instruction. This option will create 'crc32-plcmul' module, | ||
| 374 | which will enable any routine to use the CRC-32-IEEE 802.3 checksum | ||
| 375 | and gain better performance as compared with the table implementation. | ||
| 376 | |||
| 356 | config CRYPTO_GHASH | 377 | config CRYPTO_GHASH |
| 357 | tristate "GHASH digest algorithm" | 378 | tristate "GHASH digest algorithm" |
| 358 | select CRYPTO_GF128MUL | 379 | select CRYPTO_GF128MUL |
diff --git a/crypto/Makefile b/crypto/Makefile index d59dec749804..be1a1bebbb86 100644 --- a/crypto/Makefile +++ b/crypto/Makefile | |||
| @@ -81,6 +81,7 @@ obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o | |||
| 81 | obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o | 81 | obj-$(CONFIG_CRYPTO_ZLIB) += zlib.o |
| 82 | obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o | 82 | obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o |
| 83 | obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o | 83 | obj-$(CONFIG_CRYPTO_CRC32C) += crc32c.o |
| 84 | obj-$(CONFIG_CRYPTO_CRC32) += crc32.o | ||
| 84 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o | 85 | obj-$(CONFIG_CRYPTO_AUTHENC) += authenc.o authencesn.o |
| 85 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o | 86 | obj-$(CONFIG_CRYPTO_LZO) += lzo.o |
| 86 | obj-$(CONFIG_CRYPTO_842) += 842.o | 87 | obj-$(CONFIG_CRYPTO_842) += 842.o |
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index 533de9550a82..7d4a8d28277e 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
| @@ -388,9 +388,9 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 388 | { | 388 | { |
| 389 | struct crypto_report_blkcipher rblkcipher; | 389 | struct crypto_report_blkcipher rblkcipher; |
| 390 | 390 | ||
| 391 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "ablkcipher"); | 391 | strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type)); |
| 392 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | 392 | strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>", |
| 393 | alg->cra_ablkcipher.geniv ?: "<default>"); | 393 | sizeof(rblkcipher.geniv)); |
| 394 | 394 | ||
| 395 | rblkcipher.blocksize = alg->cra_blocksize; | 395 | rblkcipher.blocksize = alg->cra_blocksize; |
| 396 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; | 396 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; |
| @@ -469,9 +469,9 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 469 | { | 469 | { |
| 470 | struct crypto_report_blkcipher rblkcipher; | 470 | struct crypto_report_blkcipher rblkcipher; |
| 471 | 471 | ||
| 472 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "givcipher"); | 472 | strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type)); |
| 473 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | 473 | strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>", |
| 474 | alg->cra_ablkcipher.geniv ?: "<built-in>"); | 474 | sizeof(rblkcipher.geniv)); |
| 475 | 475 | ||
| 476 | rblkcipher.blocksize = alg->cra_blocksize; | 476 | rblkcipher.blocksize = alg->cra_blocksize; |
| 477 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; | 477 | rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize; |
diff --git a/crypto/aead.c b/crypto/aead.c index 0b8121ebec07..547491e35c63 100644 --- a/crypto/aead.c +++ b/crypto/aead.c | |||
| @@ -117,9 +117,8 @@ static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 117 | struct crypto_report_aead raead; | 117 | struct crypto_report_aead raead; |
| 118 | struct aead_alg *aead = &alg->cra_aead; | 118 | struct aead_alg *aead = &alg->cra_aead; |
| 119 | 119 | ||
| 120 | snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "aead"); | 120 | strncpy(raead.type, "aead", sizeof(raead.type)); |
| 121 | snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", | 121 | strncpy(raead.geniv, aead->geniv ?: "<built-in>", sizeof(raead.geniv)); |
| 122 | aead->geniv ?: "<built-in>"); | ||
| 123 | 122 | ||
| 124 | raead.blocksize = alg->cra_blocksize; | 123 | raead.blocksize = alg->cra_blocksize; |
| 125 | raead.maxauthsize = aead->maxauthsize; | 124 | raead.maxauthsize = aead->maxauthsize; |
| @@ -203,8 +202,8 @@ static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 203 | struct crypto_report_aead raead; | 202 | struct crypto_report_aead raead; |
| 204 | struct aead_alg *aead = &alg->cra_aead; | 203 | struct aead_alg *aead = &alg->cra_aead; |
| 205 | 204 | ||
| 206 | snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "nivaead"); | 205 | strncpy(raead.type, "nivaead", sizeof(raead.type)); |
| 207 | snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", aead->geniv); | 206 | strncpy(raead.geniv, aead->geniv, sizeof(raead.geniv)); |
| 208 | 207 | ||
| 209 | raead.blocksize = alg->cra_blocksize; | 208 | raead.blocksize = alg->cra_blocksize; |
| 210 | raead.maxauthsize = aead->maxauthsize; | 209 | raead.maxauthsize = aead->maxauthsize; |
| @@ -282,18 +281,16 @@ struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl, | |||
| 282 | int err; | 281 | int err; |
| 283 | 282 | ||
| 284 | algt = crypto_get_attr_type(tb); | 283 | algt = crypto_get_attr_type(tb); |
| 285 | err = PTR_ERR(algt); | ||
| 286 | if (IS_ERR(algt)) | 284 | if (IS_ERR(algt)) |
| 287 | return ERR_PTR(err); | 285 | return ERR_CAST(algt); |
| 288 | 286 | ||
| 289 | if ((algt->type ^ (CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_GENIV)) & | 287 | if ((algt->type ^ (CRYPTO_ALG_TYPE_AEAD | CRYPTO_ALG_GENIV)) & |
| 290 | algt->mask) | 288 | algt->mask) |
| 291 | return ERR_PTR(-EINVAL); | 289 | return ERR_PTR(-EINVAL); |
| 292 | 290 | ||
| 293 | name = crypto_attr_alg_name(tb[1]); | 291 | name = crypto_attr_alg_name(tb[1]); |
| 294 | err = PTR_ERR(name); | ||
| 295 | if (IS_ERR(name)) | 292 | if (IS_ERR(name)) |
| 296 | return ERR_PTR(err); | 293 | return ERR_CAST(name); |
| 297 | 294 | ||
| 298 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 295 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 299 | if (!inst) | 296 | if (!inst) |
diff --git a/crypto/ahash.c b/crypto/ahash.c index 3887856c2dd6..793a27f2493e 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c | |||
| @@ -404,7 +404,7 @@ static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 404 | { | 404 | { |
| 405 | struct crypto_report_hash rhash; | 405 | struct crypto_report_hash rhash; |
| 406 | 406 | ||
| 407 | snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "ahash"); | 407 | strncpy(rhash.type, "ahash", sizeof(rhash.type)); |
| 408 | 408 | ||
| 409 | rhash.blocksize = alg->cra_blocksize; | 409 | rhash.blocksize = alg->cra_blocksize; |
| 410 | rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize; | 410 | rhash.digestsize = __crypto_hash_alg_common(alg)->digestsize; |
diff --git a/crypto/algapi.c b/crypto/algapi.c index c3b9bfeeb7ff..08c57c8aec95 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c | |||
| @@ -749,12 +749,10 @@ struct crypto_alg *crypto_attr_alg2(struct rtattr *rta, | |||
| 749 | u32 type, u32 mask) | 749 | u32 type, u32 mask) |
| 750 | { | 750 | { |
| 751 | const char *name; | 751 | const char *name; |
| 752 | int err; | ||
| 753 | 752 | ||
| 754 | name = crypto_attr_alg_name(rta); | 753 | name = crypto_attr_alg_name(rta); |
| 755 | err = PTR_ERR(name); | ||
| 756 | if (IS_ERR(name)) | 754 | if (IS_ERR(name)) |
| 757 | return ERR_PTR(err); | 755 | return ERR_CAST(name); |
| 758 | 756 | ||
| 759 | return crypto_find_alg(name, frontend, type, mask); | 757 | return crypto_find_alg(name, frontend, type, mask); |
| 760 | } | 758 | } |
diff --git a/crypto/authenc.c b/crypto/authenc.c index d0583a4489e6..ffce19de05cf 100644 --- a/crypto/authenc.c +++ b/crypto/authenc.c | |||
| @@ -592,9 +592,8 @@ static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb) | |||
| 592 | int err; | 592 | int err; |
| 593 | 593 | ||
| 594 | algt = crypto_get_attr_type(tb); | 594 | algt = crypto_get_attr_type(tb); |
| 595 | err = PTR_ERR(algt); | ||
| 596 | if (IS_ERR(algt)) | 595 | if (IS_ERR(algt)) |
| 597 | return ERR_PTR(err); | 596 | return ERR_CAST(algt); |
| 598 | 597 | ||
| 599 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 598 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 600 | return ERR_PTR(-EINVAL); | 599 | return ERR_PTR(-EINVAL); |
diff --git a/crypto/authencesn.c b/crypto/authencesn.c index 136b68b9d8d4..ab53762fc309 100644 --- a/crypto/authencesn.c +++ b/crypto/authencesn.c | |||
| @@ -715,9 +715,8 @@ static struct crypto_instance *crypto_authenc_esn_alloc(struct rtattr **tb) | |||
| 715 | int err; | 715 | int err; |
| 716 | 716 | ||
| 717 | algt = crypto_get_attr_type(tb); | 717 | algt = crypto_get_attr_type(tb); |
| 718 | err = PTR_ERR(algt); | ||
| 719 | if (IS_ERR(algt)) | 718 | if (IS_ERR(algt)) |
| 720 | return ERR_PTR(err); | 719 | return ERR_CAST(algt); |
| 721 | 720 | ||
| 722 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 721 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 723 | return ERR_PTR(-EINVAL); | 722 | return ERR_PTR(-EINVAL); |
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index a8d85a1d670e..a79e7e9ab86e 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
| @@ -499,9 +499,9 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 499 | { | 499 | { |
| 500 | struct crypto_report_blkcipher rblkcipher; | 500 | struct crypto_report_blkcipher rblkcipher; |
| 501 | 501 | ||
| 502 | snprintf(rblkcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "blkcipher"); | 502 | strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type)); |
| 503 | snprintf(rblkcipher.geniv, CRYPTO_MAX_ALG_NAME, "%s", | 503 | strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>", |
| 504 | alg->cra_blkcipher.geniv ?: "<default>"); | 504 | sizeof(rblkcipher.geniv)); |
| 505 | 505 | ||
| 506 | rblkcipher.blocksize = alg->cra_blocksize; | 506 | rblkcipher.blocksize = alg->cra_blocksize; |
| 507 | rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize; | 507 | rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize; |
| @@ -588,18 +588,16 @@ struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl, | |||
| 588 | int err; | 588 | int err; |
| 589 | 589 | ||
| 590 | algt = crypto_get_attr_type(tb); | 590 | algt = crypto_get_attr_type(tb); |
| 591 | err = PTR_ERR(algt); | ||
| 592 | if (IS_ERR(algt)) | 591 | if (IS_ERR(algt)) |
| 593 | return ERR_PTR(err); | 592 | return ERR_CAST(algt); |
| 594 | 593 | ||
| 595 | if ((algt->type ^ (CRYPTO_ALG_TYPE_GIVCIPHER | CRYPTO_ALG_GENIV)) & | 594 | if ((algt->type ^ (CRYPTO_ALG_TYPE_GIVCIPHER | CRYPTO_ALG_GENIV)) & |
| 596 | algt->mask) | 595 | algt->mask) |
| 597 | return ERR_PTR(-EINVAL); | 596 | return ERR_PTR(-EINVAL); |
| 598 | 597 | ||
| 599 | name = crypto_attr_alg_name(tb[1]); | 598 | name = crypto_attr_alg_name(tb[1]); |
| 600 | err = PTR_ERR(name); | ||
| 601 | if (IS_ERR(name)) | 599 | if (IS_ERR(name)) |
| 602 | return ERR_PTR(err); | 600 | return ERR_CAST(name); |
| 603 | 601 | ||
| 604 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 602 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 605 | if (!inst) | 603 | if (!inst) |
diff --git a/crypto/ccm.c b/crypto/ccm.c index 32fe1bb5decb..499c91717d93 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c | |||
| @@ -484,18 +484,16 @@ static struct crypto_instance *crypto_ccm_alloc_common(struct rtattr **tb, | |||
| 484 | int err; | 484 | int err; |
| 485 | 485 | ||
| 486 | algt = crypto_get_attr_type(tb); | 486 | algt = crypto_get_attr_type(tb); |
| 487 | err = PTR_ERR(algt); | ||
| 488 | if (IS_ERR(algt)) | 487 | if (IS_ERR(algt)) |
| 489 | return ERR_PTR(err); | 488 | return ERR_CAST(algt); |
| 490 | 489 | ||
| 491 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 490 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 492 | return ERR_PTR(-EINVAL); | 491 | return ERR_PTR(-EINVAL); |
| 493 | 492 | ||
| 494 | cipher = crypto_alg_mod_lookup(cipher_name, CRYPTO_ALG_TYPE_CIPHER, | 493 | cipher = crypto_alg_mod_lookup(cipher_name, CRYPTO_ALG_TYPE_CIPHER, |
| 495 | CRYPTO_ALG_TYPE_MASK); | 494 | CRYPTO_ALG_TYPE_MASK); |
| 496 | err = PTR_ERR(cipher); | ||
| 497 | if (IS_ERR(cipher)) | 495 | if (IS_ERR(cipher)) |
| 498 | return ERR_PTR(err); | 496 | return ERR_CAST(cipher); |
| 499 | 497 | ||
| 500 | err = -EINVAL; | 498 | err = -EINVAL; |
| 501 | if (cipher->cra_blocksize != 16) | 499 | if (cipher->cra_blocksize != 16) |
| @@ -573,15 +571,13 @@ out_put_cipher: | |||
| 573 | 571 | ||
| 574 | static struct crypto_instance *crypto_ccm_alloc(struct rtattr **tb) | 572 | static struct crypto_instance *crypto_ccm_alloc(struct rtattr **tb) |
| 575 | { | 573 | { |
| 576 | int err; | ||
| 577 | const char *cipher_name; | 574 | const char *cipher_name; |
| 578 | char ctr_name[CRYPTO_MAX_ALG_NAME]; | 575 | char ctr_name[CRYPTO_MAX_ALG_NAME]; |
| 579 | char full_name[CRYPTO_MAX_ALG_NAME]; | 576 | char full_name[CRYPTO_MAX_ALG_NAME]; |
| 580 | 577 | ||
| 581 | cipher_name = crypto_attr_alg_name(tb[1]); | 578 | cipher_name = crypto_attr_alg_name(tb[1]); |
| 582 | err = PTR_ERR(cipher_name); | ||
| 583 | if (IS_ERR(cipher_name)) | 579 | if (IS_ERR(cipher_name)) |
| 584 | return ERR_PTR(err); | 580 | return ERR_CAST(cipher_name); |
| 585 | 581 | ||
| 586 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", | 582 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", |
| 587 | cipher_name) >= CRYPTO_MAX_ALG_NAME) | 583 | cipher_name) >= CRYPTO_MAX_ALG_NAME) |
| @@ -612,20 +608,17 @@ static struct crypto_template crypto_ccm_tmpl = { | |||
| 612 | 608 | ||
| 613 | static struct crypto_instance *crypto_ccm_base_alloc(struct rtattr **tb) | 609 | static struct crypto_instance *crypto_ccm_base_alloc(struct rtattr **tb) |
| 614 | { | 610 | { |
| 615 | int err; | ||
| 616 | const char *ctr_name; | 611 | const char *ctr_name; |
| 617 | const char *cipher_name; | 612 | const char *cipher_name; |
| 618 | char full_name[CRYPTO_MAX_ALG_NAME]; | 613 | char full_name[CRYPTO_MAX_ALG_NAME]; |
| 619 | 614 | ||
| 620 | ctr_name = crypto_attr_alg_name(tb[1]); | 615 | ctr_name = crypto_attr_alg_name(tb[1]); |
| 621 | err = PTR_ERR(ctr_name); | ||
| 622 | if (IS_ERR(ctr_name)) | 616 | if (IS_ERR(ctr_name)) |
| 623 | return ERR_PTR(err); | 617 | return ERR_CAST(ctr_name); |
| 624 | 618 | ||
| 625 | cipher_name = crypto_attr_alg_name(tb[2]); | 619 | cipher_name = crypto_attr_alg_name(tb[2]); |
| 626 | err = PTR_ERR(cipher_name); | ||
| 627 | if (IS_ERR(cipher_name)) | 620 | if (IS_ERR(cipher_name)) |
| 628 | return ERR_PTR(err); | 621 | return ERR_CAST(cipher_name); |
| 629 | 622 | ||
| 630 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm_base(%s,%s)", | 623 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm_base(%s,%s)", |
| 631 | ctr_name, cipher_name) >= CRYPTO_MAX_ALG_NAME) | 624 | ctr_name, cipher_name) >= CRYPTO_MAX_ALG_NAME) |
| @@ -760,17 +753,15 @@ static struct crypto_instance *crypto_rfc4309_alloc(struct rtattr **tb) | |||
| 760 | int err; | 753 | int err; |
| 761 | 754 | ||
| 762 | algt = crypto_get_attr_type(tb); | 755 | algt = crypto_get_attr_type(tb); |
| 763 | err = PTR_ERR(algt); | ||
| 764 | if (IS_ERR(algt)) | 756 | if (IS_ERR(algt)) |
| 765 | return ERR_PTR(err); | 757 | return ERR_CAST(algt); |
| 766 | 758 | ||
| 767 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 759 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 768 | return ERR_PTR(-EINVAL); | 760 | return ERR_PTR(-EINVAL); |
| 769 | 761 | ||
| 770 | ccm_name = crypto_attr_alg_name(tb[1]); | 762 | ccm_name = crypto_attr_alg_name(tb[1]); |
| 771 | err = PTR_ERR(ccm_name); | ||
| 772 | if (IS_ERR(ccm_name)) | 763 | if (IS_ERR(ccm_name)) |
| 773 | return ERR_PTR(err); | 764 | return ERR_CAST(ccm_name); |
| 774 | 765 | ||
| 775 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 766 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 776 | if (!inst) | 767 | if (!inst) |
diff --git a/crypto/chainiv.c b/crypto/chainiv.c index ba200b07449d..834d8dd3d4fc 100644 --- a/crypto/chainiv.c +++ b/crypto/chainiv.c | |||
| @@ -291,9 +291,8 @@ static struct crypto_instance *chainiv_alloc(struct rtattr **tb) | |||
| 291 | int err; | 291 | int err; |
| 292 | 292 | ||
| 293 | algt = crypto_get_attr_type(tb); | 293 | algt = crypto_get_attr_type(tb); |
| 294 | err = PTR_ERR(algt); | ||
| 295 | if (IS_ERR(algt)) | 294 | if (IS_ERR(algt)) |
| 296 | return ERR_PTR(err); | 295 | return ERR_CAST(algt); |
| 297 | 296 | ||
| 298 | err = crypto_get_default_rng(); | 297 | err = crypto_get_default_rng(); |
| 299 | if (err) | 298 | if (err) |
diff --git a/crypto/crc32.c b/crypto/crc32.c new file mode 100644 index 000000000000..9d1c41569898 --- /dev/null +++ b/crypto/crc32.c | |||
| @@ -0,0 +1,158 @@ | |||
| 1 | /* GPL HEADER START | ||
| 2 | * | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License version 2 only, | ||
| 7 | * as published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, but | ||
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * General Public License version 2 for more details (a copy is included | ||
| 13 | * in the LICENSE file that accompanied this code). | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * version 2 along with this program; If not, see http://www.gnu.org/licenses | ||
| 17 | * | ||
| 18 | * Please visit http://www.xyratex.com/contact if you need additional | ||
| 19 | * information or have any questions. | ||
| 20 | * | ||
| 21 | * GPL HEADER END | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* | ||
| 25 | * Copyright 2012 Xyratex Technology Limited | ||
| 26 | */ | ||
| 27 | |||
| 28 | /* | ||
| 29 | * This is crypto api shash wrappers to crc32_le. | ||
| 30 | */ | ||
| 31 | |||
| 32 | #include <linux/crc32.h> | ||
| 33 | #include <crypto/internal/hash.h> | ||
| 34 | #include <linux/init.h> | ||
| 35 | #include <linux/module.h> | ||
| 36 | #include <linux/string.h> | ||
| 37 | #include <linux/kernel.h> | ||
| 38 | |||
| 39 | #define CHKSUM_BLOCK_SIZE 1 | ||
| 40 | #define CHKSUM_DIGEST_SIZE 4 | ||
| 41 | |||
| 42 | static u32 __crc32_le(u32 crc, unsigned char const *p, size_t len) | ||
| 43 | { | ||
| 44 | return crc32_le(crc, p, len); | ||
| 45 | } | ||
| 46 | |||
| 47 | /** No default init with ~0 */ | ||
| 48 | static int crc32_cra_init(struct crypto_tfm *tfm) | ||
| 49 | { | ||
| 50 | u32 *key = crypto_tfm_ctx(tfm); | ||
| 51 | |||
| 52 | *key = 0; | ||
| 53 | |||
| 54 | return 0; | ||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | /* | ||
| 59 | * Setting the seed allows arbitrary accumulators and flexible XOR policy | ||
| 60 | * If your algorithm starts with ~0, then XOR with ~0 before you set | ||
| 61 | * the seed. | ||
| 62 | */ | ||
| 63 | static int crc32_setkey(struct crypto_shash *hash, const u8 *key, | ||
| 64 | unsigned int keylen) | ||
| 65 | { | ||
| 66 | u32 *mctx = crypto_shash_ctx(hash); | ||
| 67 | |||
| 68 | if (keylen != sizeof(u32)) { | ||
| 69 | crypto_shash_set_flags(hash, CRYPTO_TFM_RES_BAD_KEY_LEN); | ||
| 70 | return -EINVAL; | ||
| 71 | } | ||
| 72 | *mctx = le32_to_cpup((__le32 *)key); | ||
| 73 | return 0; | ||
| 74 | } | ||
| 75 | |||
| 76 | static int crc32_init(struct shash_desc *desc) | ||
| 77 | { | ||
| 78 | u32 *mctx = crypto_shash_ctx(desc->tfm); | ||
| 79 | u32 *crcp = shash_desc_ctx(desc); | ||
| 80 | |||
| 81 | *crcp = *mctx; | ||
| 82 | |||
| 83 | return 0; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int crc32_update(struct shash_desc *desc, const u8 *data, | ||
| 87 | unsigned int len) | ||
| 88 | { | ||
| 89 | u32 *crcp = shash_desc_ctx(desc); | ||
| 90 | |||
| 91 | *crcp = __crc32_le(*crcp, data, len); | ||
| 92 | return 0; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* No final XOR 0xFFFFFFFF, like crc32_le */ | ||
| 96 | static int __crc32_finup(u32 *crcp, const u8 *data, unsigned int len, | ||
| 97 | u8 *out) | ||
| 98 | { | ||
| 99 | *(__le32 *)out = cpu_to_le32(__crc32_le(*crcp, data, len)); | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | |||
| 103 | static int crc32_finup(struct shash_desc *desc, const u8 *data, | ||
| 104 | unsigned int len, u8 *out) | ||
| 105 | { | ||
| 106 | return __crc32_finup(shash_desc_ctx(desc), data, len, out); | ||
| 107 | } | ||
| 108 | |||
| 109 | static int crc32_final(struct shash_desc *desc, u8 *out) | ||
| 110 | { | ||
| 111 | u32 *crcp = shash_desc_ctx(desc); | ||
| 112 | |||
| 113 | *(__le32 *)out = cpu_to_le32p(crcp); | ||
| 114 | return 0; | ||
| 115 | } | ||
| 116 | |||
| 117 | static int crc32_digest(struct shash_desc *desc, const u8 *data, | ||
| 118 | unsigned int len, u8 *out) | ||
| 119 | { | ||
| 120 | return __crc32_finup(crypto_shash_ctx(desc->tfm), data, len, | ||
| 121 | out); | ||
| 122 | } | ||
| 123 | static struct shash_alg alg = { | ||
| 124 | .setkey = crc32_setkey, | ||
| 125 | .init = crc32_init, | ||
| 126 | .update = crc32_update, | ||
| 127 | .final = crc32_final, | ||
| 128 | .finup = crc32_finup, | ||
| 129 | .digest = crc32_digest, | ||
| 130 | .descsize = sizeof(u32), | ||
| 131 | .digestsize = CHKSUM_DIGEST_SIZE, | ||
| 132 | .base = { | ||
| 133 | .cra_name = "crc32", | ||
| 134 | .cra_driver_name = "crc32-table", | ||
| 135 | .cra_priority = 100, | ||
| 136 | .cra_blocksize = CHKSUM_BLOCK_SIZE, | ||
| 137 | .cra_ctxsize = sizeof(u32), | ||
| 138 | .cra_module = THIS_MODULE, | ||
| 139 | .cra_init = crc32_cra_init, | ||
| 140 | } | ||
| 141 | }; | ||
| 142 | |||
| 143 | static int __init crc32_mod_init(void) | ||
| 144 | { | ||
| 145 | return crypto_register_shash(&alg); | ||
| 146 | } | ||
| 147 | |||
| 148 | static void __exit crc32_mod_fini(void) | ||
| 149 | { | ||
| 150 | crypto_unregister_shash(&alg); | ||
| 151 | } | ||
| 152 | |||
| 153 | module_init(crc32_mod_init); | ||
| 154 | module_exit(crc32_mod_fini); | ||
| 155 | |||
| 156 | MODULE_AUTHOR("Alexander Boyko <alexander_boyko@xyratex.com>"); | ||
| 157 | MODULE_DESCRIPTION("CRC32 calculations wrapper for lib/crc32"); | ||
| 158 | MODULE_LICENSE("GPL"); | ||
diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c index 35d700a97d79..dfd511fb39ee 100644 --- a/crypto/crypto_user.c +++ b/crypto/crypto_user.c | |||
| @@ -30,6 +30,8 @@ | |||
| 30 | 30 | ||
| 31 | #include "internal.h" | 31 | #include "internal.h" |
| 32 | 32 | ||
| 33 | #define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x)) | ||
| 34 | |||
| 33 | static DEFINE_MUTEX(crypto_cfg_mutex); | 35 | static DEFINE_MUTEX(crypto_cfg_mutex); |
| 34 | 36 | ||
| 35 | /* The crypto netlink socket */ | 37 | /* The crypto netlink socket */ |
| @@ -75,7 +77,7 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 75 | { | 77 | { |
| 76 | struct crypto_report_cipher rcipher; | 78 | struct crypto_report_cipher rcipher; |
| 77 | 79 | ||
| 78 | snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher"); | 80 | strncpy(rcipher.type, "cipher", sizeof(rcipher.type)); |
| 79 | 81 | ||
| 80 | rcipher.blocksize = alg->cra_blocksize; | 82 | rcipher.blocksize = alg->cra_blocksize; |
| 81 | rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; | 83 | rcipher.min_keysize = alg->cra_cipher.cia_min_keysize; |
| @@ -94,8 +96,7 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 94 | { | 96 | { |
| 95 | struct crypto_report_comp rcomp; | 97 | struct crypto_report_comp rcomp; |
| 96 | 98 | ||
| 97 | snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression"); | 99 | strncpy(rcomp.type, "compression", sizeof(rcomp.type)); |
| 98 | |||
| 99 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, | 100 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, |
| 100 | sizeof(struct crypto_report_comp), &rcomp)) | 101 | sizeof(struct crypto_report_comp), &rcomp)) |
| 101 | goto nla_put_failure; | 102 | goto nla_put_failure; |
| @@ -108,12 +109,14 @@ nla_put_failure: | |||
| 108 | static int crypto_report_one(struct crypto_alg *alg, | 109 | static int crypto_report_one(struct crypto_alg *alg, |
| 109 | struct crypto_user_alg *ualg, struct sk_buff *skb) | 110 | struct crypto_user_alg *ualg, struct sk_buff *skb) |
| 110 | { | 111 | { |
| 111 | memcpy(&ualg->cru_name, &alg->cra_name, sizeof(ualg->cru_name)); | 112 | strncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name)); |
| 112 | memcpy(&ualg->cru_driver_name, &alg->cra_driver_name, | 113 | strncpy(ualg->cru_driver_name, alg->cra_driver_name, |
| 113 | sizeof(ualg->cru_driver_name)); | 114 | sizeof(ualg->cru_driver_name)); |
| 114 | memcpy(&ualg->cru_module_name, module_name(alg->cra_module), | 115 | strncpy(ualg->cru_module_name, module_name(alg->cra_module), |
| 115 | CRYPTO_MAX_ALG_NAME); | 116 | sizeof(ualg->cru_module_name)); |
| 116 | 117 | ||
| 118 | ualg->cru_type = 0; | ||
| 119 | ualg->cru_mask = 0; | ||
| 117 | ualg->cru_flags = alg->cra_flags; | 120 | ualg->cru_flags = alg->cra_flags; |
| 118 | ualg->cru_refcnt = atomic_read(&alg->cra_refcnt); | 121 | ualg->cru_refcnt = atomic_read(&alg->cra_refcnt); |
| 119 | 122 | ||
| @@ -122,8 +125,7 @@ static int crypto_report_one(struct crypto_alg *alg, | |||
| 122 | if (alg->cra_flags & CRYPTO_ALG_LARVAL) { | 125 | if (alg->cra_flags & CRYPTO_ALG_LARVAL) { |
| 123 | struct crypto_report_larval rl; | 126 | struct crypto_report_larval rl; |
| 124 | 127 | ||
| 125 | snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval"); | 128 | strncpy(rl.type, "larval", sizeof(rl.type)); |
| 126 | |||
| 127 | if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, | 129 | if (nla_put(skb, CRYPTOCFGA_REPORT_LARVAL, |
| 128 | sizeof(struct crypto_report_larval), &rl)) | 130 | sizeof(struct crypto_report_larval), &rl)) |
| 129 | goto nla_put_failure; | 131 | goto nla_put_failure; |
| @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, | |||
| 196 | struct crypto_dump_info info; | 198 | struct crypto_dump_info info; |
| 197 | int err; | 199 | int err; |
| 198 | 200 | ||
| 199 | if (!p->cru_driver_name) | 201 | if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name)) |
| 202 | return -EINVAL; | ||
| 203 | |||
| 204 | if (!p->cru_driver_name[0]) | ||
| 200 | return -EINVAL; | 205 | return -EINVAL; |
| 201 | 206 | ||
| 202 | alg = crypto_alg_match(p, 1); | 207 | alg = crypto_alg_match(p, 1); |
| @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 260 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; | 265 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; |
| 261 | LIST_HEAD(list); | 266 | LIST_HEAD(list); |
| 262 | 267 | ||
| 268 | if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name)) | ||
| 269 | return -EINVAL; | ||
| 270 | |||
| 263 | if (priority && !strlen(p->cru_driver_name)) | 271 | if (priority && !strlen(p->cru_driver_name)) |
| 264 | return -EINVAL; | 272 | return -EINVAL; |
| 265 | 273 | ||
| @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 287 | struct crypto_alg *alg; | 295 | struct crypto_alg *alg; |
| 288 | struct crypto_user_alg *p = nlmsg_data(nlh); | 296 | struct crypto_user_alg *p = nlmsg_data(nlh); |
| 289 | 297 | ||
| 298 | if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name)) | ||
| 299 | return -EINVAL; | ||
| 300 | |||
| 290 | alg = crypto_alg_match(p, 1); | 301 | alg = crypto_alg_match(p, 1); |
| 291 | if (!alg) | 302 | if (!alg) |
| 292 | return -ENOENT; | 303 | return -ENOENT; |
| @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
| 368 | struct crypto_user_alg *p = nlmsg_data(nlh); | 379 | struct crypto_user_alg *p = nlmsg_data(nlh); |
| 369 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; | 380 | struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL]; |
| 370 | 381 | ||
| 382 | if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name)) | ||
| 383 | return -EINVAL; | ||
| 384 | |||
| 371 | if (strlen(p->cru_driver_name)) | 385 | if (strlen(p->cru_driver_name)) |
| 372 | exact = 1; | 386 | exact = 1; |
| 373 | 387 | ||
diff --git a/crypto/ctr.c b/crypto/ctr.c index 1f2997cbfdd4..f2b94f27bb2c 100644 --- a/crypto/ctr.c +++ b/crypto/ctr.c | |||
| @@ -343,17 +343,15 @@ static struct crypto_instance *crypto_rfc3686_alloc(struct rtattr **tb) | |||
| 343 | int err; | 343 | int err; |
| 344 | 344 | ||
| 345 | algt = crypto_get_attr_type(tb); | 345 | algt = crypto_get_attr_type(tb); |
| 346 | err = PTR_ERR(algt); | ||
| 347 | if (IS_ERR(algt)) | 346 | if (IS_ERR(algt)) |
| 348 | return ERR_PTR(err); | 347 | return ERR_CAST(algt); |
| 349 | 348 | ||
| 350 | if ((algt->type ^ CRYPTO_ALG_TYPE_BLKCIPHER) & algt->mask) | 349 | if ((algt->type ^ CRYPTO_ALG_TYPE_BLKCIPHER) & algt->mask) |
| 351 | return ERR_PTR(-EINVAL); | 350 | return ERR_PTR(-EINVAL); |
| 352 | 351 | ||
| 353 | cipher_name = crypto_attr_alg_name(tb[1]); | 352 | cipher_name = crypto_attr_alg_name(tb[1]); |
| 354 | err = PTR_ERR(cipher_name); | ||
| 355 | if (IS_ERR(cipher_name)) | 353 | if (IS_ERR(cipher_name)) |
| 356 | return ERR_PTR(err); | 354 | return ERR_CAST(cipher_name); |
| 357 | 355 | ||
| 358 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 356 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 359 | if (!inst) | 357 | if (!inst) |
diff --git a/crypto/cts.c b/crypto/cts.c index ccf9c5de3958..042223f8e733 100644 --- a/crypto/cts.c +++ b/crypto/cts.c | |||
| @@ -282,9 +282,8 @@ static struct crypto_instance *crypto_cts_alloc(struct rtattr **tb) | |||
| 282 | 282 | ||
| 283 | alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_BLKCIPHER, | 283 | alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_BLKCIPHER, |
| 284 | CRYPTO_ALG_TYPE_MASK); | 284 | CRYPTO_ALG_TYPE_MASK); |
| 285 | err = PTR_ERR(alg); | ||
| 286 | if (IS_ERR(alg)) | 285 | if (IS_ERR(alg)) |
| 287 | return ERR_PTR(err); | 286 | return ERR_CAST(alg); |
| 288 | 287 | ||
| 289 | inst = ERR_PTR(-EINVAL); | 288 | inst = ERR_PTR(-EINVAL); |
| 290 | if (!is_power_of_2(alg->cra_blocksize)) | 289 | if (!is_power_of_2(alg->cra_blocksize)) |
diff --git a/crypto/gcm.c b/crypto/gcm.c index 1a252639ef91..137ad1ec5438 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c | |||
| @@ -701,9 +701,8 @@ static struct crypto_instance *crypto_gcm_alloc_common(struct rtattr **tb, | |||
| 701 | int err; | 701 | int err; |
| 702 | 702 | ||
| 703 | algt = crypto_get_attr_type(tb); | 703 | algt = crypto_get_attr_type(tb); |
| 704 | err = PTR_ERR(algt); | ||
| 705 | if (IS_ERR(algt)) | 704 | if (IS_ERR(algt)) |
| 706 | return ERR_PTR(err); | 705 | return ERR_CAST(algt); |
| 707 | 706 | ||
| 708 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 707 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 709 | return ERR_PTR(-EINVAL); | 708 | return ERR_PTR(-EINVAL); |
| @@ -711,9 +710,8 @@ static struct crypto_instance *crypto_gcm_alloc_common(struct rtattr **tb, | |||
| 711 | ghash_alg = crypto_find_alg(ghash_name, &crypto_ahash_type, | 710 | ghash_alg = crypto_find_alg(ghash_name, &crypto_ahash_type, |
| 712 | CRYPTO_ALG_TYPE_HASH, | 711 | CRYPTO_ALG_TYPE_HASH, |
| 713 | CRYPTO_ALG_TYPE_AHASH_MASK); | 712 | CRYPTO_ALG_TYPE_AHASH_MASK); |
| 714 | err = PTR_ERR(ghash_alg); | ||
| 715 | if (IS_ERR(ghash_alg)) | 713 | if (IS_ERR(ghash_alg)) |
| 716 | return ERR_PTR(err); | 714 | return ERR_CAST(ghash_alg); |
| 717 | 715 | ||
| 718 | err = -ENOMEM; | 716 | err = -ENOMEM; |
| 719 | inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); | 717 | inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL); |
| @@ -787,15 +785,13 @@ out_put_ghash: | |||
| 787 | 785 | ||
| 788 | static struct crypto_instance *crypto_gcm_alloc(struct rtattr **tb) | 786 | static struct crypto_instance *crypto_gcm_alloc(struct rtattr **tb) |
| 789 | { | 787 | { |
| 790 | int err; | ||
| 791 | const char *cipher_name; | 788 | const char *cipher_name; |
| 792 | char ctr_name[CRYPTO_MAX_ALG_NAME]; | 789 | char ctr_name[CRYPTO_MAX_ALG_NAME]; |
| 793 | char full_name[CRYPTO_MAX_ALG_NAME]; | 790 | char full_name[CRYPTO_MAX_ALG_NAME]; |
| 794 | 791 | ||
| 795 | cipher_name = crypto_attr_alg_name(tb[1]); | 792 | cipher_name = crypto_attr_alg_name(tb[1]); |
| 796 | err = PTR_ERR(cipher_name); | ||
| 797 | if (IS_ERR(cipher_name)) | 793 | if (IS_ERR(cipher_name)) |
| 798 | return ERR_PTR(err); | 794 | return ERR_CAST(cipher_name); |
| 799 | 795 | ||
| 800 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", cipher_name) >= | 796 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", cipher_name) >= |
| 801 | CRYPTO_MAX_ALG_NAME) | 797 | CRYPTO_MAX_ALG_NAME) |
| @@ -826,20 +822,17 @@ static struct crypto_template crypto_gcm_tmpl = { | |||
| 826 | 822 | ||
| 827 | static struct crypto_instance *crypto_gcm_base_alloc(struct rtattr **tb) | 823 | static struct crypto_instance *crypto_gcm_base_alloc(struct rtattr **tb) |
| 828 | { | 824 | { |
| 829 | int err; | ||
| 830 | const char *ctr_name; | 825 | const char *ctr_name; |
| 831 | const char *ghash_name; | 826 | const char *ghash_name; |
| 832 | char full_name[CRYPTO_MAX_ALG_NAME]; | 827 | char full_name[CRYPTO_MAX_ALG_NAME]; |
| 833 | 828 | ||
| 834 | ctr_name = crypto_attr_alg_name(tb[1]); | 829 | ctr_name = crypto_attr_alg_name(tb[1]); |
| 835 | err = PTR_ERR(ctr_name); | ||
| 836 | if (IS_ERR(ctr_name)) | 830 | if (IS_ERR(ctr_name)) |
| 837 | return ERR_PTR(err); | 831 | return ERR_CAST(ctr_name); |
| 838 | 832 | ||
| 839 | ghash_name = crypto_attr_alg_name(tb[2]); | 833 | ghash_name = crypto_attr_alg_name(tb[2]); |
| 840 | err = PTR_ERR(ghash_name); | ||
| 841 | if (IS_ERR(ghash_name)) | 834 | if (IS_ERR(ghash_name)) |
| 842 | return ERR_PTR(err); | 835 | return ERR_CAST(ghash_name); |
| 843 | 836 | ||
| 844 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm_base(%s,%s)", | 837 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm_base(%s,%s)", |
| 845 | ctr_name, ghash_name) >= CRYPTO_MAX_ALG_NAME) | 838 | ctr_name, ghash_name) >= CRYPTO_MAX_ALG_NAME) |
| @@ -971,17 +964,15 @@ static struct crypto_instance *crypto_rfc4106_alloc(struct rtattr **tb) | |||
| 971 | int err; | 964 | int err; |
| 972 | 965 | ||
| 973 | algt = crypto_get_attr_type(tb); | 966 | algt = crypto_get_attr_type(tb); |
| 974 | err = PTR_ERR(algt); | ||
| 975 | if (IS_ERR(algt)) | 967 | if (IS_ERR(algt)) |
| 976 | return ERR_PTR(err); | 968 | return ERR_CAST(algt); |
| 977 | 969 | ||
| 978 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 970 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 979 | return ERR_PTR(-EINVAL); | 971 | return ERR_PTR(-EINVAL); |
| 980 | 972 | ||
| 981 | ccm_name = crypto_attr_alg_name(tb[1]); | 973 | ccm_name = crypto_attr_alg_name(tb[1]); |
| 982 | err = PTR_ERR(ccm_name); | ||
| 983 | if (IS_ERR(ccm_name)) | 974 | if (IS_ERR(ccm_name)) |
| 984 | return ERR_PTR(err); | 975 | return ERR_CAST(ccm_name); |
| 985 | 976 | ||
| 986 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 977 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 987 | if (!inst) | 978 | if (!inst) |
| @@ -1222,17 +1213,15 @@ static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb) | |||
| 1222 | int err; | 1213 | int err; |
| 1223 | 1214 | ||
| 1224 | algt = crypto_get_attr_type(tb); | 1215 | algt = crypto_get_attr_type(tb); |
| 1225 | err = PTR_ERR(algt); | ||
| 1226 | if (IS_ERR(algt)) | 1216 | if (IS_ERR(algt)) |
| 1227 | return ERR_PTR(err); | 1217 | return ERR_CAST(algt); |
| 1228 | 1218 | ||
| 1229 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 1219 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
| 1230 | return ERR_PTR(-EINVAL); | 1220 | return ERR_PTR(-EINVAL); |
| 1231 | 1221 | ||
| 1232 | ccm_name = crypto_attr_alg_name(tb[1]); | 1222 | ccm_name = crypto_attr_alg_name(tb[1]); |
| 1233 | err = PTR_ERR(ccm_name); | ||
| 1234 | if (IS_ERR(ccm_name)) | 1223 | if (IS_ERR(ccm_name)) |
| 1235 | return ERR_PTR(err); | 1224 | return ERR_CAST(ccm_name); |
| 1236 | 1225 | ||
| 1237 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 1226 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
| 1238 | if (!inst) | 1227 | if (!inst) |
diff --git a/crypto/pcompress.c b/crypto/pcompress.c index 04e083ff5373..7140fe70c7af 100644 --- a/crypto/pcompress.c +++ b/crypto/pcompress.c | |||
| @@ -53,8 +53,7 @@ static int crypto_pcomp_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 53 | { | 53 | { |
| 54 | struct crypto_report_comp rpcomp; | 54 | struct crypto_report_comp rpcomp; |
| 55 | 55 | ||
| 56 | snprintf(rpcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "pcomp"); | 56 | strncpy(rpcomp.type, "pcomp", sizeof(rpcomp.type)); |
| 57 | |||
| 58 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, | 57 | if (nla_put(skb, CRYPTOCFGA_REPORT_COMPRESS, |
| 59 | sizeof(struct crypto_report_comp), &rpcomp)) | 58 | sizeof(struct crypto_report_comp), &rpcomp)) |
| 60 | goto nla_put_failure; | 59 | goto nla_put_failure; |
diff --git a/crypto/rng.c b/crypto/rng.c index f3b7894dec00..e0a25c2456de 100644 --- a/crypto/rng.c +++ b/crypto/rng.c | |||
| @@ -65,7 +65,7 @@ static int crypto_rng_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 65 | { | 65 | { |
| 66 | struct crypto_report_rng rrng; | 66 | struct crypto_report_rng rrng; |
| 67 | 67 | ||
| 68 | snprintf(rrng.type, CRYPTO_MAX_ALG_NAME, "%s", "rng"); | 68 | strncpy(rrng.type, "rng", sizeof(rrng.type)); |
| 69 | 69 | ||
| 70 | rrng.seedsize = alg->cra_rng.seedsize; | 70 | rrng.seedsize = alg->cra_rng.seedsize; |
| 71 | 71 | ||
diff --git a/crypto/seqiv.c b/crypto/seqiv.c index 4c4491229417..f2cba4ed6f25 100644 --- a/crypto/seqiv.c +++ b/crypto/seqiv.c | |||
| @@ -305,9 +305,8 @@ static struct crypto_instance *seqiv_alloc(struct rtattr **tb) | |||
| 305 | int err; | 305 | int err; |
| 306 | 306 | ||
| 307 | algt = crypto_get_attr_type(tb); | 307 | algt = crypto_get_attr_type(tb); |
| 308 | err = PTR_ERR(algt); | ||
| 309 | if (IS_ERR(algt)) | 308 | if (IS_ERR(algt)) |
| 310 | return ERR_PTR(err); | 309 | return ERR_CAST(algt); |
| 311 | 310 | ||
| 312 | err = crypto_get_default_rng(); | 311 | err = crypto_get_default_rng(); |
| 313 | if (err) | 312 | if (err) |
diff --git a/crypto/shash.c b/crypto/shash.c index f426330f1017..929058a68561 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
| @@ -530,7 +530,8 @@ static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) | |||
| 530 | struct crypto_report_hash rhash; | 530 | struct crypto_report_hash rhash; |
| 531 | struct shash_alg *salg = __crypto_shash_alg(alg); | 531 | struct shash_alg *salg = __crypto_shash_alg(alg); |
| 532 | 532 | ||
| 533 | snprintf(rhash.type, CRYPTO_MAX_ALG_NAME, "%s", "shash"); | 533 | strncpy(rhash.type, "shash", sizeof(rhash.type)); |
| 534 | |||
| 534 | rhash.blocksize = alg->cra_blocksize; | 535 | rhash.blocksize = alg->cra_blocksize; |
| 535 | rhash.digestsize = salg->digestsize; | 536 | rhash.digestsize = salg->digestsize; |
| 536 | 537 | ||
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index edf4a0818773..efd8b20e13dc 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
| @@ -2269,6 +2269,21 @@ static const struct alg_test_desc alg_test_descs[] = { | |||
| 2269 | } | 2269 | } |
| 2270 | } | 2270 | } |
| 2271 | }, { | 2271 | }, { |
| 2272 | .alg = "ecb(fcrypt)", | ||
| 2273 | .test = alg_test_skcipher, | ||
| 2274 | .suite = { | ||
| 2275 | .cipher = { | ||
| 2276 | .enc = { | ||
| 2277 | .vecs = fcrypt_pcbc_enc_tv_template, | ||
| 2278 | .count = 1 | ||
| 2279 | }, | ||
| 2280 | .dec = { | ||
| 2281 | .vecs = fcrypt_pcbc_dec_tv_template, | ||
| 2282 | .count = 1 | ||
| 2283 | } | ||
| 2284 | } | ||
| 2285 | } | ||
| 2286 | }, { | ||
| 2272 | .alg = "ecb(khazad)", | 2287 | .alg = "ecb(khazad)", |
| 2273 | .test = alg_test_skcipher, | 2288 | .test = alg_test_skcipher, |
| 2274 | .suite = { | 2289 | .suite = { |
