aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/xcbc.c
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 /crypto/xcbc.c
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 'crypto/xcbc.c')
-rw-r--r--crypto/xcbc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
index 317e9f08fc04..d7b4be0a057d 100644
--- a/crypto/xcbc.c
+++ b/crypto/xcbc.c
@@ -254,14 +254,15 @@ static int crypto_xcbc_digest(struct hash_desc *pdesc,
254 254
255static int xcbc_init_tfm(struct crypto_tfm *tfm) 255static int xcbc_init_tfm(struct crypto_tfm *tfm)
256{ 256{
257 struct crypto_cipher *cipher;
257 struct crypto_instance *inst = (void *)tfm->__crt_alg; 258 struct crypto_instance *inst = (void *)tfm->__crt_alg;
258 struct crypto_spawn *spawn = crypto_instance_ctx(inst); 259 struct crypto_spawn *spawn = crypto_instance_ctx(inst);
259 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm)); 260 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
260 int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm)); 261 int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm));
261 262
262 tfm = crypto_spawn_tfm(spawn); 263 cipher = crypto_spawn_cipher(spawn);
263 if (IS_ERR(tfm)) 264 if (IS_ERR(cipher))
264 return PTR_ERR(tfm); 265 return PTR_ERR(cipher);
265 266
266 switch(bs) { 267 switch(bs) {
267 case 16: 268 case 16:
@@ -271,7 +272,7 @@ static int xcbc_init_tfm(struct crypto_tfm *tfm)
271 return -EINVAL; 272 return -EINVAL;
272 } 273 }
273 274
274 ctx->child = crypto_cipher_cast(tfm); 275 ctx->child = cipher;
275 ctx->odds = (u8*)(ctx+1); 276 ctx->odds = (u8*)(ctx+1);
276 ctx->prev = ctx->odds + bs; 277 ctx->prev = ctx->odds + bs;
277 ctx->key = ctx->prev + bs; 278 ctx->key = ctx->prev + bs;