diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-01-24 04:50:26 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2007-02-06 17:21:01 -0500 |
commit | 27d2a3300755387d2fec231d37944907ff992ce8 (patch) | |
tree | c42138c0160b8f0aa3d79860557514e73577e885 /crypto/api.c | |
parent | 2e306ee016fd4750289e65c3b1856db569f1f3f2 (diff) |
[CRYPTO] api: Allow multiple frontends per backend
This patch adds support for multiple frontend types for each backend
algorithm by passing the type and mask through to the backend type
init function.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/api.c')
-rw-r--r-- | crypto/api.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crypto/api.c b/crypto/api.c index 8b80baec853a..55af8bb0f050 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -212,12 +212,12 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask) | |||
212 | } | 212 | } |
213 | EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup); | 213 | EXPORT_SYMBOL_GPL(crypto_alg_mod_lookup); |
214 | 214 | ||
215 | static int crypto_init_ops(struct crypto_tfm *tfm) | 215 | static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask) |
216 | { | 216 | { |
217 | const struct crypto_type *type = tfm->__crt_alg->cra_type; | 217 | const struct crypto_type *type_obj = tfm->__crt_alg->cra_type; |
218 | 218 | ||
219 | if (type) | 219 | if (type_obj) |
220 | return type->init(tfm); | 220 | return type_obj->init(tfm, type, mask); |
221 | 221 | ||
222 | switch (crypto_tfm_alg_type(tfm)) { | 222 | switch (crypto_tfm_alg_type(tfm)) { |
223 | case CRYPTO_ALG_TYPE_CIPHER: | 223 | case CRYPTO_ALG_TYPE_CIPHER: |
@@ -266,14 +266,14 @@ static void crypto_exit_ops(struct crypto_tfm *tfm) | |||
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | static unsigned int crypto_ctxsize(struct crypto_alg *alg) | 269 | static unsigned int crypto_ctxsize(struct crypto_alg *alg, u32 type, u32 mask) |
270 | { | 270 | { |
271 | const struct crypto_type *type = alg->cra_type; | 271 | const struct crypto_type *type_obj = alg->cra_type; |
272 | unsigned int len; | 272 | unsigned int len; |
273 | 273 | ||
274 | len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); | 274 | len = alg->cra_alignmask & ~(crypto_tfm_ctx_alignment() - 1); |
275 | if (type) | 275 | if (type_obj) |
276 | return len + type->ctxsize(alg); | 276 | return len + type_obj->ctxsize(alg, type, mask); |
277 | 277 | ||
278 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { | 278 | switch (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) { |
279 | default: | 279 | default: |
@@ -303,20 +303,21 @@ void crypto_shoot_alg(struct crypto_alg *alg) | |||
303 | } | 303 | } |
304 | EXPORT_SYMBOL_GPL(crypto_shoot_alg); | 304 | EXPORT_SYMBOL_GPL(crypto_shoot_alg); |
305 | 305 | ||
306 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg) | 306 | struct crypto_tfm *__crypto_alloc_tfm(struct crypto_alg *alg, u32 type, |
307 | u32 mask) | ||
307 | { | 308 | { |
308 | struct crypto_tfm *tfm = NULL; | 309 | struct crypto_tfm *tfm = NULL; |
309 | unsigned int tfm_size; | 310 | unsigned int tfm_size; |
310 | int err = -ENOMEM; | 311 | int err = -ENOMEM; |
311 | 312 | ||
312 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg); | 313 | tfm_size = sizeof(*tfm) + crypto_ctxsize(alg, type, mask); |
313 | tfm = kzalloc(tfm_size, GFP_KERNEL); | 314 | tfm = kzalloc(tfm_size, GFP_KERNEL); |
314 | if (tfm == NULL) | 315 | if (tfm == NULL) |
315 | goto out_err; | 316 | goto out_err; |
316 | 317 | ||
317 | tfm->__crt_alg = alg; | 318 | tfm->__crt_alg = alg; |
318 | 319 | ||
319 | err = crypto_init_ops(tfm); | 320 | err = crypto_init_ops(tfm, type, mask); |
320 | if (err) | 321 | if (err) |
321 | goto out_free_tfm; | 322 | goto out_free_tfm; |
322 | 323 | ||
@@ -372,7 +373,7 @@ struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask) | |||
372 | goto err; | 373 | goto err; |
373 | } | 374 | } |
374 | 375 | ||
375 | tfm = __crypto_alloc_tfm(alg); | 376 | tfm = __crypto_alloc_tfm(alg, type, mask); |
376 | if (!IS_ERR(tfm)) | 377 | if (!IS_ERR(tfm)) |
377 | return tfm; | 378 | return tfm; |
378 | 379 | ||