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: algapi - remove obsoleted instance creation helpers

Remove lots of helper functions that were previously used for
instantiating crypto templates, but are now unused:

- crypto_get_attr_alg() and similar functions looked up an inner
algorithm directly from a template parameter. These were replaced
with getting the algorithm's name, then calling crypto_grab_*().

- crypto_init_spawn2() and similar functions initialized a spawn, given
an algorithm. Similarly, these were replaced with crypto_grab_*().

- crypto_alloc_instance() and similar functions allocated an instance
with a single spawn, given the inner algorithm. These aren't useful
anymore since crypto_grab_*() need the instance allocated first.

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
629f1afc d5ed3b65

-154
-25
crypto/ahash.c
··· 655 655 } 656 656 EXPORT_SYMBOL_GPL(ahash_register_instance); 657 657 658 - void ahash_free_instance(struct crypto_instance *inst) 659 - { 660 - crypto_drop_spawn(crypto_instance_ctx(inst)); 661 - kfree(ahash_instance(inst)); 662 - } 663 - EXPORT_SYMBOL_GPL(ahash_free_instance); 664 - 665 - int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn, 666 - struct hash_alg_common *alg, 667 - struct crypto_instance *inst) 668 - { 669 - return crypto_init_spawn2(&spawn->base, &alg->base, inst, 670 - &crypto_ahash_type); 671 - } 672 - EXPORT_SYMBOL_GPL(crypto_init_ahash_spawn); 673 - 674 - struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask) 675 - { 676 - struct crypto_alg *alg; 677 - 678 - alg = crypto_attr_alg2(rta, &crypto_ahash_type, type, mask); 679 - return IS_ERR(alg) ? ERR_CAST(alg) : __crypto_hash_alg_common(alg); 680 - } 681 - EXPORT_SYMBOL_GPL(ahash_attr_alg); 682 - 683 658 bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg) 684 659 { 685 660 struct crypto_alg *alg = &halg->base;
-57
crypto/algapi.c
··· 697 697 } 698 698 EXPORT_SYMBOL_GPL(crypto_init_spawn); 699 699 700 - int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg, 701 - struct crypto_instance *inst, 702 - const struct crypto_type *frontend) 703 - { 704 - int err = -EINVAL; 705 - 706 - if ((alg->cra_flags ^ frontend->type) & frontend->maskset) 707 - goto out; 708 - 709 - spawn->frontend = frontend; 710 - err = crypto_init_spawn(spawn, alg, inst, frontend->maskset); 711 - 712 - out: 713 - return err; 714 - } 715 - EXPORT_SYMBOL_GPL(crypto_init_spawn2); 716 - 717 700 int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst, 718 701 const char *name, u32 type, u32 mask) 719 702 { ··· 859 876 } 860 877 EXPORT_SYMBOL_GPL(crypto_attr_alg_name); 861 878 862 - struct crypto_alg *crypto_attr_alg2(struct rtattr *rta, 863 - const struct crypto_type *frontend, 864 - u32 type, u32 mask) 865 - { 866 - const char *name; 867 - 868 - name = crypto_attr_alg_name(rta); 869 - if (IS_ERR(name)) 870 - return ERR_CAST(name); 871 - 872 - return crypto_find_alg(name, frontend, type, mask); 873 - } 874 - EXPORT_SYMBOL_GPL(crypto_attr_alg2); 875 - 876 879 int crypto_attr_u32(struct rtattr *rta, u32 *num) 877 880 { 878 881 struct crypto_attr_u32 *nu32; ··· 891 922 return 0; 892 923 } 893 924 EXPORT_SYMBOL_GPL(crypto_inst_setname); 894 - 895 - void *crypto_alloc_instance(const char *name, struct crypto_alg *alg, 896 - unsigned int head) 897 - { 898 - struct crypto_instance *inst; 899 - char *p; 900 - int err; 901 - 902 - p = kzalloc(head + sizeof(*inst) + sizeof(struct crypto_spawn), 903 - GFP_KERNEL); 904 - if (!p) 905 - return ERR_PTR(-ENOMEM); 906 - 907 - inst = (void *)(p + head); 908 - 909 - err = crypto_inst_setname(inst, name, alg); 910 - if (err) 911 - goto err_free_inst; 912 - 913 - return p; 914 - 915 - err_free_inst: 916 - kfree(p); 917 - return ERR_PTR(err); 918 - } 919 - EXPORT_SYMBOL_GPL(crypto_alloc_instance); 920 925 921 926 void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen) 922 927 {
-19
crypto/shash.c
··· 584 584 } 585 585 EXPORT_SYMBOL_GPL(shash_free_instance); 586 586 587 - int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn, 588 - struct shash_alg *alg, 589 - struct crypto_instance *inst) 590 - { 591 - return crypto_init_spawn2(&spawn->base, &alg->base, inst, 592 - &crypto_shash_type); 593 - } 594 - EXPORT_SYMBOL_GPL(crypto_init_shash_spawn); 595 - 596 - struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask) 597 - { 598 - struct crypto_alg *alg; 599 - 600 - alg = crypto_attr_alg2(rta, &crypto_shash_type, type, mask); 601 - return IS_ERR(alg) ? ERR_CAST(alg) : 602 - container_of(alg, struct shash_alg, base); 603 - } 604 - EXPORT_SYMBOL_GPL(shash_attr_alg); 605 - 606 587 MODULE_LICENSE("GPL"); 607 588 MODULE_DESCRIPTION("Synchronous cryptographic hash type");
-22
include/crypto/algapi.h
··· 113 113 114 114 int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, 115 115 struct crypto_instance *inst, u32 mask); 116 - int crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg, 117 - struct crypto_instance *inst, 118 - const struct crypto_type *frontend); 119 116 int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst, 120 117 const char *name, u32 type, u32 mask); 121 - 122 118 void crypto_drop_spawn(struct crypto_spawn *spawn); 123 119 struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, 124 120 u32 mask); ··· 123 127 struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); 124 128 int crypto_check_attr_type(struct rtattr **tb, u32 type); 125 129 const char *crypto_attr_alg_name(struct rtattr *rta); 126 - struct crypto_alg *crypto_attr_alg2(struct rtattr *rta, 127 - const struct crypto_type *frontend, 128 - u32 type, u32 mask); 129 - 130 - static inline struct crypto_alg *crypto_attr_alg(struct rtattr *rta, 131 - u32 type, u32 mask) 132 - { 133 - return crypto_attr_alg2(rta, NULL, type, mask); 134 - } 135 - 136 130 int crypto_attr_u32(struct rtattr *rta, u32 *num); 137 131 int crypto_inst_setname(struct crypto_instance *inst, const char *name, 138 132 struct crypto_alg *alg); 139 - void *crypto_alloc_instance(const char *name, struct crypto_alg *alg, 140 - unsigned int head); 141 133 142 134 void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen); 143 135 int crypto_enqueue_request(struct crypto_queue *queue, ··· 236 252 { 237 253 return queue->backlog == &queue->list ? NULL : 238 254 container_of(queue->backlog, struct crypto_async_request, list); 239 - } 240 - 241 - static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb, 242 - u32 type, u32 mask) 243 - { 244 - return crypto_attr_alg(tb[1], type, mask); 245 255 } 246 256 247 257 static inline int crypto_requires_off(u32 type, u32 mask, u32 off)
-31
include/crypto/internal/hash.h
··· 87 87 void crypto_unregister_ahashes(struct ahash_alg *algs, int count); 88 88 int ahash_register_instance(struct crypto_template *tmpl, 89 89 struct ahash_instance *inst); 90 - void ahash_free_instance(struct crypto_instance *inst); 91 90 92 91 int shash_no_setkey(struct crypto_shash *tfm, const u8 *key, 93 92 unsigned int keylen); ··· 104 105 105 106 bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg); 106 107 107 - int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn, 108 - struct hash_alg_common *alg, 109 - struct crypto_instance *inst); 110 - 111 108 int crypto_grab_ahash(struct crypto_ahash_spawn *spawn, 112 109 struct crypto_instance *inst, 113 110 const char *name, u32 type, u32 mask); ··· 119 124 return __crypto_hash_alg_common(spawn->base.alg); 120 125 } 121 126 122 - struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask); 123 - 124 127 int crypto_register_shash(struct shash_alg *alg); 125 128 void crypto_unregister_shash(struct shash_alg *alg); 126 129 int crypto_register_shashes(struct shash_alg *algs, int count); ··· 126 133 int shash_register_instance(struct crypto_template *tmpl, 127 134 struct shash_instance *inst); 128 135 void shash_free_instance(struct crypto_instance *inst); 129 - 130 - int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn, 131 - struct shash_alg *alg, 132 - struct crypto_instance *inst); 133 136 134 137 int crypto_grab_shash(struct crypto_shash_spawn *spawn, 135 138 struct crypto_instance *inst, ··· 141 152 { 142 153 return __crypto_shash_alg(spawn->base.alg); 143 154 } 144 - 145 - struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask); 146 155 147 156 int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc); 148 157 int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc); ··· 180 193 static inline void *ahash_instance_ctx(struct ahash_instance *inst) 181 194 { 182 195 return crypto_instance_ctx(ahash_crypto_instance(inst)); 183 - } 184 - 185 - static inline unsigned int ahash_instance_headroom(void) 186 - { 187 - return sizeof(struct ahash_alg) - sizeof(struct crypto_alg); 188 - } 189 - 190 - static inline struct ahash_instance *ahash_alloc_instance( 191 - const char *name, struct crypto_alg *alg) 192 - { 193 - return crypto_alloc_instance(name, alg, ahash_instance_headroom()); 194 196 } 195 197 196 198 static inline void ahash_request_complete(struct ahash_request *req, int err) ··· 236 260 static inline void *shash_instance_ctx(struct shash_instance *inst) 237 261 { 238 262 return crypto_instance_ctx(shash_crypto_instance(inst)); 239 - } 240 - 241 - static inline struct shash_instance *shash_alloc_instance( 242 - const char *name, struct crypto_alg *alg) 243 - { 244 - return crypto_alloc_instance(name, alg, 245 - sizeof(struct shash_alg) - sizeof(*alg)); 246 263 } 247 264 248 265 static inline struct crypto_shash *crypto_spawn_shash(