public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE
@ 2015-10-14 19:15 LABBE Corentin
  2015-10-14 20:44 ` Thomas Gleixner
  2015-10-16 16:04 ` Tim Chen
  0 siblings, 2 replies; 5+ messages in thread
From: LABBE Corentin @ 2015-10-14 19:15 UTC (permalink / raw)
  To: ameenali023, bp, clabbe.montjoie, dan.carpenter, davem, firogm,
	herbert, hpa, mingo, minipli, smueller, tglx, tim.c.chen, x86
  Cc: linux-crypto, linux-kernel

The sha x86 crypto code use two define for the same thing:
NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
Replace them by SHA1_DIGEST_SIZE/4

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 arch/x86/crypto/sha-mb/sha1_mb.c    | 2 +-
 arch/x86/crypto/sha-mb/sha_mb_ctx.h | 1 -
 arch/x86/crypto/sha-mb/sha_mb_mgr.h | 6 ++----
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c
index a841e97..791cbfa 100644
--- a/arch/x86/crypto/sha-mb/sha1_mb.c
+++ b/arch/x86/crypto/sha-mb/sha1_mb.c
@@ -104,7 +104,7 @@ static asmlinkage struct job_sha1* (*sha1_job_mgr_get_comp_job)(struct sha1_mb_m
 
 inline void sha1_init_digest(uint32_t *digest)
 {
-	static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
+	static const uint32_t initial_digest[SHA1_DIGEST_SIZE / 4] = {SHA1_H0,
 					SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
 	memcpy(digest, initial_digest, sizeof(initial_digest));
 }
diff --git a/arch/x86/crypto/sha-mb/sha_mb_ctx.h b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
index e36069d..9fd36eb5 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_ctx.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
@@ -94,7 +94,6 @@ enum hash_ctx_error {
 
 
 /* Hash Constants and Typedefs */
-#define SHA1_DIGEST_LENGTH          5
 #define SHA1_LOG2_BLOCK_SIZE        6
 
 #define SHA1_PADLENGTHFIELD_SIZE    8
diff --git a/arch/x86/crypto/sha-mb/sha_mb_mgr.h b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
index 08ad1a9..3ff337c 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_mgr.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
@@ -54,11 +54,9 @@
 #ifndef __SHA_MB_MGR_H
 #define __SHA_MB_MGR_H
 
-
+#include <crypto/sha.h>
 #include <linux/types.h>
 
-#define NUM_SHA1_DIGEST_WORDS 5
-
 enum job_sts {	STS_UNKNOWN = 0,
 		STS_BEING_PROCESSED = 1,
 		STS_COMPLETED = 2,
@@ -69,7 +67,7 @@ enum job_sts {	STS_UNKNOWN = 0,
 struct job_sha1 {
 	u8	*buffer;
 	u32	len;
-	u32	result_digest[NUM_SHA1_DIGEST_WORDS] __aligned(32);
+	u32	result_digest[SHA1_DIGEST_SIZE / 4] __aligned(32);
 	enum	job_sts status;
 	void	*user_data;
 };
-- 
2.4.9


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE
  2015-10-14 19:15 [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE LABBE Corentin
@ 2015-10-14 20:44 ` Thomas Gleixner
  2015-10-16 16:04 ` Tim Chen
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2015-10-14 20:44 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: ameenali023, bp, dan.carpenter, davem, firogm, herbert, hpa,
	mingo, minipli, smueller, tim.c.chen, x86, linux-crypto,
	linux-kernel

On Wed, 14 Oct 2015, LABBE Corentin wrote:

> The sha x86 crypto code use two define for the same thing:
> NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
> Replace them by SHA1_DIGEST_SIZE/4

That's wrong. Use only one for the number of words and make the define
so it's derived from the LENGTH.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE
  2015-10-14 19:15 [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE LABBE Corentin
  2015-10-14 20:44 ` Thomas Gleixner
@ 2015-10-16 16:04 ` Tim Chen
  2015-10-29  7:51   ` LABBE Corentin
  1 sibling, 1 reply; 5+ messages in thread
From: Tim Chen @ 2015-10-16 16:04 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: ameenali023, bp, dan.carpenter, davem, firogm, herbert, hpa,
	mingo, minipli, smueller, tglx, x86, linux-crypto, linux-kernel

On Wed, 2015-10-14 at 21:15 +0200, LABBE Corentin wrote:
> The sha x86 crypto code use two define for the same thing:
> NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
> Replace them by SHA1_DIGEST_SIZE/4

Thanks.  Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE
  2015-10-16 16:04 ` Tim Chen
@ 2015-10-29  7:51   ` LABBE Corentin
  2015-10-29 16:16     ` Tim Chen
  0 siblings, 1 reply; 5+ messages in thread
From: LABBE Corentin @ 2015-10-29  7:51 UTC (permalink / raw)
  To: Tim Chen, tglx
  Cc: ameenali023, bp, dan.carpenter, davem, firogm, herbert, hpa,
	mingo, minipli, smueller, tglx, x86, linux-crypto, linux-kernel

On Fri, Oct 16, 2015 at 09:04:58AM -0700, Tim Chen wrote:
> On Wed, 2015-10-14 at 21:15 +0200, LABBE Corentin wrote:
> > The sha x86 crypto code use two define for the same thing:
> > NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
> > Replace them by SHA1_DIGEST_SIZE/4
> 
> Thanks.  Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
> > 
> > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> 

Hello

Thanks for your ack, but Thomas Gleixner in the same time NACK this patch.
Just in case I attach the new patch, for permit you to decide which one you prefer.

Regards

--8<--
>From 7439bc57d95de49a510c0eb5d328dec10a3c6689 Mon Sep 17 00:00:00 2001
From: LABBE Corentin <clabbe.montjoie@gmail.com>
Date: Wed, 14 Oct 2015 12:48:04 +0200
Subject: [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE

The sha x86 crypto code use two define for the same thing:
NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
Replace them by SHA1_DIGEST_SIZE/4

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 arch/x86/crypto/sha-mb/sha1_mb.c    | 2 +-
 arch/x86/crypto/sha-mb/sha_mb_ctx.h | 1 -
 arch/x86/crypto/sha-mb/sha_mb_mgr.h | 6 +++---
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c
index a841e97..6544ea7 100644
--- a/arch/x86/crypto/sha-mb/sha1_mb.c
+++ b/arch/x86/crypto/sha-mb/sha1_mb.c
@@ -104,7 +104,7 @@ static asmlinkage struct job_sha1* (*sha1_job_mgr_get_comp_job)(struct sha1_mb_m
 
 inline void sha1_init_digest(uint32_t *digest)
 {
-	static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
+	static const uint32_t initial_digest[SHA1_DIGEST_WORDS] = {SHA1_H0,
 					SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
 	memcpy(digest, initial_digest, sizeof(initial_digest));
 }
diff --git a/arch/x86/crypto/sha-mb/sha_mb_ctx.h b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
index e36069d..9fd36eb5 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_ctx.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
@@ -94,7 +94,6 @@ enum hash_ctx_error {
 
 
 /* Hash Constants and Typedefs */
-#define SHA1_DIGEST_LENGTH          5
 #define SHA1_LOG2_BLOCK_SIZE        6
 
 #define SHA1_PADLENGTHFIELD_SIZE    8
diff --git a/arch/x86/crypto/sha-mb/sha_mb_mgr.h b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
index 08ad1a9..b295e15 100644
--- a/arch/x86/crypto/sha-mb/sha_mb_mgr.h
+++ b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
@@ -54,10 +54,10 @@
 #ifndef __SHA_MB_MGR_H
 #define __SHA_MB_MGR_H
 
-
+#include <crypto/sha.h>
 #include <linux/types.h>
 
-#define NUM_SHA1_DIGEST_WORDS 5
+#define SHA1_DIGEST_WORDS (SHA1_DIGEST_SIZE / sizeof(u32))
 
 enum job_sts {	STS_UNKNOWN = 0,
 		STS_BEING_PROCESSED = 1,
@@ -69,7 +69,7 @@ enum job_sts {	STS_UNKNOWN = 0,
 struct job_sha1 {
 	u8	*buffer;
 	u32	len;
-	u32	result_digest[NUM_SHA1_DIGEST_WORDS] __aligned(32);
+	u32	result_digest[SHA1_DIGEST_WORDS] __aligned(32);
 	enum	job_sts status;
 	void	*user_data;
 };
-- 
2.4.10

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE
  2015-10-29  7:51   ` LABBE Corentin
@ 2015-10-29 16:16     ` Tim Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Tim Chen @ 2015-10-29 16:16 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: tglx, ameenali023, bp, dan.carpenter, davem, firogm, herbert, hpa,
	mingo, minipli, smueller, x86, linux-crypto, linux-kernel

On Thu, 2015-10-29 at 08:51 +0100, LABBE Corentin wrote:
> On Fri, Oct 16, 2015 at 09:04:58AM -0700, Tim Chen wrote:
> > On Wed, 2015-10-14 at 21:15 +0200, LABBE Corentin wrote:
> > > The sha x86 crypto code use two define for the same thing:
> > > NUM_SHA1_DIGEST_WORDS and SHA1_DIGEST_LENGTH
> > > Replace them by SHA1_DIGEST_SIZE/4
> > 
> > Thanks.  Acked-by: Tim Chen <tim.c.chen@linux.intel.com>
> > > 
> > > Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> > 
> 
> Hello
> 
> Thanks for your ack, but Thomas Gleixner in the same time NACK this patch.
> Just in case I attach the new patch, for permit you to decide which one you prefer.
> 
> Regards

Looks fine.  But wonder if you should have
#define SHA1_DIGEST_WORDS (SHA1_DIGEST_SIZE / sizeof(u32))

moved to sha1.h

Tim
> 

> diff --git a/arch/x86/crypto/sha-mb/sha_mb_ctx.h b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
> index e36069d..9fd36eb5 100644
> --- a/arch/x86/crypto/sha-mb/sha_mb_ctx.h
> +++ b/arch/x86/crypto/sha-mb/sha_mb_ctx.h
> @@ -94,7 +94,6 @@ enum hash_ctx_error {
>  
> 
>  /* Hash Constants and Typedefs */
> -#define SHA1_DIGEST_LENGTH          5
>  #define SHA1_LOG2_BLOCK_SIZE        6
>  
>  #define SHA1_PADLENGTHFIELD_SIZE    8
> diff --git a/arch/x86/crypto/sha-mb/sha_mb_mgr.h b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
> index 08ad1a9..b295e15 100644
> --- a/arch/x86/crypto/sha-mb/sha_mb_mgr.h
> +++ b/arch/x86/crypto/sha-mb/sha_mb_mgr.h
> @@ -54,10 +54,10 @@
>  #ifndef __SHA_MB_MGR_H
>  #define __SHA_MB_MGR_H
>  
> -
> +#include <crypto/sha.h>
>  #include <linux/types.h>
>  
> -#define NUM_SHA1_DIGEST_WORDS 5
> +#define SHA1_DIGEST_WORDS (SHA1_DIGEST_SIZE / sizeof(u32))

Suggest to move SHA1_DIGEST_WORDS to sha1.h

Tim




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-29 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-14 19:15 [PATCH] crypto: x86: Remove duplicate define of SHA1_DIGEST_SIZE LABBE Corentin
2015-10-14 20:44 ` Thomas Gleixner
2015-10-16 16:04 ` Tim Chen
2015-10-29  7:51   ` LABBE Corentin
2015-10-29 16:16     ` Tim Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox