]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
crypto: cryptd - pass through absence of ->setkey()
authorEric Biggers <ebiggers@google.com>
Wed, 3 Jan 2018 19:16:23 +0000 (11:16 -0800)
committerSasha Levin <alexander.levin@microsoft.com>
Thu, 1 Mar 2018 03:09:51 +0000 (22:09 -0500)
[ Upstream commit 841a3ff329713f796a63356fef6e2f72e4a3f6a3 ]

When the cryptd template is used to wrap an unkeyed hash algorithm,
don't install a ->setkey() method to the cryptd instance.  This change
is necessary for cryptd to keep working with unkeyed hash algorithms
once we start enforcing that ->setkey() is called when present.

Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
crypto/cryptd.c

index 66c9e826257294bf3b8ee6ce49c98473cb556cd6..4e76f1db3e68b3498057a50f47c9cc921480c29d 100644 (file)
@@ -645,7 +645,8 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
        inst->alg.finup  = cryptd_hash_finup_enqueue;
        inst->alg.export = cryptd_hash_export;
        inst->alg.import = cryptd_hash_import;
-       inst->alg.setkey = cryptd_hash_setkey;
+       if (crypto_shash_alg_has_setkey(salg))
+               inst->alg.setkey = cryptd_hash_setkey;
        inst->alg.digest = cryptd_hash_digest_enqueue;
 
        err = ahash_register_instance(tmpl, inst);