aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/internal
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-14 02:06:06 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-14 03:54:09 -0400
commit01c2dece4316dadc0f9fad1ad0b56d493980e492 (patch)
tree0d28b58ef64c4b286351ff18adc96899baac5ab8 /include/crypto/internal
parent88056ec346ccf41f63dbc7080b24b5fd19d1358d (diff)
crypto: ahash - Add instance/spawn support
This patch adds support for creating ahash instances and using ahash as spawns. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto/internal')
-rw-r--r--include/crypto/internal/hash.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
index 08bdffafefad..34eda233ee67 100644
--- a/include/crypto/internal/hash.h
+++ b/include/crypto/internal/hash.h
@@ -34,10 +34,18 @@ struct crypto_hash_walk {
34 unsigned int flags; 34 unsigned int flags;
35}; 35};
36 36
37struct ahash_instance {
38 struct ahash_alg alg;
39};
40
37struct shash_instance { 41struct shash_instance {
38 struct shash_alg alg; 42 struct shash_alg alg;
39}; 43};
40 44
45struct crypto_ahash_spawn {
46 struct crypto_spawn base;
47};
48
41struct crypto_shash_spawn { 49struct crypto_shash_spawn {
42 struct crypto_spawn base; 50 struct crypto_spawn base;
43}; 51};
@@ -53,6 +61,15 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
53 61
54int crypto_register_ahash(struct ahash_alg *alg); 62int crypto_register_ahash(struct ahash_alg *alg);
55int crypto_unregister_ahash(struct ahash_alg *alg); 63int crypto_unregister_ahash(struct ahash_alg *alg);
64int ahash_register_instance(struct crypto_template *tmpl,
65 struct ahash_instance *inst);
66void ahash_free_instance(struct crypto_instance *inst);
67
68int crypto_init_ahash_spawn(struct crypto_ahash_spawn *spawn,
69 struct hash_alg_common *alg,
70 struct crypto_instance *inst);
71
72struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
56 73
57int crypto_register_shash(struct shash_alg *alg); 74int crypto_register_shash(struct shash_alg *alg);
58int crypto_unregister_shash(struct shash_alg *alg); 75int crypto_unregister_shash(struct shash_alg *alg);
@@ -88,6 +105,40 @@ static inline void crypto_ahash_set_reqsize(struct crypto_ahash *tfm,
88 tfm->reqsize = reqsize; 105 tfm->reqsize = reqsize;
89} 106}
90 107
108static inline struct crypto_instance *ahash_crypto_instance(
109 struct ahash_instance *inst)
110{
111 return container_of(&inst->alg.halg.base, struct crypto_instance, alg);
112}
113
114static inline struct ahash_instance *ahash_instance(
115 struct crypto_instance *inst)
116{
117 return container_of(&inst->alg, struct ahash_instance, alg.halg.base);
118}
119
120static inline void *ahash_instance_ctx(struct ahash_instance *inst)
121{
122 return crypto_instance_ctx(ahash_crypto_instance(inst));
123}
124
125static inline unsigned int ahash_instance_headroom(void)
126{
127 return sizeof(struct ahash_alg) - sizeof(struct crypto_alg);
128}
129
130static inline struct ahash_instance *ahash_alloc_instance(
131 const char *name, struct crypto_alg *alg)
132{
133 return crypto_alloc_instance2(name, alg, ahash_instance_headroom());
134}
135
136static inline struct crypto_ahash *crypto_spawn_ahash(
137 struct crypto_ahash_spawn *spawn)
138{
139 return crypto_spawn_tfm2(&spawn->base);
140}
141
91static inline int ahash_enqueue_request(struct crypto_queue *queue, 142static inline int ahash_enqueue_request(struct crypto_queue *queue,
92 struct ahash_request *request) 143 struct ahash_request *request)
93{ 144{