Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
[cascardo/linux.git] / crypto / ablkcipher.c
index db201bc..b788f16 100644 (file)
@@ -454,7 +454,7 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type,
                      alg->setkey : setkey;
        crt->encrypt = alg->encrypt;
        crt->decrypt = alg->decrypt;
-       crt->givencrypt = alg->givencrypt;
+       crt->givencrypt = alg->givencrypt ?: no_givdecrypt;
        crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt;
        crt->base = __crypto_ablkcipher_cast(tfm);
        crt->ivsize = alg->ivsize;
@@ -586,6 +586,13 @@ static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)
        if (!tmpl)
                goto kill_larval;
 
+       if (tmpl->create) {
+               err = tmpl->create(tmpl, tb);
+               if (err)
+                       goto put_tmpl;
+               goto ok;
+       }
+
        inst = tmpl->alloc(tb);
        err = PTR_ERR(inst);
        if (IS_ERR(inst))
@@ -597,6 +604,7 @@ static int crypto_givcipher_default(struct crypto_alg *alg, u32 type, u32 mask)
                goto put_tmpl;
        }
 
+ok:
        /* Redo the lookup to use the instance we just registered. */
        err = -EAGAIN;
 
@@ -636,7 +644,7 @@ struct crypto_alg *crypto_lookup_skcipher(const char *name, u32 type, u32 mask)
 
        if ((alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
            CRYPTO_ALG_TYPE_GIVCIPHER) {
-               if ((alg->cra_flags ^ type ^ ~mask) & CRYPTO_ALG_TESTED) {
+               if (~alg->cra_flags & (type ^ ~mask) & CRYPTO_ALG_TESTED) {
                        crypto_mod_put(alg);
                        alg = ERR_PTR(-ENOENT);
                }