From patchwork Mon Apr 24 14:16:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9696481 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 1EBA0601AE for ; Mon, 24 Apr 2017 14:19:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F5E628329 for ; Mon, 24 Apr 2017 14:19:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0396F2835D; Mon, 24 Apr 2017 14:19:09 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8916A28329 for ; Mon, 24 Apr 2017 14:19:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=74DkHOTv2mWvDUoddGiVt8r3AK91+zu6xBh0cj1O4cQ=; b=HHS uwR701FTNv4GkOuLYmB9Frk9ntF7qr4WltzW9hXLPqerF1recTeRMlK8FukRE59t+dRCHbiwCcoE4 RFNRRVgbSuXARFBEhJ+vAP3KpPm1dl90lfpqiINbg53qCaSrIBGALgn6G0tyivWdqVZWULSPCbc3J v6A+PslVeZ2Os7JBt6pL/ZFwH7/pg+sOVaY9+O860Fq1IX+c5KIAFimr8XH067SfKWLOkYOIlQZZq FyJGg3VF2nXAQNJ8s/hy1VA5c18bMyKOCTQFAa1xcQue0BUeBp7qGFQJh5VH13nwrFHPUWtQZ4whR pjrcLaI0lrh78tElu/2NRjrfKa7BSsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2epW-0006Zt-Rd; Mon, 24 Apr 2017 14:19:06 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2epT-0006Wk-GE; Mon, 24 Apr 2017 14:19:05 +0000 Received: by mail-wr0-x242.google.com with SMTP id w50so16563528wrc.0; Mon, 24 Apr 2017 07:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uKVqcaiQETQzX2AYnpJrrD8fS5ALPhg08Q1KNLU39C0=; b=euOh/ho/DOt0I0WuZj8hJLP7QE/Yx1vmYcJDT9mlXHs4PLYKVjr5VgfvWu5gYR54yk l5PfX/KqcSES4LwMF+PLwqd+7MY8hlHxwKJmaRRaBcHM5VOthv690r+gPdq1bwUUw9IC Us77SgTL+0rCihLTA3W3rFQw3k+5v9CaSOND2RiXjDw4yRfynG65+IWzGZIavFKHZIum 4lIhmmI1khY6Shm8QMvLstuTaZ3GnXX2kIBSVBDt200WQQn0T98AWlCsf/Vsktw5PS2H i8tjZmp8CS3aj8r2HgKp/K0mFGcGRV1FwMqBxiF0CW0rpiVxHuGfp1I8B5O3qFXsLSYW oOSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uKVqcaiQETQzX2AYnpJrrD8fS5ALPhg08Q1KNLU39C0=; b=ulfTfIBJ6y2pNRSAGMu4v8mYS+MrRb+C1Oj60nKjD9GPxzp6Qw/GCkaDG8YRbdJZCx tT3oLl5QStRQwbg0NUsRKGB7zEEucUiZUc83/XHFK4nuPRaXertTN+zZQqmY2xvyP1lt +gRGZOkjabBsDSQTpqHA1ILjagzhY5xsP2Cnh88T9QBW6UyeHSq7oE2EwVcz+vuBHP8J tqbjYYFq6wbDFqNE7+Lw3H1OxfhBLLfLHLJOl8SIC6d0PSQcx7MMVryNDnQ9G8h5Y178 Htfv6VJocGNJdA5UUg/iQ9CQylAm4tmOn9/mQrUIy25SeY9x5SKprLpb0hyTAx13u1TO PR8w== X-Gm-Message-State: AN3rC/7AalieS3xiul5qIx4BI+lI26K6+mZW534WRPSBoWIqi4lMykTv EEG1Q/WBuYRjKA== X-Received: by 10.223.148.7 with SMTP id 7mr6029298wrq.65.1493043521777; Mon, 24 Apr 2017 07:18:41 -0700 (PDT) Received: from Red.local (LFbn-1-7035-57.w90-116.abo.wanadoo.fr. [90.116.208.57]) by smtp.googlemail.com with ESMTPSA id q140sm548033wmb.14.2017.04.24.07.18.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Apr 2017 07:18:41 -0700 (PDT) From: Corentin Labbe To: herbert@gondor.apana.org.au, davem@davemloft.net, thomas.lendacky@amd.com, gary.hook@amd.com, boris.brezillon@free-electrons.com, arno@natisbad.org, matthias.bgg@gmail.com, giovanni.cabiddu@intel.com, salvatore.benedetto@intel.com Subject: [PATCH 1/9] crypto: add hmac IPAD/OPAD constant Date: Mon, 24 Apr 2017 16:16:21 +0200 Message-Id: <20170424141629.27155-1-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.10.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170424_071903_707934_78E7E8B8 X-CRM114-Status: UNSURE ( 9.56 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qat-linux@intel.com, linux-kernel@vger.kernel.org, Corentin Labbe , linux-crypto@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Many HMAC users directly use directly 0x36/0x5c values. It's better with crypto to use a name instead of directly some crypto constant. This patch simply add HMAC_IPAD_VALUE/HMAC_OPAD_VALUE defines. Signed-off-by: Corentin Labbe --- crypto/hmac.c | 4 ++-- include/crypto/hash.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/crypto/hmac.c b/crypto/hmac.c index 72e38c0..4a997ce 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -74,8 +74,8 @@ static int hmac_setkey(struct crypto_shash *parent, memcpy(opad, ipad, bs); for (i = 0; i < bs; i++) { - ipad[i] ^= 0x36; - opad[i] ^= 0x5c; + ipad[i] ^= HMAC_IPAD_VALUE; + opad[i] ^= HMAC_OPAD_VALUE; } return crypto_shash_init(shash) ?: diff --git a/include/crypto/hash.h b/include/crypto/hash.h index b5727bc..0f51ff1 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -922,4 +922,7 @@ static inline void shash_desc_zero(struct shash_desc *desc) sizeof(*desc) + crypto_shash_descsize(desc->tfm)); } +#define HMAC_IPAD_VALUE 0x36 +#define HMAC_OPAD_VALUE 0x5c + #endif /* _CRYPTO_HASH_H */