From patchwork Fri May 19 06:53:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 9735931 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 425F3601C2 for ; Fri, 19 May 2017 06:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DB93288A6 for ; Fri, 19 May 2017 06:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3176D288A9; Fri, 19 May 2017 06:57:14 +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 BE02B288A6 for ; Fri, 19 May 2017 06:57:13 +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:References: In-Reply-To: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:List-Owner; bh=BH8bcfJngBSeS4hxqVkVX3JI9PIEm3dvFc6yx+QzZgs=; b=oYYJreUJEKwHunmiEOuYoXGwha xB7Fq0NHtSY9Cz07Q+pkEz2BgAXTrIW4ap5gy5HykqM5YjPBWR+C7kvHt8gF20RAGn2uGU1Ju+ffB VBGTX9OWnpnB+CqTivtUu7SLRmK6CBfGO7EWP0sjYEZ14q75lwRaAiw69/rfSulVhh7SArMY9rQEi BiqM8SKeuIdWbZ5x3pFuSX/V/t+jT7K7osgNoV7+MT1OnjyIqoIvmoN/9AH3IuuwHmh1k9DKGBStj G04uIcJLBKZJPBLCxJ2Pd20iSp/e/5e+y99AlNHxOygbJQkX0aUMSAeoK4A2yU/ZpLHYntCXmUqz6 aoGEsPlw==; 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 1dBbqa-00054j-2x; Fri, 19 May 2017 06:57:12 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dBbpY-0004Ql-SB; Fri, 19 May 2017 06:56:10 +0000 Received: by mail-wr0-x241.google.com with SMTP id w50so1740030wrc.0; Thu, 18 May 2017 23:55:48 -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:in-reply-to:references; bh=L5MgWCt74MTi8D4U+Y58MO3eVAMOH2hA2K2rI78uSXE=; b=uCByj0NSNiQdT8iHB4Nm4SvoCYhTiBNBZttNBy4YAoGaeNveEMpFsy2biQpaR/C0+u Yq+jme6XFjAC7cG4XsfeUz1xFFBYtUmbAJwlyxXn7cePiVZxYzfrbtJqB7quRboXRZmk HJRQwlWOlXh7nUIrRpPVm4vmEuezhCd3NRsfr0m9n90uiUEH70GS0kN4/1UeO/QudiJT AoVFr9ZzYw4Z2Wx7ETbZsHqWr9sV2G8+I0sX3eF+Ox+dh4qBopSYSbzqHNHemVc9xEWq SwOx4BAd1WWmA6Aykywd4XkgbFL5BL8p3u/cNtFUubTeMgbuTLrv5uN9FwNnGk7RNlIo JhLw== 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:in-reply-to :references; bh=L5MgWCt74MTi8D4U+Y58MO3eVAMOH2hA2K2rI78uSXE=; b=mcHkZ5WkFJ6olTNKIwkF1UJ26jo7GR2E54Wr4Xu0HOeSYW4GPbZPJJ9UGB++eu1tzN v02qqLKn8y+xgesw8SJo6sejKUFHDgbj3zAFyd/k+CIUChQEOULHG/kd0/xFz4R6znno icYJEOEyN7f1AAJhaguk4XpFMOYsRVd58/HLL2Yx5JRknLsYPxRRnI6EnBTFaqhMbb1v 1wZgTHU1Dg3xs2Fj4p9+nkPgn+xtjsLrjk3G+hhSDbGu6x5TPe3G/UXYlvhgNFcezCsP h6oUBGYWKAjb9rVPRWtpqjwJgeFRDiy4D2yY7jyHPe6ZezzwxX1jPY/6PlXkCZaHs7O7 B1gQ== X-Gm-Message-State: AODbwcBe3Yy/pLKwVDoYYh2IQ+HOoHGU/akeGFrwENNYPQWHbRdS/r9a 8N7tTpG9fmcsNw== X-Received: by 10.223.149.68 with SMTP id 62mr1655724wrs.7.1495176947264; Thu, 18 May 2017 23:55:47 -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 1sm3256734wrw.32.2017.05.18.23.55.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 May 2017 23:55:46 -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 v2 1/9] crypto: add hmac IPAD/OPAD constant Date: Fri, 19 May 2017 08:53:23 +0200 Message-Id: <20170519065331.27670-2-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170519065331.27670-1-clabbe.montjoie@gmail.com> References: <20170519065331.27670-1-clabbe.montjoie@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170518_235609_057374_9B5AD9C7 X-CRM114-Status: GOOD ( 14.08 ) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=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 in a new include file "crypto/hmac.h" and use them in crypto/hmac.c Signed-off-by: Corentin Labbe --- crypto/hmac.c | 5 +++-- include/crypto/hmac.h | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 include/crypto/hmac.h diff --git a/crypto/hmac.c b/crypto/hmac.c index 72e38c098bb3..92871dc2a63e 100644 --- a/crypto/hmac.c +++ b/crypto/hmac.c @@ -16,6 +16,7 @@ * */ +#include #include #include #include @@ -74,8 +75,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/hmac.h b/include/crypto/hmac.h new file mode 100644 index 000000000000..ef09f7938204 --- /dev/null +++ b/include/crypto/hmac.h @@ -0,0 +1,7 @@ +#ifndef _CRYPTO_HMAC_H +#define _CRYPTO_HMAC_H + +#define HMAC_IPAD_VALUE 0x36 +#define HMAC_OPAD_VALUE 0x5c + +#endif /* _CRYPTO_HMAC_H */