[CRYPTO] sha: Load the SHA[1|256] module by an alias
authorSebastian Siewior <sebastian@breakpoint.cc>
Mon, 8 Oct 2007 03:45:10 +0000 (11:45 +0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:55:50 +0000 (16:55 -0700)
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>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/s390/crypto/sha1_s390.c
arch/s390/crypto/sha256_s390.c
crypto/Makefile
crypto/sha1_generic.c [moved from crypto/sha1.c with 99% similarity]
crypto/sha256_generic.c [moved from crypto/sha256.c with 99% similarity]
drivers/crypto/padlock-sha.c

index af4460e..8ebd3cd 100644 (file)
@@ -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>
index 2ced333..c728bd0 100644 (file)
@@ -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
index b6ef5e4..43c2a0d 100644 (file)
@@ -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
similarity index 99%
rename from crypto/sha1.c
rename to crypto/sha1_generic.c
index 1bba551..70364dd 100644 (file)
@@ -139,4 +139,4 @@ module_exit(fini);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
 
-MODULE_ALIAS("sha1-generic");
+MODULE_ALIAS("sha1");
similarity index 99%
rename from crypto/sha256.c
rename to crypto/sha256_generic.c
index 716195b..74bf2f9 100644 (file)
@@ -339,4 +339,4 @@ module_exit(fini);
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm");
 
-MODULE_ALIAS("sha256-generic");
+MODULE_ALIAS("sha256");
index a781fd2..f3857bb 100644 (file)
@@ -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,7 @@ MODULE_DESCRIPTION("VIA PadLock SHA1/SHA256 algorithms support.");
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Michal Ludvig");
 
+MODULE_ALIAS("sha1");
+MODULE_ALIAS("sha256");
 MODULE_ALIAS("sha1-padlock");
 MODULE_ALIAS("sha256-padlock");