Skip to content

Commit 629f1af

Browse files
ebiggersherbertx
authored andcommitted
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>
1 parent d5ed3b6 commit 629f1af

5 files changed

Lines changed: 0 additions & 154 deletions

File tree

‎crypto/ahash.c‎

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -655,31 +655,6 @@ int ahash_register_instance(struct crypto_template *tmpl,
655655
}
656656
EXPORT_SYMBOL_GPL(ahash_register_instance);
657657

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-
683658
bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg)
684659
{
685660
struct crypto_alg *alg = &halg->base;

‎crypto/algapi.c‎

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -697,23 +697,6 @@ int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
697697
}
698698
EXPORT_SYMBOL_GPL(crypto_init_spawn);
699699

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-
717700
int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst,
718701
const char *name, u32 type, u32 mask)
719702
{
@@ -876,20 +859,6 @@ const char *crypto_attr_alg_name(struct rtattr *rta)
876859
}
877860
EXPORT_SYMBOL_GPL(crypto_attr_alg_name);
878861

879-
struct crypto_alg *crypto_attr_alg2(struct rtattr *rta,
880-
const struct crypto_type *frontend,
881-
u32 type, u32 mask)
882-
{
883-
const char *name;
884-
885-
name = crypto_attr_alg_name(rta);
886-
if (IS_ERR(name))
887-
return ERR_CAST(name);
888-
889-
return crypto_find_alg(name, frontend, type, mask);
890-
}
891-
EXPORT_SYMBOL_GPL(crypto_attr_alg2);
892-
893862
int crypto_attr_u32(struct rtattr *rta, u32 *num)
894863
{
895864
struct crypto_attr_u32 *nu32;
@@ -923,32 +892,6 @@ int crypto_inst_setname(struct crypto_instance *inst, const char *name,
923892
}
924893
EXPORT_SYMBOL_GPL(crypto_inst_setname);
925894

926-
void *crypto_alloc_instance(const char *name, struct crypto_alg *alg,
927-
unsigned int head)
928-
{
929-
struct crypto_instance *inst;
930-
char *p;
931-
int err;
932-
933-
p = kzalloc(head + sizeof(*inst) + sizeof(struct crypto_spawn),
934-
GFP_KERNEL);
935-
if (!p)
936-
return ERR_PTR(-ENOMEM);
937-
938-
inst = (void *)(p + head);
939-
940-
err = crypto_inst_setname(inst, name, alg);
941-
if (err)
942-
goto err_free_inst;
943-
944-
return p;
945-
946-
err_free_inst:
947-
kfree(p);
948-
return ERR_PTR(err);
949-
}
950-
EXPORT_SYMBOL_GPL(crypto_alloc_instance);
951-
952895
void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen)
953896
{
954897
INIT_LIST_HEAD(&queue->list);

‎crypto/shash.c‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -584,24 +584,5 @@ void shash_free_instance(struct crypto_instance *inst)
584584
}
585585
EXPORT_SYMBOL_GPL(shash_free_instance);
586586

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-
606587
MODULE_LICENSE("GPL");
607588
MODULE_DESCRIPTION("Synchronous cryptographic hash type");

‎include/crypto/algapi.h‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ void crypto_unregister_instance(struct crypto_instance *inst);
113113

114114
int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
115115
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);
119116
int crypto_grab_spawn(struct crypto_spawn *spawn, struct crypto_instance *inst,
120117
const char *name, u32 type, u32 mask);
121-
122118
void crypto_drop_spawn(struct crypto_spawn *spawn);
123119
struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
124120
u32 mask);
@@ -127,21 +123,9 @@ void *crypto_spawn_tfm2(struct crypto_spawn *spawn);
127123
struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
128124
int crypto_check_attr_type(struct rtattr **tb, u32 type);
129125
const char *crypto_attr_alg_name(struct rtattr *rta);
130-
struct crypto_alg *crypto_attr_alg2(struct rtattr *rta,
131-
const struct crypto_type *frontend,
132-
u32 type, u32 mask);
133-
134-
static inline struct crypto_alg *crypto_attr_alg(struct rtattr *rta,
135-
u32 type, u32 mask)
136-
{
137-
return crypto_attr_alg2(rta, NULL, type, mask);
138-
}
139-
140126
int crypto_attr_u32(struct rtattr *rta, u32 *num);
141127
int crypto_inst_setname(struct crypto_instance *inst, const char *name,
142128
struct crypto_alg *alg);
143-
void *crypto_alloc_instance(const char *name, struct crypto_alg *alg,
144-
unsigned int head);
145129

146130
void crypto_init_queue(struct crypto_queue *queue, unsigned int max_qlen);
147131
int crypto_enqueue_request(struct crypto_queue *queue,
@@ -254,12 +238,6 @@ static inline struct crypto_async_request *crypto_get_backlog(
254238
container_of(queue->backlog, struct crypto_async_request, list);
255239
}
256240

257-
static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb,
258-
u32 type, u32 mask)
259-
{
260-
return crypto_attr_alg(tb[1], type, mask);
261-
}
262-
263241
static inline int crypto_requires_off(u32 type, u32 mask, u32 off)
264242
{
265243
return (type ^ off) & mask & off;

‎include/crypto/internal/hash.h‎

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ int crypto_register_ahashes(struct ahash_alg *algs, int count);
8787
void crypto_unregister_ahashes(struct ahash_alg *algs, int count);
8888
int ahash_register_instance(struct crypto_template *tmpl,
8989
struct ahash_instance *inst);
90-
void ahash_free_instance(struct crypto_instance *inst);
9190

9291
int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
9392
unsigned int keylen);
@@ -105,10 +104,6 @@ static inline bool crypto_shash_alg_needs_key(struct shash_alg *alg)
105104

106105
bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg);
107106

108-
int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
109-
struct hash_alg_common *alg,
110-
struct crypto_instance *inst);
111-
112107
int crypto_grab_ahash(struct crypto_ahash_spawn *spawn,
113108
struct crypto_instance *inst,
114109
const char *name, u32 type, u32 mask);
@@ -124,8 +119,6 @@ static inline struct hash_alg_common *crypto_spawn_ahash_alg(
124119
return __crypto_hash_alg_common(spawn->base.alg);
125120
}
126121

127-
struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
128-
129122
int crypto_register_shash(struct shash_alg *alg);
130123
void crypto_unregister_shash(struct shash_alg *alg);
131124
int crypto_register_shashes(struct shash_alg *algs, int count);
@@ -134,10 +127,6 @@ int shash_register_instance(struct crypto_template *tmpl,
134127
struct shash_instance *inst);
135128
void shash_free_instance(struct crypto_instance *inst);
136129

137-
int crypto_init_shash_spawn(struct crypto_shash_spawn *spawn,
138-
struct shash_alg *alg,
139-
struct crypto_instance *inst);
140-
141130
int crypto_grab_shash(struct crypto_shash_spawn *spawn,
142131
struct crypto_instance *inst,
143132
const char *name, u32 type, u32 mask);
@@ -153,8 +142,6 @@ static inline struct shash_alg *crypto_spawn_shash_alg(
153142
return __crypto_shash_alg(spawn->base.alg);
154143
}
155144

156-
struct shash_alg *shash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
157-
158145
int shash_ahash_update(struct ahash_request *req, struct shash_desc *desc);
159146
int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc);
160147
int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc);
@@ -195,17 +182,6 @@ static inline void *ahash_instance_ctx(struct ahash_instance *inst)
195182
return crypto_instance_ctx(ahash_crypto_instance(inst));
196183
}
197184

198-
static inline unsigned int ahash_instance_headroom(void)
199-
{
200-
return sizeof(struct ahash_alg) - sizeof(struct crypto_alg);
201-
}
202-
203-
static inline struct ahash_instance *ahash_alloc_instance(
204-
const char *name, struct crypto_alg *alg)
205-
{
206-
return crypto_alloc_instance(name, alg, ahash_instance_headroom());
207-
}
208-
209185
static inline void ahash_request_complete(struct ahash_request *req, int err)
210186
{
211187
req->base.complete(&req->base, err);
@@ -262,13 +238,6 @@ static inline void *shash_instance_ctx(struct shash_instance *inst)
262238
return crypto_instance_ctx(shash_crypto_instance(inst));
263239
}
264240

265-
static inline struct shash_instance *shash_alloc_instance(
266-
const char *name, struct crypto_alg *alg)
267-
{
268-
return crypto_alloc_instance(name, alg,
269-
sizeof(struct shash_alg) - sizeof(*alg));
270-
}
271-
272241
static inline struct crypto_shash *crypto_spawn_shash(
273242
struct crypto_shash_spawn *spawn)
274243
{

0 commit comments

Comments
 (0)