diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-02-01 04:36:54 -0900 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-02-05 22:33:20 -0900 |
| commit | 896545098777564212b9e91af4c973f094649aa7 (patch) | |
| tree | 980e96d4362f304e5ec39ddc1a343b2fed5c5234 /crypto/shash.c | |
| parent | 6dae10001e84253992142c7343fdae16a13f3d73 (diff) | |
| download | linux-stable-896545098777564212b9e91af4c973f094649aa7.tar.gz linux-stable-896545098777564212b9e91af4c973f094649aa7.tar.bz2 linux-stable-896545098777564212b9e91af4c973f094649aa7.tar.xz linux-stable-896545098777564212b9e91af4c973f094649aa7.zip | |
crypto: hash - Remove crypto_hash interface
This patch removes all traces of the crypto_hash interface, now
that everyone has switched over to shash or ahash.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
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 88a27de79848..472bc141f50d 100644 --- a/crypto/shash.c +++ b/crypto/shash.c | |||
| @@ -369,151 +369,6 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm) | |||
| 369 | return 0; | 369 | return 0; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | static int shash_compat_setkey(struct crypto_hash *tfm, const u8 *key, | ||
| 373 | unsigned int keylen) | ||
| 374 | { | ||
| 375 | struct shash_desc **descp = crypto_hash_ctx(tfm); | ||
| 376 | struct shash_desc *desc = *descp; | ||
| 377 | |||
| 378 | return crypto_shash_setkey(desc->tfm, key, keylen); | ||
| 379 | } | ||
| 380 | |||
| 381 | static int shash_compat_init(struct hash_desc *hdesc) | ||
| 382 | { | ||
| 383 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 384 | struct shash_desc *desc = *descp; | ||
| 385 | |||
| 386 | desc->flags = hdesc->flags; | ||
| 387 | |||
| 388 | return crypto_shash_init(desc); | ||
| 389 | } | ||
| 390 | |||
| 391 | static int shash_compat_update(struct hash_desc *hdesc, struct scatterlist *sg, | ||
| 392 | unsigned int len) | ||
| 393 | { | ||
| 394 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 395 | struct shash_desc *desc = *descp; | ||
| 396 | struct crypto_hash_walk walk; | ||
| 397 | int nbytes; | ||
| 398 | |||
| 399 | for (nbytes = crypto_hash_walk_first_compat(hdesc, &walk, sg, len); | ||
| 400 | nbytes > 0; nbytes = crypto_hash_walk_done(&walk, nbytes)) | ||
| 401 | nbytes = crypto_shash_update(desc, walk.data, nbytes); | ||
| 402 | |||
| 403 | return nbytes; | ||
| 404 | } | ||
| 405 | |||
| 406 | static int shash_compat_final(struct hash_desc *hdesc, u8 *out) | ||
| 407 | { | ||
| 408 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 409 | |||
| 410 | return crypto_shash_final(*descp, out); | ||
| 411 | } | ||
| 412 | |||
| 413 | static int shash_compat_digest(struct hash_desc *hdesc, struct scatterlist *sg, | ||
| 414 | unsigned int nbytes, u8 *out) | ||
| 415 | { | ||
| 416 | unsigned int offset = sg->offset; | ||
| 417 | int err; | ||
| 418 | |||
| 419 | if (nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset)) { | ||
| 420 | struct shash_desc **descp = crypto_hash_ctx(hdesc->tfm); | ||
| 421 | struct shash_desc *desc = *descp; | ||
| 422 | void *data; | ||
| 423 | |||
| 424 | desc->flags = hdesc->flags; | ||
| 425 | |||
| 426 | data = kmap_atomic(sg_page(sg)); | ||
| 427 | err = crypto_shash_digest(desc, data + offset, nbytes, out); | ||
| 428 | kunmap_atomic(data); | ||
| 429 | crypto_yield(desc->flags); | ||
| 430 | goto out; | ||
| 431 | } | ||
| 432 | |||
| 433 | err = shash_compat_init(hdesc); | ||
| 434 | if (err) | ||
| 435 | goto out; | ||
| 436 | |||
| 437 | err = shash_compat_update(hdesc, sg, nbytes); | ||
| 438 | if (err) | ||
| 439 | goto out; | ||
| 440 | |||
| 441 | err = shash_compat_final(hdesc, out); | ||
| 442 | |||
| 443 | out: | ||
| 444 | return err; | ||
| 445 | } | ||
| 446 | |||
| 447 | static void crypto_exit_shash_ops_compat(struct crypto_tfm *tfm) | ||
| 448 | { | ||
| 449 | struct shash_desc **descp = crypto_tfm_ctx(tfm); | ||
| 450 | struct shash_desc *desc = *descp; | ||
| 451 | |||
| 452 | crypto_free_shash(desc->tfm); | ||
| 453 | kzfree(desc); | ||
| 454 | } | ||
| 455 | |||
| 456 | static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm) | ||
| 457 | { | ||
| 458 | struct hash_tfm *crt = &tfm->crt_hash; | ||
| 459 | struct crypto_alg *calg = tfm->__crt_alg; | ||
| 460 | struct shash_alg *alg = __crypto_shash_alg(calg); | ||
| 461 | struct shash_desc **descp = crypto_tfm_ctx(tfm); | ||
| 462 | struct crypto_shash *shash; | ||
| 463 | struct shash_desc *desc; | ||
| 464 | |||
| 465 | if (!crypto_mod_get(calg)) | ||
| 466 | return -EAGAIN; | ||
| 467 | |||
| 468 | shash = crypto_create_tfm(calg, &crypto_shash_type); | ||
| 469 | if (IS_ERR(shash)) { | ||
| 470 | crypto_mod_put(calg); | ||
| 471 | return PTR_ERR(shash); | ||
| 472 | } | ||
| 473 | |||
| 474 | desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(shash), | ||
| 475 | GFP_KERNEL); | ||
| 476 | if (!desc) { | ||
| 477 | crypto_free_shash(shash); | ||
| 478 | return -ENOMEM; | ||
| 479 | } | ||
| 480 | |||
| 481 | *descp = desc; | ||
| 482 | desc->tfm = shash; | ||
| 483 | tfm->exit = crypto_exit_shash_ops_compat; | ||
| 484 | |||
| 485 | crt->init = shash_compat_init; | ||
| 486 | crt->update = shash_compat_update; | ||
| 487 | crt->final = shash_compat_final; | ||
| 488 | crt->digest = shash_compat_digest; | ||
| 489 | crt->setkey = shash_compat_setkey; | ||
| 490 | |||
| 491 | crt->digestsize = alg->digestsize; | ||
| 492 | |||
| 493 | return 0; | ||
| 494 | } | ||
| 495 | |||
| 496 | static int crypto_init_shash_ops(struct crypto_tfm *tfm, u32 type, u32 mask) | ||
| 497 | { | ||
| 498 | switch (mask & CRYPTO_ALG_TYPE_MASK) { | ||
| 499 | case CRYPTO_ALG_TYPE_HASH_MASK: | ||
| 500 | return crypto_init_shash_ops_compat(tfm); | ||
| 501 | } | ||
| 502 | |||
| 503 | return -EINVAL; | ||
| 504 | } | ||
| 505 | |||
| 506 | static unsigned int crypto_shash_ctxsize(struct crypto_alg *alg, u32 type, | ||
| 507 | u32 mask) | ||
| 508 | { | ||
| 509 | switch (mask & CRYPTO_ALG_TYPE_MASK) { | ||
| 510 | case CRYPTO_ALG_TYPE_HASH_MASK: | ||
| 511 | return sizeof(struct shash_desc *); | ||
| 512 | } | ||
| 513 | |||
| 514 | return 0; | ||
| 515 | } | ||
| 516 | |||
| 517 | static int crypto_shash_init_tfm(struct crypto_tfm *tfm) | 372 | static int crypto_shash_init_tfm(struct crypto_tfm *tfm) |
| 518 | { | 373 | { |
| 519 | struct crypto_shash *hash = __crypto_shash_cast(tfm); | 374 | struct crypto_shash *hash = __crypto_shash_cast(tfm); |
| @@ -560,9 +415,7 @@ static void crypto_shash_show(struct seq_file *m, struct crypto_alg *alg) | |||
| 560 | } | 415 | } |
| 561 | 416 | ||
| 562 | static const struct crypto_type crypto_shash_type = { | 417 | static const struct crypto_type crypto_shash_type = { |
| 563 | .ctxsize = crypto_shash_ctxsize, | ||
| 564 | .extsize = crypto_alg_extsize, | 418 | .extsize = crypto_alg_extsize, |
| 565 | .init = crypto_init_shash_ops, | ||
| 566 | .init_tfm = crypto_shash_init_tfm, | 419 | .init_tfm = crypto_shash_init_tfm, |
| 567 | #ifdef CONFIG_PROC_FS | 420 | #ifdef CONFIG_PROC_FS |
| 568 | .show = crypto_shash_show, | 421 | .show = crypto_shash_show, |
