diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 10:22:54 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-17 10:22:54 -0800 |
| commit | 70477371dc350746d10431d74f0f213a8d59924c (patch) | |
| tree | 6271978b6e4ee4b1e6f22775ad7fc0930c09d3ee /crypto/shash.c | |
| parent | 09fd671ccb2475436bd5f597f751ca4a7d177aea (diff) | |
| parent | 34074205bb9f04b416efb3cbedcd90f418c86200 (diff) | |
| download | linux-stable-70477371dc350746d10431d74f0f213a8d59924c.tar.gz linux-stable-70477371dc350746d10431d74f0f213a8d59924c.tar.bz2 linux-stable-70477371dc350746d10431d74f0f213a8d59924c.tar.xz linux-stable-70477371dc350746d10431d74f0f213a8d59924c.zip | |
Merge branch 'linus' of 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 4.6:
API:
- Convert remaining crypto_hash users to shash or ahash, also convert
blkcipher/ablkcipher users to skcipher.
- Remove crypto_hash interface.
- Remove crypto_pcomp interface.
- Add crypto engine for async cipher drivers.
- Add akcipher documentation.
- Add skcipher documentation.
Algorithms:
- Rename crypto/crc32 to avoid name clash with lib/crc32.
- Fix bug in keywrap where we zero the wrong pointer.
Drivers:
- Support T5/M5, T7/M7 SPARC CPUs in n2 hwrng driver.
- Add PIC32 hwrng driver.
- Support BCM6368 in bcm63xx hwrng driver.
- Pack structs for 32-bit compat users in qat.
- Use crypto engine in omap-aes.
- Add support for sama5d2x SoCs in atmel-sha.
- Make atmel-sha available again.
- Make sahara hashing available again.
- Make ccp hashing available again.
- Make sha1-mb available again.
- Add support for multiple devices in ccp.
- Improve DMA performance in caam.
- Add hashing support to rockchip"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (116 commits)
crypto: qat - remove redundant arbiter configuration
crypto: ux500 - fix checks of error code returned by devm_ioremap_resource()
crypto: atmel - fix checks of error code returned by devm_ioremap_resource()
crypto: qat - Change the definition of icp_qat_uof_regtype
hwrng: exynos - use __maybe_unused to hide pm functions
crypto: ccp - Add abstraction for device-specific calls
crypto: ccp - CCP versioning support
crypto: ccp - Support for multiple CCPs
crypto: ccp - Remove check for x86 family and model
crypto: ccp - memset request context to zero during import
lib/mpi: use "static inline" instead of "extern inline"
lib/mpi: avoid assembler warning
hwrng: bcm63xx - fix non device tree compatibility
crypto: testmgr - allow rfc3686 aes-ctr variants in fips mode.
crypto: qat - The AE id should be less than the maximal AE number
lib/mpi: Endianness fix
crypto: rockchip - add hash support for crypto engine in rk3288
crypto: xts - fix compile errors
crypto: doc - add skcipher API documentation
crypto: doc - update AEAD AD handling
...
Diffstat (limited to 'crypto/shash.c')
| -rw-r--r-- | crypto/shash.c | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/crypto/shash.c b/crypto/shash.c index 359754591653..a051541a4a17 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
| @@ -368,151 +368,6 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm) | |||
| 368 | return 0; | 368 | return 0; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | static int shash_compat_setkey(struct crypto_hash *tfm, const u8 *key, | ||
| 372 | unsigned int keylen) | ||
| 373 | { | ||
| 374 | struct shash_desc **descp = crypto_hash_ctx(tfm); | ||
| 375 | struct shash_desc *desc = *descp; | ||
| 376 | |||
| 377 | return crypto_shash_setkey(desc->tfm, key, keylen); | ||
| 378 | } | ||
| 379 | |||
| 380 | static int shash_compat_init(struct hash_desc *hdesc) | ||
| 381 | { | ||
| 382 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 383 | struct shash_desc *desc = *descp; | ||
| 384 | |||
| 385 | desc->flags = hdesc->flags; | ||
| 386 | |||
| 387 | return crypto_shash_init(desc); | ||
| 388 | } | ||
| 389 | |||
| 390 | static int shash_compat_update(struct hash_desc *hdesc, struct scatterlist *sg, | ||
| 391 | unsigned int len) | ||
| 392 | { | ||
| 393 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 394 | struct shash_desc *desc = *descp; | ||
| 395 | struct crypto_hash_walk walk; | ||
| 396 | int nbytes; | ||
| 397 | |||
| 398 | for (nbytes = crypto_hash_walk_first_compat(hdesc, &walk, sg, len); | ||
| 399 | nbytes > 0; nbytes = crypto_hash_walk_done(&walk, nbytes)) | ||
| 400 | nbytes = crypto_shash_update(desc, walk.data, nbytes); | ||
| 401 | |||
| 402 | return nbytes; | ||
| 403 | } | ||
| 404 | |||
| 405 | static int shash_compat_final(struct hash_desc *hdesc, u8 *out) | ||
| 406 | { | ||
| 407 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 408 | |||
| 409 | return crypto_shash_final(*descp, out); | ||
| 410 | } | ||
| 411 | |||
| 412 | static int shash_compat_digest(struct hash_desc *hdesc, struct scatterlist *sg, | ||
| 413 | unsigned int nbytes, u8 *out) | ||
| 414 | { | ||
| 415 | unsigned int offset = sg->offset; | ||
| 416 | int err; | ||
| 417 | |||
| 418 | if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { | ||
| 419 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 420 | struct shash_desc *desc = *descp; | ||
| 421 | void *data; | ||
| 422 | |||
| 423 | desc->flags = hdesc->flags; | ||
| 424 | |||
| 425 | data = kmap_atomic(sg_page(sg)); | ||
| 426 | err = crypto_shash_digest(desc, data + offset, nbytes, out); | ||
| 427 | kunmap_atomic(data); | ||
| 428 | crypto_yield(desc->flags); | ||
| 429 | goto out; | ||
| 430 | } | ||
| 431 | |||
| 432 | err = shash_compat_init(hdesc); | ||
| 433 | if (err) | ||
| 434 | goto out; | ||
| 435 | |||
| 436 | err = shash_compat_update(hdesc, sg, nbytes); | ||
| 437 | if (err) | ||
| 438 | goto out; | ||
| 439 | |||
| 440 | err = shash_compat_final(hdesc, out); | ||
| 441 | |||
| 442 | out: | ||
| 443 | return err; | ||
| 444 | } | ||
| 445 | |||
| 446 | static void crypto_exit_shash_ops_compat(struct crypto_tfm *tfm) | ||
| 447 | { | ||
| 448 | struct shash_desc **descp = crypto_tfm_ctx(tfm); | ||
| 449 | struct shash_desc *desc = *descp; | ||
| 450 | |||
| 451 | crypto_free_shash(desc->tfm); | ||
| 452 | kzfree(desc); | ||
| 453 | } | ||
| 454 | |||
| 455 | static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm) | ||
| 456 | { | ||
| 457 | struct hash_tfm *crt = &tfm->crt_hash; | ||
| 458 | struct crypto_alg *calg = tfm->__crt_alg; | ||
| 459 | struct shash_alg *alg = __crypto_shash_alg(calg); | ||
| 460 | struct shash_desc **descp = crypto_tfm_ctx(tfm); | ||
| 461 | struct crypto_shash *shash; | ||
| 462 | struct shash_desc *desc; | ||
| 463 | |||
| 464 | if (!crypto_mod_get(calg)) | ||
| 465 | return -EAGAIN; | ||
| 466 | |||
| 467 | shash = crypto_create_tfm(calg, &crypto_shash_type); | ||
| 468 | if (IS_ERR(shash)) { | ||
| 469 | crypto_mod_put(calg); | ||
| 470 | return PTR_ERR(shash); | ||
| 471 | } | ||
| 472 | |||
| 473 | desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(shash), | ||
| 474 | GFP_KERNEL); | ||
| 475 | if (!desc) { | ||
| 476 | crypto_free_shash(shash); | ||
| 477 | return -ENOMEM; | ||
| 478 | } | ||
| 479 | |||
| 480 | *descp = desc; | ||
| 481 | desc->tfm = shash; | ||
| 482 | tfm->exit = crypto_exit_shash_ops_compat; | ||
| 483 | |||
| 484 | crt->init = shash_compat_init; | ||
| 485 | crt->update = shash_compat_update; | ||
| 486 | crt->final = shash_compat_final; | ||
| 487 | crt->digest = shash_compat_digest; | ||
| 488 | crt->setkey = shash_compat_setkey; | ||
| 489 | |||
| 490 | crt->digestsize = alg->digestsize; | ||
| 491 | |||
| 492 | return 0; | ||
| 493 | } | ||
| 494 | |||
| 495 | static int crypto_init_shash_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | ||
| 496 | { | ||
| 497 | switch (mask & CRYPTO_ALG_TYPE_MASK) { | ||
| 498 | case CRYPTO_ALG_TYPE_HASH_MASK: | ||
| 499 | return crypto_init_shash_ops_compat(tfm); | ||
| 500 | } | ||
| 501 | |||
| 502 | return -EINVAL; | ||
| 503 | } | ||
| 504 | |||
| 505 | static unsigned int crypto_shash_ctxsize(struct crypto_alg *alg, u32 type, | ||
| 506 | u32 mask) | ||
| 507 | { | ||
| 508 | switch (mask & CRYPTO_ALG_TYPE_MASK) { | ||
| 509 | case CRYPTO_ALG_TYPE_HASH_MASK: | ||
| 510 | return sizeof(struct shash_desc *); | ||
| 511 | } | ||
| 512 | |||
| 513 | return 0; | ||
| 514 | } | ||
| 515 | |||
| 516 | static int crypto_shash_init_tfm(struct crypto_tfm *tfm) | 371 | static int crypto_shash_init_tfm(struct crypto_tfm *tfm) |
| 517 | { | 372 | { |
| 518 | struct crypto_shash *hash = __crypto_shash_cast(tfm); | 373 | struct crypto_shash *hash = __crypto_shash_cast(tfm); |
| @@ -559,9 +414,7 @@ static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | |||
| 559 | } | 414 | } |
| 560 | 415 | ||
| 561 | static const struct crypto_type crypto_shash_type = { | 416 | static const struct crypto_type crypto_shash_type = { |
| 562 | .ctxsize = crypto_shash_ctxsize, | ||
| 563 | .extsize = crypto_alg_extsize, | 417 | .extsize = crypto_alg_extsize, |
| 564 | .init = crypto_init_shash_ops, | ||
| 565 | .init_tfm = crypto_shash_init_tfm, | 418 | .init_tfm = crypto_shash_init_tfm, |
| 566 | #ifdef CONFIG_PROC_FS | 419 | #ifdef CONFIG_PROC_FS |
| 567 | .show = crypto_shash_show, | 420 | .show = crypto_shash_show, |
