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: 9735907 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 4116B601C2 for ; Fri, 19 May 2017 06:55:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E345288A6 for ; Fri, 19 May 2017 06:55:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30E1B288A9; Fri, 19 May 2017 06:55:56 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 C322E288A6 for ; Fri, 19 May 2017 06:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752253AbdESGzw (ORCPT ); Fri, 19 May 2017 02:55:52 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34169 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752137AbdESGzu (ORCPT ); Fri, 19 May 2017 02:55:50 -0400 Received: by mail-wr0-f193.google.com with SMTP id 6so1741122wrb.1; 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=G3Qn8VcRb6PrQdfrUy8rJ/dVSK647LZ62supO//lr/foyikW1dPZXzPdaJ6R4QN1+8 2+5e7R+zVUM7Tk8ilQBUK9rRA22Yvyqz7R4Qe15GdLzuIy2pdGPDGLjCF+6kzEfPoWf7 nl7jU6f8MXJKCmncxLJtw20qqBe/cGGGolKRlPkokzH4v9aJted2Ep+SRQiHczWpDpnB d02po1Wgb/CuNy5bUO1zHmdFc8J/PeN5TIyrk+7s2w0Hdtur2CbKbVPFuCkFsrA79nZl NCv++fK8sGr1QW+0HJW8zDrRuWNvGkwX9K0XUvoBeugx6Ro7+Wok1Gb55L8oaoBuDoZX WtRQ== X-Gm-Message-State: AODbwcDLYiaJ/iUbVF1jqj85riq+IoVZvY8KeV2MQYfkwTuyCbR45k6x uzwXlMl73nJw4Q== 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 Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, qat-linux@intel.com, Corentin Labbe 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> 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 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 */