crypto: make all generic algorithms set cra_driver_name
authorEric Biggers <ebiggers@google.com>
Mon, 3 Jun 2019 05:40:57 +0000 (22:40 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Jun 2019 06:31:39 +0000 (14:31 +0800)
Most generic crypto algorithms declare a driver name ending in
"-generic".  The rest don't declare a driver name and instead rely on
the crypto API automagically appending "-generic" upon registration.

Having multiple conventions is unnecessarily confusing and makes it
harder to grep for all generic algorithms in the kernel source tree.
But also, allowing NULL driver names is problematic because sometimes
people fail to set it, e.g. the case fixed by commit 417980364300
("crypto: cavium/zip - fix collision with generic cra_driver_name").

Of course, people can also incorrectly name their drivers "-generic".
But that's much easier to notice / grep for.

Therefore, let's make cra_driver_name mandatory.  In preparation for
this, this patch makes all generic algorithms set cra_driver_name.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
22 files changed:
crypto/anubis.c
crypto/arc4.c
crypto/crypto_null.c
crypto/deflate.c
crypto/fcrypt.c
crypto/khazad.c
crypto/lz4.c
crypto/lz4hc.c
crypto/lzo-rle.c
crypto/lzo.c
crypto/md4.c
crypto/md5.c
crypto/michael_mic.c
crypto/rmd128.c
crypto/rmd160.c
crypto/rmd256.c
crypto/rmd320.c
crypto/serpent_generic.c
crypto/tea.c
crypto/tgr192.c
crypto/wp512.c
crypto/zstd.c

index 673927de0eb92977de0c13b2712292795e61756c..f9ce78fde6eeeeca9013cd260471cd8a6cfa4760 100644 (file)
@@ -673,6 +673,7 @@ static void anubis_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 
 static struct crypto_alg anubis_alg = {
        .cra_name               =       "anubis",
+       .cra_driver_name        =       "anubis-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       ANUBIS_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof (struct anubis_ctx),
index 2233d36456e2715ff10dd4b7389d7db127574763..b78dcb390a7e2160271f34d07db85b0f3e73493e 100644 (file)
@@ -115,6 +115,7 @@ static int ecb_arc4_crypt(struct skcipher_request *req)
 
 static struct crypto_alg arc4_cipher = {
        .cra_name               =       "arc4",
+       .cra_driver_name        =       "arc4-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       ARC4_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof(struct arc4_ctx),
@@ -132,6 +133,7 @@ static struct crypto_alg arc4_cipher = {
 
 static struct skcipher_alg arc4_skcipher = {
        .base.cra_name          =       "ecb(arc4)",
+       .base.cra_driver_name   =       "ecb(arc4)-generic",
        .base.cra_priority      =       100,
        .base.cra_blocksize     =       ARC4_BLOCK_SIZE,
        .base.cra_ctxsize       =       sizeof(struct arc4_ctx),
index 9320d4eaa4a8adbbb6ee2d5d05e46d54be18b279..6aa9a4c29edf8635b62089f7251a81eaf05c7a92 100644 (file)
@@ -105,6 +105,7 @@ static struct shash_alg digest_null = {
        .final                  =       null_final,
        .base                   =       {
                .cra_name               =       "digest_null",
+               .cra_driver_name        =       "digest_null-generic",
                .cra_blocksize          =       NULL_BLOCK_SIZE,
                .cra_module             =       THIS_MODULE,
        }
@@ -127,6 +128,7 @@ static struct skcipher_alg skcipher_null = {
 
 static struct crypto_alg null_algs[] = { {
        .cra_name               =       "cipher_null",
+       .cra_driver_name        =       "cipher_null-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       NULL_BLOCK_SIZE,
        .cra_ctxsize            =       0,
@@ -139,6 +141,7 @@ static struct crypto_alg null_algs[] = { {
        .cia_decrypt            =       null_crypt } }
 }, {
        .cra_name               =       "compress_null",
+       .cra_driver_name        =       "compress_null-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_COMPRESS,
        .cra_blocksize          =       NULL_BLOCK_SIZE,
        .cra_ctxsize            =       0,
index aab089cde1bf88fbed5857870f293cd7665d8628..1143ccbe0296bc2a78428ff3536f2d578716b8c7 100644 (file)
@@ -279,6 +279,7 @@ static int deflate_sdecompress(struct crypto_scomp *tfm, const u8 *src,
 
 static struct crypto_alg alg = {
        .cra_name               = "deflate",
+       .cra_driver_name        = "deflate-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct deflate_ctx),
        .cra_module             = THIS_MODULE,
index 4e8704405a3b94d24c78bd60083124a61dddf80c..58f935315cf8fe3a203adef960f4f5b2f62dc9bb 100644 (file)
@@ -391,6 +391,7 @@ static int fcrypt_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key
 
 static struct crypto_alg fcrypt_alg = {
        .cra_name               =       "fcrypt",
+       .cra_driver_name        =       "fcrypt-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       8,
        .cra_ctxsize            =       sizeof(struct fcrypt_ctx),
index b50aa8a3ab4cfcc47df70758635c6e66c8c4f1d6..14ca7f1631c79e24e37d7f7e91fdf9b6b20d2703 100644 (file)
@@ -848,6 +848,7 @@ static void khazad_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 
 static struct crypto_alg khazad_alg = {
        .cra_name               =       "khazad",
+       .cra_driver_name        =       "khazad-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       KHAZAD_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof (struct khazad_ctx),
index 1e35134d0a98d9e58e06cdc86f5a75d56a65f186..ed9088c97c6e7a5beabaa162f76e0b25ee7a527a 100644 (file)
@@ -119,6 +119,7 @@ static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
 
 static struct crypto_alg alg_lz4 = {
        .cra_name               = "lz4",
+       .cra_driver_name        = "lz4-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct lz4_ctx),
        .cra_module             = THIS_MODULE,
index 4a220b628fe7eec5cdd1b3f87a14ecc01f1ae79e..21a342c6b9d4c6664c51634baad040dfd941574f 100644 (file)
@@ -120,6 +120,7 @@ static int lz4hc_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
 
 static struct crypto_alg alg_lz4hc = {
        .cra_name               = "lz4hc",
+       .cra_driver_name        = "lz4hc-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct lz4hc_ctx),
        .cra_module             = THIS_MODULE,
index 4c82bf18440f0688bc5920e0908c85b8c6e04039..469814926f02bf966dde4aac66dade2c7fbda42e 100644 (file)
@@ -122,6 +122,7 @@ static int lzorle_sdecompress(struct crypto_scomp *tfm, const u8 *src,
 
 static struct crypto_alg alg = {
        .cra_name               = "lzo-rle",
+       .cra_driver_name        = "lzo-rle-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct lzorle_ctx),
        .cra_module             = THIS_MODULE,
index 4a6ac8f247d0a6688bcf37fb81c87440110db31c..a98ac046613a16d3e76a73cb21964a744e7a8675 100644 (file)
@@ -122,6 +122,7 @@ static int lzo_sdecompress(struct crypto_scomp *tfm, const u8 *src,
 
 static struct crypto_alg alg = {
        .cra_name               = "lzo",
+       .cra_driver_name        = "lzo-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct lzo_ctx),
        .cra_module             = THIS_MODULE,
index 9a1a228a0c6955cd2f95ef6449bca396cdb60b0b..2e7f2f319f95037a97b8cc978da8873cdf27ab6e 100644 (file)
@@ -216,9 +216,10 @@ static struct shash_alg alg = {
        .final          =       md4_final,
        .descsize       =       sizeof(struct md4_ctx),
        .base           =       {
-               .cra_name       =       "md4",
-               .cra_blocksize  =       MD4_HMAC_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "md4",
+               .cra_driver_name =      "md4-generic",
+               .cra_blocksize   =      MD4_HMAC_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 };
 
index 221c2c0932f83a4c8194fbae1685b259ce15ec11..22dc60bc04375dad20b176f7d007d01039967cd1 100644 (file)
@@ -228,9 +228,10 @@ static struct shash_alg alg = {
        .descsize       =       sizeof(struct md5_state),
        .statesize      =       sizeof(struct md5_state),
        .base           =       {
-               .cra_name       =       "md5",
-               .cra_blocksize  =       MD5_HMAC_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "md5",
+               .cra_driver_name =      "md5-generic",
+               .cra_blocksize   =      MD5_HMAC_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 };
 
index 538ae79337957416f73b90cf4b9c7282c7ac5343..be5c07ea6841c01583c423da7d4d1056fc74083a 100644 (file)
@@ -159,6 +159,7 @@ static struct shash_alg alg = {
        .descsize               =       sizeof(struct michael_mic_desc_ctx),
        .base                   =       {
                .cra_name               =       "michael_mic",
+               .cra_driver_name        =       "michael_mic-generic",
                .cra_blocksize          =       8,
                .cra_alignmask          =       3,
                .cra_ctxsize            =       sizeof(struct michael_mic_ctx),
index faf4252c4b85625597cb071a8e077a63dcc91088..81fcae094bd5eaa98e85ec490db6edd2f3751b15 100644 (file)
@@ -303,6 +303,7 @@ static struct shash_alg alg = {
        .descsize       =       sizeof(struct rmd128_ctx),
        .base           =       {
                .cra_name        =      "rmd128",
+               .cra_driver_name =      "rmd128-generic",
                .cra_blocksize   =      RMD128_BLOCK_SIZE,
                .cra_module      =      THIS_MODULE,
        }
index b33309916d4fe6ab7032b5ec699b97db51c35e0a..0c0d178dee9ddd5d8850f6f5bd442908510784c8 100644 (file)
@@ -347,6 +347,7 @@ static struct shash_alg alg = {
        .descsize       =       sizeof(struct rmd160_ctx),
        .base           =       {
                .cra_name        =      "rmd160",
+               .cra_driver_name =      "rmd160-generic",
                .cra_blocksize   =      RMD160_BLOCK_SIZE,
                .cra_module      =      THIS_MODULE,
        }
index 2a643250c9a5c0addd18fe83d1ffd5c0c6c8fcd3..cdbbe37266c3532bad39d82fe870e807c51d8b4b 100644 (file)
@@ -322,6 +322,7 @@ static struct shash_alg alg = {
        .descsize       =       sizeof(struct rmd256_ctx),
        .base           =       {
                .cra_name        =      "rmd256",
+               .cra_driver_name =      "rmd256-generic",
                .cra_blocksize   =      RMD256_BLOCK_SIZE,
                .cra_module      =      THIS_MODULE,
        }
index 2f062574fc8c8d1f94b65a3d8bffefebe8825ad2..9327af0fe4b7afbd5961855a79a7e5981fd7ad96 100644 (file)
@@ -371,6 +371,7 @@ static struct shash_alg alg = {
        .descsize       =       sizeof(struct rmd320_ctx),
        .base           =       {
                .cra_name        =      "rmd320",
+               .cra_driver_name =      "rmd320-generic",
                .cra_blocksize   =      RMD320_BLOCK_SIZE,
                .cra_module      =      THIS_MODULE,
        }
index ec4ec89ad1085c7b60dde96aa93ec84ee6a39887..f2f549330d2b72dff04ef418c27e270f188c6654 100644 (file)
@@ -641,6 +641,7 @@ static struct crypto_alg srp_algs[2] = { {
        .cia_decrypt            =       serpent_decrypt } }
 }, {
        .cra_name               =       "tnepres",
+       .cra_driver_name        =       "tnepres-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       SERPENT_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof(struct serpent_ctx),
index 786b589e13995619507e9fbfd5ee3cafe2e2c160..fa012589d3b0d06a979ed7e03022911ab0190994 100644 (file)
@@ -221,6 +221,7 @@ static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 
 static struct crypto_alg tea_algs[3] = { {
        .cra_name               =       "tea",
+       .cra_driver_name        =       "tea-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       TEA_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof (struct tea_ctx),
@@ -234,6 +235,7 @@ static struct crypto_alg tea_algs[3] = { {
        .cia_decrypt            =       tea_decrypt } }
 }, {
        .cra_name               =       "xtea",
+       .cra_driver_name        =       "xtea-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       XTEA_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof (struct xtea_ctx),
@@ -247,6 +249,7 @@ static struct crypto_alg tea_algs[3] = { {
        .cia_decrypt            =       xtea_decrypt } }
 }, {
        .cra_name               =       "xeta",
+       .cra_driver_name        =       "xeta-generic",
        .cra_flags              =       CRYPTO_ALG_TYPE_CIPHER,
        .cra_blocksize          =       XTEA_BLOCK_SIZE,
        .cra_ctxsize            =       sizeof (struct xtea_ctx),
index 40020f8adc46a6208a92fc4283942ff08c15ef02..39b3ffd22f5d73aca910a1bde24b9ffc33b4e19a 100644 (file)
@@ -635,9 +635,10 @@ static struct shash_alg tgr_algs[3] = { {
        .final          =       tgr192_final,
        .descsize       =       sizeof(struct tgr192_ctx),
        .base           =       {
-               .cra_name       =       "tgr192",
-               .cra_blocksize  =       TGR192_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "tgr192",
+               .cra_driver_name =      "tgr192-generic",
+               .cra_blocksize   =      TGR192_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 }, {
        .digestsize     =       TGR160_DIGEST_SIZE,
@@ -646,9 +647,10 @@ static struct shash_alg tgr_algs[3] = { {
        .final          =       tgr160_final,
        .descsize       =       sizeof(struct tgr192_ctx),
        .base           =       {
-               .cra_name       =       "tgr160",
-               .cra_blocksize  =       TGR192_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "tgr160",
+               .cra_driver_name =      "tgr160-generic",
+               .cra_blocksize   =      TGR192_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 }, {
        .digestsize     =       TGR128_DIGEST_SIZE,
@@ -657,9 +659,10 @@ static struct shash_alg tgr_algs[3] = { {
        .final          =       tgr128_final,
        .descsize       =       sizeof(struct tgr192_ctx),
        .base           =       {
-               .cra_name       =       "tgr128",
-               .cra_blocksize  =       TGR192_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "tgr128",
+               .cra_driver_name =      "tgr128-generic",
+               .cra_blocksize   =      TGR192_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 } };
 
index 1b8e502d999fff329e742f6884b209d3ab9375ea..feadc13ccae06fe8bd1b1461612cc3cd36e1fa29 100644 (file)
@@ -1126,9 +1126,10 @@ static struct shash_alg wp_algs[3] = { {
        .final          =       wp512_final,
        .descsize       =       sizeof(struct wp512_ctx),
        .base           =       {
-               .cra_name       =       "wp512",
-               .cra_blocksize  =       WP512_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "wp512",
+               .cra_driver_name =      "wp512-generic",
+               .cra_blocksize   =      WP512_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 }, {
        .digestsize     =       WP384_DIGEST_SIZE,
@@ -1137,9 +1138,10 @@ static struct shash_alg wp_algs[3] = { {
        .final          =       wp384_final,
        .descsize       =       sizeof(struct wp512_ctx),
        .base           =       {
-               .cra_name       =       "wp384",
-               .cra_blocksize  =       WP512_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "wp384",
+               .cra_driver_name =      "wp384-generic",
+               .cra_blocksize   =      WP512_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 }, {
        .digestsize     =       WP256_DIGEST_SIZE,
@@ -1148,9 +1150,10 @@ static struct shash_alg wp_algs[3] = { {
        .final          =       wp256_final,
        .descsize       =       sizeof(struct wp512_ctx),
        .base           =       {
-               .cra_name       =       "wp256",
-               .cra_blocksize  =       WP512_BLOCK_SIZE,
-               .cra_module     =       THIS_MODULE,
+               .cra_name        =      "wp256",
+               .cra_driver_name =      "wp256-generic",
+               .cra_blocksize   =      WP512_BLOCK_SIZE,
+               .cra_module      =      THIS_MODULE,
        }
 } };
 
index 2c04055e407f0648bd21f923bac6603c3e81ace4..c9ff2ec8d4a325b536dd684da96e1b2367e0f256 100644 (file)
@@ -214,6 +214,7 @@ static int zstd_sdecompress(struct crypto_scomp *tfm, const u8 *src,
 
 static struct crypto_alg alg = {
        .cra_name               = "zstd",
+       .cra_driver_name        = "zstd-generic",
        .cra_flags              = CRYPTO_ALG_TYPE_COMPRESS,
        .cra_ctxsize            = sizeof(struct zstd_ctx),
        .cra_module             = THIS_MODULE,