crypto: aead - pass instance to crypto_grab_aead()
[linux-2.6-block.git] / crypto / gcm.c
index 887f472734b66c2d26b1de2002244fbee40a5d27..72649b8cbf2a4523952423bcc3089f3958f539c1 100644 (file)
@@ -856,6 +856,7 @@ static int crypto_rfc4106_create(struct crypto_template *tmpl,
                                 struct rtattr **tb)
 {
        struct crypto_attr_type *algt;
+       u32 mask;
        struct aead_instance *inst;
        struct crypto_aead_spawn *spawn;
        struct aead_alg *alg;
@@ -869,6 +870,8 @@ static int crypto_rfc4106_create(struct crypto_template *tmpl,
        if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
                return -EINVAL;
 
+       mask = crypto_requires_sync(algt->type, algt->mask);
+
        ccm_name = crypto_attr_alg_name(tb[1]);
        if (IS_ERR(ccm_name))
                return PTR_ERR(ccm_name);
@@ -878,9 +881,8 @@ static int crypto_rfc4106_create(struct crypto_template *tmpl,
                return -ENOMEM;
 
        spawn = aead_instance_ctx(inst);
-       crypto_set_aead_spawn(spawn, aead_crypto_instance(inst));
-       err = crypto_grab_aead(spawn, ccm_name, 0,
-                              crypto_requires_sync(algt->type, algt->mask));
+       err = crypto_grab_aead(spawn, aead_crypto_instance(inst),
+                              ccm_name, 0, mask);
        if (err)
                goto out_free_inst;
 
@@ -1087,6 +1089,7 @@ static int crypto_rfc4543_create(struct crypto_template *tmpl,
                                struct rtattr **tb)
 {
        struct crypto_attr_type *algt;
+       u32 mask;
        struct aead_instance *inst;
        struct crypto_aead_spawn *spawn;
        struct aead_alg *alg;
@@ -1101,6 +1104,8 @@ static int crypto_rfc4543_create(struct crypto_template *tmpl,
        if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
                return -EINVAL;
 
+       mask = crypto_requires_sync(algt->type, algt->mask);
+
        ccm_name = crypto_attr_alg_name(tb[1]);
        if (IS_ERR(ccm_name))
                return PTR_ERR(ccm_name);
@@ -1111,9 +1116,8 @@ static int crypto_rfc4543_create(struct crypto_template *tmpl,
 
        ctx = aead_instance_ctx(inst);
        spawn = &ctx->aead;
-       crypto_set_aead_spawn(spawn, aead_crypto_instance(inst));
-       err = crypto_grab_aead(spawn, ccm_name, 0,
-                              crypto_requires_sync(algt->type, algt->mask));
+       err = crypto_grab_aead(spawn, aead_crypto_instance(inst),
+                              ccm_name, 0, mask);
        if (err)
                goto out_free_inst;