Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1645225 > unrolled thread

[PATCH v2 0/9] crypto: add HMAC IPAD/OPAD constant

Started byCorentin Labbe <clabbe.montjoie@gmail.com>
First post2017-05-19 09:00 +0200
Last post2017-05-23 07:10 +0200
Articles 13 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/9] crypto: add HMAC IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 9/9] crypto: ccp - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 7/9] crypto: qat - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 5/9] crypto: mv_cesa - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 2/9] crypto: brcm - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
      Re: [PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-05-19 11:20 +0200
    [PATCH v2 6/9] crypto: omap-sham - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 3/9] crypto: ixp4xx - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 1/9] crypto: add hmac IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
    [PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-05-19 09:00 +0200
      Re: [PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant Matthias Brugger <matthias.bgg@gmail.com> - 2017-05-19 11:20 +0200
    Re: [PATCH v2 0/9] crypto: add HMAC IPAD/OPAD constant Herbert Xu <herbert@gondor.apana.org.au> - 2017-05-23 07:10 +0200

#1645225 — [PATCH v2 0/9] crypto: add HMAC IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 0/9] crypto: add HMAC IPAD/OPAD constant
Message-ID<tIK3f-6Oj-1@gated-at.bofh.it>
Hello

Many HMAC users directly use directly 0x36/0x5c values.
It's better with crypto to use a name instead of directly some crypto constant.

Changes since v1:
- Moved constant to include/crypto/hmac.h
- Added <crypto/hmac.h> to includes

Corentin Labbe (9):
  crypto: add hmac IPAD/OPAD constant
  crypto: brcm - Use IPAD/OPAD constant
  crypto: ixp4xx - Use IPAD/OPAD constant
  crypto: marvell - Use IPAD/OPAD constant
  crypto: mv_cesa - Use IPAD/OPAD constant
  crypto: omap-sham - Use IPAD/OPAD constant
  crypto: qat - Use IPAD/OPAD constant
  crypto: mediatek - Use IPAD/OPAD constant
  crypto: ccp - Use IPAD/OPAD constant

 crypto/hmac.c                            | 5 +++--
 drivers/crypto/bcm/cipher.c              | 5 +++--
 drivers/crypto/ccp/ccp-crypto-sha.c      | 5 +++--
 drivers/crypto/ixp4xx_crypto.c           | 3 +--
 drivers/crypto/marvell/hash.c            | 5 +++--
 drivers/crypto/mediatek/mtk-sha.c        | 5 +++--
 drivers/crypto/mv_cesa.c                 | 5 +++--
 drivers/crypto/omap-sham.c               | 5 +++--
 drivers/crypto/qat/qat_common/qat_algs.c | 5 +++--
 include/crypto/hmac.h                    | 7 +++++++
 10 files changed, 32 insertions(+), 18 deletions(-)
 create mode 100644 include/crypto/hmac.h

-- 
2.13.0

[toc] | [next] | [standalone]


#1645226 — [PATCH v2 9/9] crypto: ccp - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 9/9] crypto: ccp - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-3@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/ccp/ccp-crypto-sha.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c
index 6b46eea94932..ce97b3868f4a 100644
--- a/drivers/crypto/ccp/ccp-crypto-sha.c
+++ b/drivers/crypto/ccp/ccp-crypto-sha.c
@@ -18,6 +18,7 @@
 #include <linux/crypto.h>
 #include <crypto/algapi.h>
 #include <crypto/hash.h>
+#include <crypto/hmac.h>
 #include <crypto/internal/hash.h>
 #include <crypto/sha.h>
 #include <crypto/scatterwalk.h>
@@ -308,8 +309,8 @@ static int ccp_sha_setkey(struct crypto_ahash *tfm, const u8 *key,
 	}
 
 	for (i = 0; i < block_size; i++) {
-		ctx->u.sha.ipad[i] = ctx->u.sha.key[i] ^ 0x36;
-		ctx->u.sha.opad[i] = ctx->u.sha.key[i] ^ 0x5c;
+		ctx->u.sha.ipad[i] = ctx->u.sha.key[i] ^ HMAC_IPAD_VALUE;
+		ctx->u.sha.opad[i] = ctx->u.sha.key[i] ^ HMAC_OPAD_VALUE;
 	}
 
 	sg_init_one(&ctx->u.sha.opad_sg, ctx->u.sha.opad, block_size);
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645228 — [PATCH v2 7/9] crypto: qat - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 7/9] crypto: qat - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-7@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/qat/qat_common/qat_algs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c
index 20f35df8a01f..5b5efcc52cb5 100644
--- a/drivers/crypto/qat/qat_common/qat_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_algs.c
@@ -51,6 +51,7 @@
 #include <crypto/aes.h>
 #include <crypto/sha.h>
 #include <crypto/hash.h>
+#include <crypto/hmac.h>
 #include <crypto/algapi.h>
 #include <crypto/authenc.h>
 #include <linux/dma-mapping.h>
@@ -178,8 +179,8 @@ static int qat_alg_do_precomputes(struct icp_qat_hw_auth_algo_blk *hash,
 	for (i = 0; i < block_size; i++) {
 		char *ipad_ptr = ipad + i;
 		char *opad_ptr = opad + i;
-		*ipad_ptr ^= 0x36;
-		*opad_ptr ^= 0x5C;
+		*ipad_ptr ^= HMAC_IPAD_VALUE;
+		*opad_ptr ^= HMAC_OPAD_VALUE;
 	}
 
 	if (crypto_shash_init(shash))
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645232 — [PATCH v2 5/9] crypto: mv_cesa - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 5/9] crypto: mv_cesa - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-15@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/mv_cesa.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/mv_cesa.c b/drivers/crypto/mv_cesa.c
index 451fa18c1c7b..bf25f415eea6 100644
--- a/drivers/crypto/mv_cesa.c
+++ b/drivers/crypto/mv_cesa.c
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/clk.h>
+#include <crypto/hmac.h>
 #include <crypto/internal/hash.h>
 #include <crypto/sha.h>
 #include <linux/of.h>
@@ -822,8 +823,8 @@ static int mv_hash_setkey(struct crypto_ahash *tfm, const u8 * key,
 		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;
 		}
 
 		rc = crypto_shash_init(shash) ? :
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645233 — [PATCH v2 2/9] crypto: brcm - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 2/9] crypto: brcm - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-17@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/bcm/cipher.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
index cc0d5b98006e..61393dc70b0b 100644
--- a/drivers/crypto/bcm/cipher.c
+++ b/drivers/crypto/bcm/cipher.c
@@ -36,6 +36,7 @@
 #include <crypto/internal/aead.h>
 #include <crypto/aes.h>
 #include <crypto/des.h>
+#include <crypto/hmac.h>
 #include <crypto/sha.h>
 #include <crypto/md5.h>
 #include <crypto/authenc.h>
@@ -2510,8 +2511,8 @@ static int ahash_hmac_setkey(struct crypto_ahash *ahash, const u8 *key,
 		memcpy(ctx->opad, ctx->ipad, blocksize);
 
 		for (index = 0; index < blocksize; index++) {
-			ctx->ipad[index] ^= 0x36;
-			ctx->opad[index] ^= 0x5c;
+			ctx->ipad[index] ^= HMAC_IPAD_VALUE;
+			ctx->opad[index] ^= HMAC_OPAD_VALUE;
 		}
 
 		flow_dump("  ipad: ", ctx->ipad, blocksize);
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645235 — [PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-27@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/marvell/hash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
index 77c0fb936f47..e61b08566093 100644
--- a/drivers/crypto/marvell/hash.c
+++ b/drivers/crypto/marvell/hash.c
@@ -12,6 +12,7 @@
  * by the Free Software Foundation.
  */
 
+#include <crypto/hmac.h>
 #include <crypto/md5.h>
 #include <crypto/sha.h>
 
@@ -1164,8 +1165,8 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req,
 	memcpy(opad, ipad, blocksize);
 
 	for (i = 0; i < blocksize; i++) {
-		ipad[i] ^= 0x36;
-		opad[i] ^= 0x5c;
+		ipad[i] ^= HMAC_IPAD_VALUE;
+		opad[i] ^= HMAC_OPAD_VALUE;
 	}
 
 	return 0;
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645447 — Re: [PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant

FromBoris Brezillon <boris.brezillon@free-electrons.com>
Date2017-05-19 11:20 +0200
SubjectRe: [PATCH v2 4/9] crypto: marvell - Use IPAD/OPAD constant
Message-ID<tIMeJ-8ro-1@gated-at.bofh.it>
In reply to#1645235
On Fri, 19 May 2017 08:53:26 +0200
Corentin Labbe <clabbe.montjoie@gmail.com> wrote:

> This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
> define.
> 
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>

Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
>  drivers/crypto/marvell/hash.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c
> index 77c0fb936f47..e61b08566093 100644
> --- a/drivers/crypto/marvell/hash.c
> +++ b/drivers/crypto/marvell/hash.c
> @@ -12,6 +12,7 @@
>   * by the Free Software Foundation.
>   */
>  
> +#include <crypto/hmac.h>
>  #include <crypto/md5.h>
>  #include <crypto/sha.h>
>  
> @@ -1164,8 +1165,8 @@ static int mv_cesa_ahmac_pad_init(struct ahash_request *req,
>  	memcpy(opad, ipad, blocksize);
>  
>  	for (i = 0; i < blocksize; i++) {
> -		ipad[i] ^= 0x36;
> -		opad[i] ^= 0x5c;
> +		ipad[i] ^= HMAC_IPAD_VALUE;
> +		opad[i] ^= HMAC_OPAD_VALUE;
>  	}
>  
>  	return 0;

[toc] | [prev] | [next] | [standalone]


#1645236 — [PATCH v2 6/9] crypto: omap-sham - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 6/9] crypto: omap-sham - Use IPAD/OPAD constant
Message-ID<tIK3g-6Oj-25@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/omap-sham.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index d0b16e5e4ee5..1864a57caaa4 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -41,6 +41,7 @@
 #include <crypto/algapi.h>
 #include <crypto/sha.h>
 #include <crypto/hash.h>
+#include <crypto/hmac.h>
 #include <crypto/internal/hash.h>
 
 #define MD5_DIGEST_SIZE			16
@@ -1326,8 +1327,8 @@ static int omap_sham_setkey(struct crypto_ahash *tfm, const u8 *key,
 		memcpy(bctx->opad, bctx->ipad, bs);
 
 		for (i = 0; i < bs; i++) {
-			bctx->ipad[i] ^= 0x36;
-			bctx->opad[i] ^= 0x5c;
+			bctx->ipad[i] ^= HMAC_IPAD_VALUE;
+			bctx->opad[i] ^= HMAC_OPAD_VALUE;
 		}
 	}
 
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645237 — [PATCH v2 3/9] crypto: ixp4xx - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 3/9] crypto: ixp4xx - Use IPAD/OPAD constant
Message-ID<tIK3h-6Oj-29@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/ixp4xx_crypto.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
index 771dd26c7076..427cbe012729 100644
--- a/drivers/crypto/ixp4xx_crypto.c
+++ b/drivers/crypto/ixp4xx_crypto.c
@@ -23,6 +23,7 @@
 #include <crypto/ctr.h>
 #include <crypto/des.h>
 #include <crypto/aes.h>
+#include <crypto/hmac.h>
 #include <crypto/sha.h>
 #include <crypto/algapi.h>
 #include <crypto/internal/aead.h>
@@ -90,8 +91,6 @@
 #define CTL_FLAG_PERFORM_AEAD	0x0008
 #define CTL_FLAG_MASK		0x000f
 
-#define HMAC_IPAD_VALUE   0x36
-#define HMAC_OPAD_VALUE   0x5C
 #define HMAC_PAD_BLOCKLEN SHA1_BLOCK_SIZE
 
 #define MD5_DIGEST_SIZE   16
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645238 — [PATCH v2 1/9] crypto: add hmac IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 1/9] crypto: add hmac IPAD/OPAD constant
Message-ID<tIK3h-6Oj-31@gated-at.bofh.it>
In reply to#1645225
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 <clabbe.montjoie@gmail.com>
---
 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 <crypto/hmac.h>
 #include <crypto/internal/hash.h>
 #include <crypto/scatterwalk.h>
 #include <linux/err.h>
@@ -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 */
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645240 — [PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant

FromCorentin Labbe <clabbe.montjoie@gmail.com>
Date2017-05-19 09:00 +0200
Subject[PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant
Message-ID<tIK3h-6Oj-35@gated-at.bofh.it>
In reply to#1645225
This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
define.

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
---
 drivers/crypto/mediatek/mtk-sha.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/mediatek/mtk-sha.c b/drivers/crypto/mediatek/mtk-sha.c
index 2226f12d1c7a..5f4f845adbb8 100644
--- a/drivers/crypto/mediatek/mtk-sha.c
+++ b/drivers/crypto/mediatek/mtk-sha.c
@@ -12,6 +12,7 @@
  * Some ideas are from atmel-sha.c and omap-sham.c drivers.
  */
 
+#include <crypto/hmac.h>
 #include <crypto/sha.h>
 #include "mtk-platform.h"
 
@@ -825,8 +826,8 @@ static int mtk_sha_setkey(struct crypto_ahash *tfm, const u8 *key,
 	memcpy(bctx->opad, bctx->ipad, bs);
 
 	for (i = 0; i < bs; i++) {
-		bctx->ipad[i] ^= 0x36;
-		bctx->opad[i] ^= 0x5c;
+		bctx->ipad[i] ^= HMAC_IPAD_VALUE;
+		bctx->opad[i] ^= HMAC_OPAD_VALUE;
 	}
 
 	return 0;
-- 
2.13.0

[toc] | [prev] | [next] | [standalone]


#1645451 — Re: [PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant

FromMatthias Brugger <matthias.bgg@gmail.com>
Date2017-05-19 11:20 +0200
SubjectRe: [PATCH v2 8/9] crypto: mediatek - Use IPAD/OPAD constant
Message-ID<tIMeK-8ro-13@gated-at.bofh.it>
In reply to#1645240

On 19/05/17 08:53, Corentin Labbe wrote:
> This patch simply replace all occurrence of HMAC IPAD/OPAD value by their
> define.
> 
> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> ---

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

>   drivers/crypto/mediatek/mtk-sha.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/mediatek/mtk-sha.c b/drivers/crypto/mediatek/mtk-sha.c
> index 2226f12d1c7a..5f4f845adbb8 100644
> --- a/drivers/crypto/mediatek/mtk-sha.c
> +++ b/drivers/crypto/mediatek/mtk-sha.c
> @@ -12,6 +12,7 @@
>    * Some ideas are from atmel-sha.c and omap-sham.c drivers.
>    */
>   
> +#include <crypto/hmac.h>
>   #include <crypto/sha.h>
>   #include "mtk-platform.h"
>   
> @@ -825,8 +826,8 @@ static int mtk_sha_setkey(struct crypto_ahash *tfm, const u8 *key,
>   	memcpy(bctx->opad, bctx->ipad, bs);
>   
>   	for (i = 0; i < bs; i++) {
> -		bctx->ipad[i] ^= 0x36;
> -		bctx->opad[i] ^= 0x5c;
> +		bctx->ipad[i] ^= HMAC_IPAD_VALUE;
> +		bctx->opad[i] ^= HMAC_OPAD_VALUE;
>   	}
>   
>   	return 0;
> 

[toc] | [prev] | [next] | [standalone]


#1647633

FromHerbert Xu <herbert@gondor.apana.org.au>
Date2017-05-23 07:10 +0200
Message-ID<tKaeZ-77l-13@gated-at.bofh.it>
In reply to#1645225
On Fri, May 19, 2017 at 08:53:22AM +0200, Corentin Labbe wrote:
> Hello
> 
> Many HMAC users directly use directly 0x36/0x5c values.
> It's better with crypto to use a name instead of directly some crypto constant.
> 
> Changes since v1:
> - Moved constant to include/crypto/hmac.h
> - Added <crypto/hmac.h> to includes
> 
> Corentin Labbe (9):
>   crypto: add hmac IPAD/OPAD constant
>   crypto: brcm - Use IPAD/OPAD constant
>   crypto: ixp4xx - Use IPAD/OPAD constant
>   crypto: marvell - Use IPAD/OPAD constant
>   crypto: mv_cesa - Use IPAD/OPAD constant
>   crypto: omap-sham - Use IPAD/OPAD constant
>   crypto: qat - Use IPAD/OPAD constant
>   crypto: mediatek - Use IPAD/OPAD constant
>   crypto: ccp - Use IPAD/OPAD constant

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web