From patchwork Thu Oct 27 14:29:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 9400119 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA233600BA for ; Thu, 27 Oct 2016 18:04:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFA752A227 for ; Thu, 27 Oct 2016 18:04:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D490F2A344; Thu, 27 Oct 2016 18:04:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EE602A227 for ; Thu, 27 Oct 2016 18:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934322AbcJ0SEB (ORCPT ); Thu, 27 Oct 2016 14:04:01 -0400 Received: from mail-ve1eur01on0105.outbound.protection.outlook.com ([104.47.1.105]:13440 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S936503AbcJ0SEA (ORCPT ); Thu, 27 Oct 2016 14:04:00 -0400 X-Greylist: delayed 7226 seconds by postgrey-1.27 at vger.kernel.org; Thu, 27 Oct 2016 14:03:59 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=7biknAJlDgJFgRDalKs9hxaSehe0hyJlNtvTJibgXtc=; b=KsiRo66/z6ZgqXGeWQH4z5pIHZoeajIL3PYNHH4T7I0vZiJSCsqs577NAunJ9lIUcRF/RwoycDJXqmlcoIUNkHOPP/tWuENG7ZobmpD23v1Qc9r0vwHfKFO5Mamh4gF2pvn+iAwpMpUeHkTuKfb6Ct3urrCkOUVy0me+ed+/O4M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Received: from localhost.sw.ru (195.214.232.10) by HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.12; Thu, 27 Oct 2016 14:29:51 +0000 From: Andrey Ryabinin To: Willy Tarreau , CC: Herbert Xu , , Andrey Ryabinin Subject: [PATCH stable 3.10.y 05/18] crypto: hash - Add crypto_ahash_has_setkey Date: Thu, 27 Oct 2016 17:29:38 +0300 Message-ID: <1477578591-28924-6-git-send-email-aryabinin@virtuozzo.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477578591-28924-1-git-send-email-aryabinin@virtuozzo.com> References: <1477578591-28924-1-git-send-email-aryabinin@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: AM4PR0501CA0035.eurprd05.prod.outlook.com (10.167.83.173) To HE1PR0802MB2555.eurprd08.prod.outlook.com (10.175.35.148) X-MS-Office365-Filtering-Correlation-Id: 3084d391-1d39-4dec-b5cd-08d3fe75b6db X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 2:vb0pOvHJBI9o2mjGtQ2D2H35XqVVFmU+7+xknLVAsaa8PMw80AZb94E1JKGABFQSKVALPBw9ksmnzOmlSTs0omIZ3WZiNeAcQUsSYxC63DCoCfN1pZwAUtjUey4x8Ka8FGot186T8/+cp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XcPAu1OsarpBRBHv/2G9Z8Bu7FhO+Nc9201iyT7tP+3FxWnWOojj96IpE3vFxrAkVLIh87P+k4QVjNLHeci1BIyhjDwI8+k3B3ws7n4b2iuOzeM4f+FlA3mVu8KWijeVsuXSwQKVbXnu2lSkzJG6BxHRGUcqNDpcpXcKtqoTdB17FiKqyifVpbJD8l25zXZ8D9UReDF3V6je8a0knDld0detC4JPvy+RzjYoxAx7reapSHt4xq8KEdv6PF/CnNLqA8L+BZJ4ogcG2IdMhxpFs282GTk/hpixwhh6OiwgXc/0KKgVcpaOMmR9vfkQUEZ0Bp7CCkzEEZ2y6rGO/svXVziOVumrg4QY9DDvp8eVShfTdCW3SYrfFcdYuBzZ8ReQJtf6fdBW2LDHK/XZJ89lO5lZFc/PItQVrCnCOntJHiX8ZcsdOD7OO2rCONZHfgzLWih1f9QFFw7qn7bhTZdXv3BSYR/2gLN23e/a3rY9QQU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6043046)(6042046); SRVR:HE1PR0802MB2555; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0802MB2555; X-Forefront-PRVS: 0108A997B2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(2906002)(81166006)(53416004)(76506005)(8676002)(81156014)(42186005)(305945005)(7846002)(76176999)(48376002)(19580395003)(50986999)(7736002)(19580405001)(2950100002)(105586002)(86362001)(229853001)(586003)(6666003)(6116002)(3846002)(4001430100002)(33646002)(50466002)(36756003)(4326007)(69596002)(189998001)(77096005)(47776003)(5001770100001)(66066001)(107886002)(92566002)(5660300001)(50226002)(5003940100001)(101416001)(68736007)(106356001)(97736004)(781001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0802MB2555; H:localhost.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0802MB2555; 23:bgvJTeQbI4ydfVp9E2D4eWT6SrP+HkhhQBm51gS?= =?us-ascii?Q?/c4Q5/Nu4a5mdj9n7bmssB7EtH2Z8A+PPNsMgfCDj5CAipe1UICJ6LWp0YY4?= =?us-ascii?Q?XHNnjZrUssrlcYZJAMECR9IuATD4s/x06R/B3/MR4CHbZunJSHIO3B1YRsnn?= =?us-ascii?Q?UvsG7I4k9me0kGFmTqulPpRCQLmDXyNujv8l2LbeWhVORBN0VzfXGyHxmYVs?= =?us-ascii?Q?qbBxb0rNcXxlhvus9U/TeQ86voh7sENNdc0CTq3sKyDcj+eiQdDYHC3YVJW+?= =?us-ascii?Q?R9jjxi3Dt8bOk0vv7Ca+dZanLGoxHKDIhP8ycRnJ5NJG3UUWbvNoQPmeaikX?= =?us-ascii?Q?IfqT/7M5fwe33MCcLrYAP55GafnTn/HKNb7OK+Y4t7yx4VJD6b6RVGO8DDM3?= =?us-ascii?Q?6meF/H3ewJY+yhrm9F1KvFSEcVfxDQds5U1mt91J7HfF4AoStHeBZRVJu6Xm?= =?us-ascii?Q?T5tC0/oqYOTYuyp3UVoNrnyk/KE0hWSNPxvVtpUpNXOm0OAXey1OTs7pmMnt?= =?us-ascii?Q?Ajqx9yPECjIhnEVoDfOMkYRMi3puO6mfqcHA1Mffuesu8SJiFoMnUfNcqfee?= =?us-ascii?Q?yqHt5WsNlWhgpGcGoBrV5xhElj0OggXRJJ8VoENb4BjhBxJw/MKP25y5U+7U?= =?us-ascii?Q?uynVPB4sQZPhiOlBHsei9ptGT5CmEGbKUaAHYP1XwyCGEJwiJ1xD1S5QUc5x?= =?us-ascii?Q?HGkDBPYjyCVbw6pfy12d+uztI2MrU31v6wiowEOnohAR8VdeCq+h+Yzt936/?= =?us-ascii?Q?6rlUCsNG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3zqWFnrNPfiSRLQZHZsyV58Umtg9CknwlqjghuyUlHihbBPpMn/+AFn80sw==; 24:CAPVQPDOzjsb3PtqsmAMfahk3fmoctgj+18K0TJvahJU0N2isPCBnB7/EgfIUhK72BQmjUnNKQVRJBrta9Ap99+TQRhWvpA4+Sn/L4hbx/0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0802MB2555; 7:NUNJJZELtDg2qILBOI4SgkRgH/GWlbK9lpNeqEtn9vgESEkgAonNdayskeRR9iOIJejLRmQeRqOEdTo+C3hRPf0ZCma6ow8zagm1h13oDY3z2wr6eeRJwxO5D5+PLLygvB+V1AmSqQRL++7XqUrlO0qHFWsxLprXrxRFDaq5aHvwC0LiHmv97YklF+HXjpMM0GUGP6uAaWplw/9TIpjQbhxPx1G5C2T1+eouoMuwPVtYigqhdMeBNe1ewvz/NrEGzYsSNDwQ2P/MY4ecJmdTtzZF1K3nDJu8/yH9CMYdpDy1h485mXoihyWDyuXo/m9n1SrFWJbBdXcVQ9V89hgw0JxKXpuFfpvtOoWIqSKnJHA=; 20:1C8IEGmbSGVgKdH2vVAoP2AF/1sH1PN9feH0NmOTnInbiZBjTXKVnskJjeiCATANoqsLNlIPCBBtpWn2ljzD2f78yjRd4xIUuAjoWoLofbHy+sJdgW+w3joG6SUZpiHgJy+r87nydMG3tMi8CVz46A9MnbLQPf1dLYy+61OKXuQ= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2016 14:29:51.6348 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2555 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Herbert Xu commit a5596d6332787fd383b3b5427b41f94254430827 upstream. This patch adds a way for ahash users to determine whether a key is required by a crypto_ahash transform. Cc: stable@vger.kernel.org Signed-off-by: Herbert Xu Signed-off-by: Andrey Ryabinin --- crypto/ahash.c | 5 ++++- crypto/shash.c | 4 +++- include/crypto/hash.h | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crypto/ahash.c b/crypto/ahash.c index bcd5efc..781a8a7 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -370,6 +370,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) struct ahash_alg *alg = crypto_ahash_alg(hash); hash->setkey = ahash_nosetkey; + hash->has_setkey = false; hash->export = ahash_no_export; hash->import = ahash_no_import; @@ -382,8 +383,10 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) hash->finup = alg->finup ?: ahash_def_finup; hash->digest = alg->digest; - if (alg->setkey) + if (alg->setkey) { hash->setkey = alg->setkey; + hash->has_setkey = true; + } if (alg->export) hash->export = alg->export; if (alg->import) diff --git a/crypto/shash.c b/crypto/shash.c index 929058a..8e4256a 100644 --- a/crypto/shash.c +++ b/crypto/shash.c @@ -354,8 +354,10 @@ int crypto_init_shash_ops_async(struct crypto_tfm *tfm) crt->finup = shash_async_finup; crt->digest = shash_async_digest; - if (alg->setkey) + if (alg->setkey) { crt->setkey = shash_async_setkey; + crt->has_setkey = true; + } if (alg->export) crt->export = shash_async_export; if (alg->import) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index 26cb1eb..c8c7987 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -94,6 +94,7 @@ struct crypto_ahash { unsigned int keylen); unsigned int reqsize; + bool has_setkey; struct crypto_tfm base; }; @@ -181,6 +182,11 @@ static inline void *ahash_request_ctx(struct ahash_request *req) int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key, unsigned int keylen); +static inline bool crypto_ahash_has_setkey(struct crypto_ahash *tfm) +{ + return tfm->has_setkey; +} + int crypto_ahash_finup(struct ahash_request *req); int crypto_ahash_final(struct ahash_request *req); int crypto_ahash_digest(struct ahash_request *req);