From patchwork Thu Mar 24 17:06:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 601735 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3qWCXr4vlGz9sD5; Fri, 25 Mar 2016 04:07:24 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1aj8jA-0005Br-Uv; Thu, 24 Mar 2016 17:07:20 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1aj8iw-00056H-Tp for kernel-team@lists.ubuntu.com; Thu, 24 Mar 2016 17:07:06 +0000 Received: from 1.general.kamal.us.vpn ([10.172.68.52] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1aj8iw-0006gO-Ch for kernel-team@lists.ubuntu.com; Thu, 24 Mar 2016 17:07:06 +0000 Received: from kamal by fourier with local (Exim 4.86) (envelope-from ) id 1aj8it-0007MR-MR for kernel-team@lists.ubuntu.com; Thu, 24 Mar 2016 10:07:03 -0700 From: Kamal Mostafa To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4] crypto: skcipher - Add crypto_skcipher_has_setkey Date: Thu, 24 Mar 2016 10:06:58 -0700 Message-Id: <1458839221-28249-2-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458839221-28249-1-git-send-email-kamal@canonical.com> References: <1458839221-28249-1-git-send-email-kamal@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Herbert Xu BugLink: http://bugs.launchpad.net/bugs/1556562 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 Signed-off-by: Kamal Mostafa --- crypto/ablkcipher.c | 1 + include/linux/crypto.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index e5b5721..71b4b2e 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c @@ -377,6 +377,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; } diff --git a/include/linux/crypto.h b/include/linux/crypto.h index 81ef938..ab5f912 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -552,6 +552,7 @@ struct ablkcipher_tfm { unsigned int ivsize; unsigned int reqsize; + bool has_setkey; }; struct blkcipher_tfm { @@ -922,6 +923,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