]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: skcipher - Add crypto_skcipher_has_setkey
authorHerbert Xu <herbert@gondor.apana.org.au>
Mon, 11 Jan 2016 13:26:50 +0000 (21:26 +0800)
committerLuis Henriques <luis.henriques@canonical.com>
Wed, 24 Feb 2016 14:31:26 +0000 (14:31 +0000)
commit a1383cd86a062fc798899ab20f0ec2116cce39cb upstream.

This patch adds a way for skcipher users to determine whether a key
is required by a transform.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
[bwh: Backported to 3.2: add to ablkcipher API instead]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
crypto/ablkcipher.c
include/linux/crypto.h

index f02fdbefb2c6f8ed5e318c1c5b463e73e56c073a..5da16526c89063f59eea8767163dd7a6d1c7425b 100644 (file)
@@ -375,6 +375,7 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type,
        }
        crt->base = __crypto_ablkcipher_cast(tfm);
        crt->ivsize = alg->ivsize;
+       crt->has_setkey = alg->max_keysize;
 
        return 0;
 }
index 2b00d92a6e6fcec18b0ccf532b25839813d0868e..61dd0b15d21ca915750aa399befe33bd968329e9 100644 (file)
@@ -354,6 +354,7 @@ struct ablkcipher_tfm {
 
        unsigned int ivsize;
        unsigned int reqsize;
+       bool has_setkey;
 };
 
 struct aead_tfm {
@@ -664,6 +665,13 @@ static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
        return crt->setkey(crt->base, key, keylen);
 }
 
+static inline bool crypto_ablkcipher_has_setkey(struct crypto_ablkcipher *tfm)
+{
+       struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm);
+
+       return crt->has_setkey;
+}
+
 static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm(
        struct ablkcipher_request *req)
 {