Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759503AbcDBBnd (ORCPT ); Fri, 1 Apr 2016 21:43:33 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53784 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755875AbcDBAyh (ORCPT ); Fri, 1 Apr 2016 20:54:37 -0400 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Herbert Xu , Ben Hutchings , Luis Henriques , Kamal Mostafa Subject: [PATCH 3.19.y-ckt 004/170] crypto: skcipher - Add crypto_skcipher_has_setkey Date: Fri, 1 Apr 2016 17:51:30 -0700 Message-Id: <1459558456-24452-5-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1459558456-24452-1-git-send-email-kamal@canonical.com> References: <1459558456-24452-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.19 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2603 Lines: 83 3.19.8-ckt18 -stable review patch. If anyone has any objections, please let me know. ---8<------------------------------------------------------------ From: Herbert Xu 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 [bwh: Backported to 3.2: add to ablkcipher API instead] Signed-off-by: Ben Hutchings Signed-off-by: Luis Henriques [kamal: plus bwh http://article.gmane.org/gmane.linux.kernel.stable/169083] Signed-off-by: Kamal Mostafa --- crypto/ablkcipher.c | 2 ++ crypto/blkcipher.c | 1 + include/linux/crypto.h | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index f02fdbe..970b48e 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c @@ -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; } @@ -456,6 +457,7 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type, crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; crt->base = __crypto_ablkcipher_cast(tfm); crt->ivsize = alg->ivsize; + crt->has_setkey = alg->max_keysize; return 0; } diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 7180cb2..3c551d4 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c @@ -471,6 +471,7 @@ static int crypto_init_blkcipher_ops_async(struct crypto_tfm *tfm) } crt->base = __crypto_ablkcipher_cast(tfm); crt->ivsize = alg->ivsize; + crt->has_setkey = alg->max_keysize; return 0; } diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 9c8776d..4948de9 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -594,6 +594,7 @@ struct ablkcipher_tfm { unsigned int ivsize; unsigned int reqsize; + bool has_setkey; }; struct aead_tfm { @@ -997,6 +998,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; +} + /** * crypto_ablkcipher_reqtfm() - obtain cipher handle from request * @req: ablkcipher_request out of which the cipher handle is to be obtained -- 2.7.4