aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/algapi.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2006-12-16 18:05:58 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2007-02-06 17:21:01 -0500
commit2e306ee016fd4750289e65c3b1856db569f1f3f2 (patch)
tree53ace6081967c640f052d53397250657af855c25 /include/crypto/algapi.h
parentf1ddcaf3393b7a3871809b97fae90fac841a1f39 (diff)
[CRYPTO] api: Add type-safe spawns
This patch allows spawns of specific types (e.g., cipher) to be allocated. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto/algapi.h')
-rw-r--r--include/crypto/algapi.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index 5748aecdb414..99c534d573d2 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -93,7 +93,8 @@ struct crypto_template *crypto_lookup_template(const char *name);
93int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg, 93int crypto_init_spawn(struct crypto_spawn *spawn, struct crypto_alg *alg,
94 struct crypto_instance *inst); 94 struct crypto_instance *inst);
95void crypto_drop_spawn(struct crypto_spawn *spawn); 95void crypto_drop_spawn(struct crypto_spawn *spawn);
96struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn); 96struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
97 u32 mask);
97 98
98struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len, 99struct crypto_alg *crypto_get_attr_alg(void *param, unsigned int len,
99 u32 type, u32 mask); 100 u32 type, u32 mask);
@@ -132,11 +133,28 @@ static inline void *crypto_blkcipher_ctx_aligned(struct crypto_blkcipher *tfm)
132 return crypto_tfm_ctx_aligned(&tfm->base); 133 return crypto_tfm_ctx_aligned(&tfm->base);
133} 134}
134 135
136static inline struct crypto_cipher *crypto_spawn_cipher(
137 struct crypto_spawn *spawn)
138{
139 u32 type = CRYPTO_ALG_TYPE_CIPHER;
140 u32 mask = CRYPTO_ALG_TYPE_MASK;
141
142 return __crypto_cipher_cast(crypto_spawn_tfm(spawn, type, mask));
143}
144
135static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm) 145static inline struct cipher_alg *crypto_cipher_alg(struct crypto_cipher *tfm)
136{ 146{
137 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher; 147 return &crypto_cipher_tfm(tfm)->__crt_alg->cra_cipher;
138} 148}
139 149
150static inline struct crypto_hash *crypto_spawn_hash(struct crypto_spawn *spawn)
151{
152 u32 type = CRYPTO_ALG_TYPE_HASH;
153 u32 mask = CRYPTO_ALG_TYPE_HASH_MASK;
154
155 return __crypto_hash_cast(crypto_spawn_tfm(spawn, type, mask));
156}
157
140static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm) 158static inline void *crypto_hash_ctx_aligned(struct crypto_hash *tfm)
141{ 159{
142 return crypto_tfm_ctx_aligned(&tfm->base); 160 return crypto_tfm_ctx_aligned(&tfm->base);