linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Siewior <sebastian@breakpoint.cc>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Subject: [PATCH] [crypto] load the SHA1[1|256] module by an alias (v2)
Date: Fri, 5 Oct 2007 15:12:10 +0200	[thread overview]
Message-ID: <E1IdnjO-0006eu-JQ@Chamillionaire.breakpoint.cc> (raw)
In-Reply-To: <20071005135056.GA19693@Chamillionaire.breakpoint.cc>

Loading the crypto algorithm by the alias instead of by module directly
has the advantage that all possible implementations of this algorithm
are loaded automatically and the crypto API can choose the best one
depending on its priority.
Additionally it ensures that the generic implementation as well as the
HW driver (if available) is loaded in case the HW driver needs the
generic version as fallback in corner cases.
Also remove the probe for sha1 in padlock's init code.
Quote from Herbert:
  The probe is actually pointless since we can always probe when
  the algorithm is actually used which does not lead to dead-locks
  like this.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
---
 arch/s390/crypto/sha1_s390.c          |    2 +-
 arch/s390/crypto/sha256_s390.c        |    2 +-
 crypto/Makefile                       |    4 ++--
 crypto/{sha1.c => sha1_generic.c}     |    2 +-
 crypto/{sha256.c => sha256_generic.c} |    8 ++++----
 drivers/crypto/padlock-sha.c          |   19 ++-----------------
 6 files changed, 11 insertions(+), 26 deletions(-)
 rename crypto/{sha1.c => sha1_generic.c} (99%)
 rename crypto/{sha256.c => sha256_generic.c} (99%)

diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c
index af4460e..8ebd3cd 100644
--- a/arch/s390/crypto/sha1_s390.c
+++ b/arch/s390/crypto/sha1_s390.c
@@ -12,7 +12,7 @@
  *   Author(s): Thomas Spatzier
  *		Jan Glauber (jan.glauber@de.ibm.com)
  *
- * Derived from "crypto/sha1.c"
+ * Derived from "crypto/sha1_generic.c"
  *   Copyright (c) Alan Smithee.
  *   Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
  *   Copyright (c) Jean-Francois Dive <jef@linuxbe.org>
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c
index 2ced333..c728bd0 100644
--- a/arch/s390/crypto/sha256_s390.c
+++ b/arch/s390/crypto/sha256_s390.c
@@ -7,7 +7,7 @@
  *   Copyright IBM Corp. 2005,2007
  *   Author(s): Jan Glauber (jang@de.ibm.com)
  *
- * Derived from "crypto/sha256.c"
+ * Derived from "crypto/sha256_generic.c"
  * and "arch/s390/crypto/sha1_s390.c"
  *
  * This program is free software; you can redistribute it and/or modify it
diff --git a/crypto/Makefile b/crypto/Makefile
index b6ef5e4..43c2a0d 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -21,8 +21,8 @@ obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
 obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
 obj-$(CONFIG_CRYPTO_MD4) += md4.o
 obj-$(CONFIG_CRYPTO_MD5) += md5.o
-obj-$(CONFIG_CRYPTO_SHA1) += sha1.o
-obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
+obj-$(CONFIG_CRYPTO_SHA1) += sha1_generic.o
+obj-$(CONFIG_CRYPTO_SHA256) += sha256_generic.o
 obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
 obj-$(CONFIG_CRYPTO_WP512) += wp512.o
 obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
diff --git a/crypto/sha1.c b/crypto/sha1_generic.c
similarity index 99%
rename from crypto/sha1.c
rename to crypto/sha1_generic.c
index 1bba551..70364dd 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1_generic.c
@@ -139,4 +139,4 @@ module_exit(fini);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
 
-MODULE_ALIAS("sha1-generic");
+MODULE_ALIAS("sha1");
diff --git a/crypto/sha256.c b/crypto/sha256_generic.c
similarity index 99%
rename from crypto/sha256.c
rename to crypto/sha256_generic.c
index 716195b..c7097dd 100644
--- a/crypto/sha256.c
+++ b/crypto/sha256_generic.c
@@ -339,4 +339,4 @@ module_exit(fini);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm");
 
-MODULE_ALIAS("sha256-generic");
+MODULE_ALIAS("sha256");
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index a781fd2..bc1de34 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -253,19 +253,6 @@ static struct crypto_alg sha256_alg = {
 	}
 };
 
-static void __init padlock_sha_check_fallbacks(void)
-{
-	if (!crypto_has_hash("sha1", 0, CRYPTO_ALG_ASYNC |
-					CRYPTO_ALG_NEED_FALLBACK))
-		printk(KERN_WARNING PFX
-		       "Couldn't load fallback module for sha1.\n");
-
-	if (!crypto_has_hash("sha256", 0, CRYPTO_ALG_ASYNC |
-					CRYPTO_ALG_NEED_FALLBACK))
-		printk(KERN_WARNING PFX
-		       "Couldn't load fallback module for sha256.\n");
-}
-
 static int __init padlock_init(void)
 {
 	int rc = -ENODEV;
@@ -280,8 +267,6 @@ static int __init padlock_init(void)
 		return -ENODEV;
 	}
 
-	padlock_sha_check_fallbacks();
-
 	rc = crypto_register_alg(&sha1_alg);
 	if (rc)
 		goto out;
@@ -314,5 +299,5 @@ MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support.");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michal Ludvig");
 
-MODULE_ALIAS("sha1-padlock");
-MODULE_ALIAS("sha256-padlock");
+MODULE_ALIAS("sha1");
+MODULE_ALIAS("sha256");
-- 
1.5.3.2

  reply	other threads:[~2007-10-05 14:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-20  0:34 {twofish,aes}-{x86_64,i586} versus C implementations Andi Kleen
2007-08-20  1:01 ` Herbert Xu
2007-08-20 10:16   ` Andi Kleen
2007-08-20  9:45     ` Sebastian Siewior
2007-08-20 10:47       ` Andi Kleen
2007-08-20 10:08         ` Sebastian Siewior
2007-08-20 11:12           ` Andi Kleen
2007-08-20 11:27             ` Sebastian Siewior
2007-08-20 12:06     ` Herbert Xu
2007-08-20 13:06       ` Andi Kleen
2007-08-20 13:07         ` Herbert Xu
2007-09-02 22:42         ` Sebastian Siewior
2007-09-04 13:58           ` Andi Kleen
2007-09-19 12:29           ` Herbert Xu
2007-09-19 21:46             ` Sebastian Siewior
2007-09-20  0:20               ` Herbert Xu
2007-09-20 21:09                 ` Sebastian Siewior
2007-09-30 12:23                   ` Sebastian Siewior
2007-09-30 12:42       ` Sebastian Siewior
2007-10-03  7:35         ` Herbert Xu
2007-10-04  8:35           ` Sebastian Siewior
2007-10-03 19:23             ` [PATCH] [crypto] load the DES module by an alias Sebastian Siewior
2007-10-05  8:48               ` Herbert Xu
2007-10-04  7:37             ` [PATCH] [crypto] load the AES " Sebastian Siewior
2007-10-05  8:52               ` Herbert Xu
2007-10-04  7:37             ` [PATCH] [crypto] load the SHA1[1|256] " Sebastian Siewior
2007-10-05  8:57               ` Herbert Xu
2007-10-05 13:50                 ` Sebastian Siewior
2007-10-05 13:12                   ` Sebastian Siewior [this message]
2007-10-05 15:10                     ` [PATCH] [crypto] load the SHA1[1|256] module by an alias (v2) Herbert Xu
2007-10-06 22:02                       ` Sebastian Siewior
2007-10-08  3:21                         ` Herbert Xu
2007-10-07 21:42                       ` Sebastian Siewior
2007-10-08  3:20                         ` Herbert Xu
2007-10-08 12:35                           ` Sebastian Siewior
2007-10-08  4:12                     ` Herbert Xu
2007-10-05 14:20                   ` [PATCH] [crypto] load the SHA1[1|256] module by an alias Herbert Xu
2007-10-06 21:54                     ` Sebastian Siewior
2007-10-08 11:25               ` Jan Glauber
2007-10-08 11:30                 ` Sebastian Siewior
2007-10-04  8:48             ` {twofish,aes}-{x86_64,i586} versus C implementations Herbert Xu
2007-10-04  9:31               ` Andi Kleen
2007-10-04 10:00                 ` Sebastian Siewior
2007-10-04 10:00                 ` Herbert Xu
2007-10-04  9:39               ` Sebastian Siewior

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=E1IdnjO-0006eu-JQ@Chamillionaire.breakpoint.cc \
    --to=sebastian@breakpoint.cc \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).