Skip to contentSkip to conversation

crypto: sha1-mb - remove HASH_FIRST flag

PATCH In review Eric Biggers 3 participants 5 messages Jan 25, 2018 – Feb 15, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: sha1-mb - remove HASH_FIRST flag

From: Eric Biggers <[email protected]>

The HASH_FIRST flag is never set. Remove it.

---
 arch/x86/crypto/sha1-mb/sha1_mb.c     | 28 +++-------------------------
 arch/x86/crypto/sha1-mb/sha1_mb_ctx.h |  8 +++-----
 2 files changed, 6 insertions(+), 30 deletions(-)
arch/x86/crypto/sha1-mb/sha1_mb.c +3 -25
index acf9fdf01671..e17655ffde79 100644
@@ -106,13 +106,6 @@ static asmlinkage struct job_sha1* (*sha1_job_mgr_flush)
 static asmlinkage struct job_sha1* (*sha1_job_mgr_get_comp_job)
 						(struct sha1_mb_mgr *state);
 
-static inline void sha1_init_digest(uint32_t *digest)
-{
-	static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
-					SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
-	memcpy(digest, initial_digest, sizeof(initial_digest));
-}
-
 static inline uint32_t sha1_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2],
 			 uint64_t total_len)
 {
@@ -244,11 +237,8 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 					  uint32_t len,
 					  int flags)
 {
-	if (flags & (~HASH_ENTIRE)) {
-		/*
-		 * User should not pass anything other than FIRST, UPDATE, or
-		 * LAST
-		 */
+	if (flags & ~(HASH_UPDATE | HASH_LAST)) {
+		/* User should not pass anything other than UPDATE or LAST */
 		ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
 		return ctx;
 	}
@@ -259,24 +249,12 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 		return ctx;
 	}
 
-	if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) {
+	if (ctx->status & HASH_CTX_STS_COMPLETE) {
 		/* Cannot update a finished job. */
 		ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
 		return ctx;
 	}
 
-
-	if (flags & HASH_FIRST) {
-		/* Init digest */
-		sha1_init_digest(ctx->job.result_digest);
-
-		/* Reset byte counter */
-		ctx->total_length = 0;
-
-		/* Clear extra blocks */
-		ctx->partial_block_buffer_length = 0;
-	}
-
 	/*
 	 * If we made it here, there were no errors during this call to
 	 * submit
arch/x86/crypto/sha1-mb/sha1_mb_ctx.h +3 -5
index 13590ccf965c..9454bd16f9f8 100644
@@ -57,11 +57,9 @@
 #include "sha1_mb_mgr.h"
 
 #define HASH_UPDATE          0x00
-#define HASH_FIRST           0x01
-#define HASH_LAST            0x02
-#define HASH_ENTIRE          0x03
-#define HASH_DONE	     0x04
-#define HASH_FINAL	     0x08
+#define HASH_LAST            0x01
+#define HASH_DONE	     0x02
+#define HASH_FINAL	     0x04
 
 #define HASH_CTX_STS_IDLE       0x00
 #define HASH_CTX_STS_PROCESSING 0x01
Signature · 1 line
2.16.0
#1 lore raw
Quoted 55 lines · Eric Biggers

From: Eric Biggers <[email protected]>

The HASH_FIRST flag is never set. Remove it.

---
 arch/x86/crypto/sha1-mb/sha1_mb.c     | 28 +++-------------------------
 arch/x86/crypto/sha1-mb/sha1_mb_ctx.h |  8 +++-----
 2 files changed, 6 insertions(+), 30 deletions(-)
arch/x86/crypto/sha1-mb/sha1_mb.c +3 -15
index acf9fdf01671..e17655ffde79 100644
@@ -106,13 +106,6 @@ static asmlinkage struct job_sha1* (*sha1_job_mgr_flush)
 static asmlinkage struct job_sha1* (*sha1_job_mgr_get_comp_job)
 						(struct sha1_mb_mgr *state);
 
-static inline void sha1_init_digest(uint32_t *digest)
-{
-	static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
-					SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
-	memcpy(digest, initial_digest, sizeof(initial_digest));
-}
-
 static inline uint32_t sha1_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2],
 			 uint64_t total_len)
 {
@@ -244,11 +237,8 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 					  uint32_t len,
 					  int flags)
 {
-	if (flags & (~HASH_ENTIRE)) {
-		/*
-		 * User should not pass anything other than FIRST, UPDATE, or
-		 * LAST
-		 */
+	if (flags & ~(HASH_UPDATE | HASH_LAST)) {
+		/* User should not pass anything other than UPDATE or LAST */
 		ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
 		return ctx;
 	}
@@ -259,24 +249,12 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 		return ctx;
 	}
 
-	if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) {
+	if (ctx->status & HASH_CTX_STS_COMPLETE) {
 		/* Cannot update a finished job. */
 		ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
 		return ctx;
 	}
 
-
-	if (flags & HASH_FIRST) {

arch/x86/crypto/sha1-mb/sha1_mb.c static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr, · line 279

Quoted 10 lines
arch/x86/crypto/sha1-mb/sha1_mb.c +0 -10
-		/* Init digest */
-		sha1_init_digest(ctx->job.result_digest);
-
-		/* Reset byte counter */
-		ctx->total_length = 0;
-
-		/* Clear extra blocks */
-		ctx->partial_block_buffer_length = 0;
-	}
-

I suppose this will be okay as we are really doing the initialization in sha1_mb_init. Megha is now maintaining this code. Copying her so she can do some verification of this change.

Tim

Quoted 25 lines
arch/x86/crypto/sha1-mb/sha1_mb.c +0 -0
 	/*
 	 * If we made it here, there were no errors during this call to
 	 * submit
arch/x86/crypto/sha1-mb/sha1_mb_ctx.h +3 -5
index 13590ccf965c..9454bd16f9f8 100644
@@ -57,11 +57,9 @@
 #include "sha1_mb_mgr.h"
 
 #define HASH_UPDATE          0x00
-#define HASH_FIRST           0x01
-#define HASH_LAST            0x02
-#define HASH_ENTIRE          0x03
-#define HASH_DONE	     0x04
-#define HASH_FINAL	     0x08
+#define HASH_LAST            0x01
 
 
+#define HASH_DONE	     0x02
+#define HASH_FINAL	     0x04
 

#define HASH_CTX_STS_IDLE 0x00
#define HASH_CTX_STS_PROCESSING 0x01

#2 lore raw
Quoted 54 lines · Tim Chen
Quoted 53 lines · Eric Biggers

From: Eric Biggers <[email protected]>

The HASH_FIRST flag is never set. Remove it.

---
 arch/x86/crypto/sha1-mb/sha1_mb.c     | 28 +++-------------------------
 arch/x86/crypto/sha1-mb/sha1_mb_ctx.h |  8 +++-----
 2 files changed, 6 insertions(+), 30 deletions(-)
arch/x86/crypto/sha1-mb/sha1_mb.c +3 -13
index acf9fdf01671..e17655ffde79 100644
@@ -106,13 +106,6 @@ static asmlinkage struct job_sha1* (*sha1_job_mgr_flush)
 static asmlinkage struct job_sha1* (*sha1_job_mgr_get_comp_job)
 						(struct sha1_mb_mgr *state);
 
-static inline void sha1_init_digest(uint32_t *digest)
-{
-	static const uint32_t initial_digest[SHA1_DIGEST_LENGTH] = {SHA1_H0,
-					SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 };
-	memcpy(digest, initial_digest, sizeof(initial_digest));
-}
-
 static inline uint32_t sha1_pad(uint8_t padblock[SHA1_BLOCK_SIZE * 2],
 			 uint64_t total_len)
 {
@@ -244,11 +237,8 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 					  uint32_t len,
 					  int flags)
 {
-	if (flags & (~HASH_ENTIRE)) {
-		/*
-		 * User should not pass anything other than FIRST, UPDATE, or
-		 * LAST
-		 */
+	if (flags & ~(HASH_UPDATE | HASH_LAST)) {
+		/* User should not pass anything other than UPDATE or LAST */
 		ctx->error = HASH_CTX_ERROR_INVALID_FLAGS;
 		return ctx;
 	}
@@ -259,24 +249,12 @@ static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr,
 		return ctx;
 	}
 
-	if ((ctx->status & HASH_CTX_STS_COMPLETE) && !(flags & HASH_FIRST)) {
+	if (ctx->status & HASH_CTX_STS_COMPLETE) {
 		/* Cannot update a finished job. */
 		ctx->error = HASH_CTX_ERROR_ALREADY_COMPLETED;
 		return ctx;
 	}
 
Quoted 17 lines

arch/x86/crypto/sha1-mb/sha1_mb.c static struct sha1_hash_ctx *sha1_ctx_mgr_submit(struct sha1_ctx_mgr *mgr, · line 279

Quoted 12 lines
arch/x86/crypto/sha1-mb/sha1_mb.c +0 -12
-
-	if (flags & HASH_FIRST) {
-		/* Init digest */
-		sha1_init_digest(ctx->job.result_digest);
-
-		/* Reset byte counter */
-		ctx->total_length = 0;
-
-		/* Clear extra blocks */
-		ctx->partial_block_buffer_length = 0;
-	}
-

I suppose this will be okay as we are really doing the initialization in sha1_mb_init. Megha is now maintaining this code. Copying her so she can do some verification of this change.

Please update the MAINTAINERS file so that people know who to Cc on patches.

Eric

#3 lore raw
Quoted 11 lines
Quoted 6 lines

I suppose this will be okay as we are really doing the initialization in sha1_mb_init. Megha is now maintaining this code. Copying her so she can do some verification of this change.

Please update the MAINTAINERS file so that people know who to Cc on patches.

Eric

Herbert,

Can you pull in the patch below to update MAINTAINERS for sha multibuffer?

Tim

Quoted 1 line

From 884095fccd36d2de8c6edfe6f4d60ab4a1b9339b Mon Sep 17 00:00:00 2001

From: Tim Chen <[email protected]>
Date: Mon, 29 Jan 2018 09:22:41 -0800
Subject: [PATCH] x86/crypto: Designate maintainer for SHA-1/256/512
multibuffer driver

Even though I created the original implementation of SHA1 multibuffer driver, Megha extended it to SHA256 and SHA512 and she is now maintaining the code for SHA1/SHA256/SHA512 multi-buffer driver.

Add the entry in the MAINTAINERS file so any update patch can find its way properly to Megha.

---
 MAINTAINERS | 8 ++++++++
 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
index 2811a21..2085171 100644
@@ -7064,6 +7064,14 @@ L:	[email protected]
 S:	Supported
 F:	drivers/infiniband/hw/i40iw/
 
+INTEL SHA MULTIBUFFER DRIVER
+M:	Megha Dey <[email protected]>
+R:	Tim Chen <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	arch/x86/crypto/sha*-mb
+F:	crypto/mcryptd.c
+
 INTEL TELEMETRY DRIVER
 M:	Souvik Kumar Chakravarty <[email protected]>
 L:	[email protected]
Signature · 1 line
2.7.4