Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: hash - add support for new way of freeing instances

Add support to shash and ahash for the new way of freeing instances
(already used for skcipher, aead, and akcipher) where a ->free() method
is installed to the instance struct itself. These methods are more
strongly-typed than crypto_template::free(), which they replace.

This will allow removing support for the old way of freeing instances.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Eric Biggers and committed by
Herbert Xu
48fb3e57 aed11cf5

+28
+13
crypto/ahash.c
··· 511 511 return crypto_alg_extsize(alg); 512 512 } 513 513 514 + static void crypto_ahash_free_instance(struct crypto_instance *inst) 515 + { 516 + struct ahash_instance *ahash = ahash_instance(inst); 517 + 518 + if (!ahash->free) { 519 + inst->tmpl->free(inst); 520 + return; 521 + } 522 + 523 + ahash->free(ahash); 524 + } 525 + 514 526 #ifdef CONFIG_NET 515 527 static int crypto_ahash_report(struct sk_buff *skb, struct crypto_alg *alg) 516 528 { ··· 559 547 static const struct crypto_type crypto_ahash_type = { 560 548 .extsize = crypto_ahash_extsize, 561 549 .init_tfm = crypto_ahash_init_tfm, 550 + .free = crypto_ahash_free_instance, 562 551 #ifdef CONFIG_PROC_FS 563 552 .show = crypto_ahash_show, 564 553 #endif
+13
crypto/shash.c
··· 423 423 return 0; 424 424 } 425 425 426 + static void crypto_shash_free_instance(struct crypto_instance *inst) 427 + { 428 + struct shash_instance *shash = shash_instance(inst); 429 + 430 + if (!shash->free) { 431 + inst->tmpl->free(inst); 432 + return; 433 + } 434 + 435 + shash->free(shash); 436 + } 437 + 426 438 #ifdef CONFIG_NET 427 439 static int crypto_shash_report(struct sk_buff *skb, struct crypto_alg *alg) 428 440 { ··· 471 459 static const struct crypto_type crypto_shash_type = { 472 460 .extsize = crypto_alg_extsize, 473 461 .init_tfm = crypto_shash_init_tfm, 462 + .free = crypto_shash_free_instance, 474 463 #ifdef CONFIG_PROC_FS 475 464 .show = crypto_shash_show, 476 465 #endif
+2
include/crypto/internal/hash.h
··· 30 30 }; 31 31 32 32 struct ahash_instance { 33 + void (*free)(struct ahash_instance *inst); 33 34 union { 34 35 struct { 35 36 char head[offsetof(struct ahash_alg, halg.base)]; ··· 41 40 }; 42 41 43 42 struct shash_instance { 43 + void (*free)(struct shash_instance *inst); 44 44 union { 45 45 struct { 46 46 char head[offsetof(struct shash_alg, base)];