mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>,
	Oleg Drokin <oleg.drokin@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>,
	Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH 04/12] staging: lustre: libcfs: add new definitions for cfs_crypto api
Date: Sat, 26 Mar 2016 15:40:48 -0400	[thread overview]
Message-ID: <1459021256-23857-5-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1459021256-23857-1-git-send-email-jsimmons@infradead.org>

From: Andreas Dilger <andreas.dilger@intel.com>

Add CFS_HASH_ALG_UNKOWN for unknown hash names instead of
using "0xFF" directly. Define the max digestsize the cfs
crypto api can handle.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5053
Reviewed-on: http://review.whamcloud.com/9990
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
 .../lustre/include/linux/libcfs/libcfs_crypto.h    |    9 +++++++--
 .../lustre/lnet/libcfs/linux/linux-crypto.c        |    4 ++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
index 0782bfb..921aa7c 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_crypto.h
@@ -46,7 +46,8 @@ enum cfs_crypto_hash_alg {
 	CFS_HASH_ALG_SHA384,
 	CFS_HASH_ALG_SHA512,
 	CFS_HASH_ALG_CRC32C,
-	CFS_HASH_ALG_MAX
+	CFS_HASH_ALG_MAX,
+	CFS_HASH_ALG_UNKNOWN	= 0xff
 };
 
 static struct cfs_crypto_hash_type hash_types[] = {
@@ -59,8 +60,12 @@ static struct cfs_crypto_hash_type hash_types[] = {
 	[CFS_HASH_ALG_SHA256]  = { "sha256",   0,     32 },
 	[CFS_HASH_ALG_SHA384]  = { "sha384",   0,     48 },
 	[CFS_HASH_ALG_SHA512]  = { "sha512",   0,     64 },
+	[CFS_HASH_ALG_MAX]	= { NULL,	0,	64 },
 };
 
+/* Maximum size of hash_types[].cht_size */
+#define CFS_CRYPTO_HASH_DIGESTSIZE_MAX	64
+
 /**
  * Return hash algorithm information for the specified algorithm identifier
  *
@@ -131,7 +136,7 @@ static inline unsigned char cfs_crypto_hash_alg(const char *algname)
 	for (i = 0; i < CFS_HASH_ALG_MAX; i++)
 		if (!strcmp(hash_types[i].cht_name, algname))
 			break;
-	return (i == CFS_HASH_ALG_MAX ? 0xFF : i);
+	return (i == CFS_HASH_ALG_MAX ? CFS_HASH_ALG_UNKNOWN : i);
 }
 
 int cfs_crypto_hash_digest(unsigned char hash_alg,
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
index 1a9eb77..b4e203d 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-crypto.c
@@ -316,8 +316,8 @@ static void cfs_crypto_performance_test(unsigned char hash_alg,
 	unsigned long		   start, end;
 	int			     bcount, err = 0;
 	int			     sec = 1; /* do test only 1 sec */
-	unsigned char		   hash[64];
-	unsigned int		    hash_len = 64;
+	unsigned char hash[CFS_CRYPTO_HASH_DIGESTSIZE_MAX];
+	unsigned int hash_len = sizeof(hash);
 
 	for (start = jiffies, end = start + sec * HZ, bcount = 0;
 	     time_before(jiffies, end); bcount++) {
-- 
1.7.1

  parent reply	other threads:[~2016-03-26 19:41 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-26 19:40 [PATCH 00/12] Bring the libcfs crypto code up to date James Simmons
2016-03-26 19:40 ` [PATCH 01/12] staging: lustre: libcfs: limit scope of libcfs_crypto.h James Simmons
2016-03-26 19:40 ` [PATCH 02/12] staging: lustre: libcfs: add documentation for cfs_crypto_hash_*() James Simmons
2016-03-26 19:40 ` [PATCH 03/12] staging: lustre: libcfs: rename some variables for crypto handling James Simmons
2016-03-26 19:40 ` James Simmons [this message]
2016-03-26 19:40 ` [PATCH 05/12] staging: lustre: libcfs: small alignment change for cfs_crypto_hash_*() James Simmons
2016-03-26 19:40 ` [PATCH 06/12] staging: lustre: libcfs: start using enum cfs_crypto_hash_alg James Simmons
2016-03-26 19:40 ` [PATCH 07/12] staging: lustre: libcfs: bug fixes for cfs_crypto_hash_final() James Simmons
2016-03-26 19:40 ` [PATCH 08/12] staging: lustre: libcfs: return proper error code for cfs_crypto_hash_speed() James Simmons
2016-03-26 19:40 ` [PATCH 09/12] staging: lustre: libcfs: allocate memory in cfs_crypto_performance_test() James Simmons
2016-03-26 19:40 ` [PATCH 10/12] staging: lustre: libcfs: print crypto performance result only on success James Simmons
2016-03-26 19:40 ` [PATCH 11/12] staging: lustre: libcfs: improve reporting error for crypto performance James Simmons
2016-03-26 19:40 ` [PATCH 12/12] staging: lustre: libcfs: calculate crypto performance using pages James Simmons

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459021256-23857-5-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®