Skip to content

Commit

Permalink
crypto: make all generic algorithms set cra_driver_name
Browse files Browse the repository at this point in the history
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 4179803
("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>
  • Loading branch information
ebiggers authored and herbertx committed Jun 13, 2019
1 parent 7545b6c commit d6ebf52
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 24 deletions.
1 change: 1 addition & 0 deletions crypto/anubis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions crypto/arc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions crypto/crypto_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand All @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crypto/deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crypto/fcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions crypto/khazad.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions crypto/lz4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crypto/lz4hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crypto/lzo-rle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crypto/lzo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions crypto/md4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};

Expand Down
7 changes: 4 additions & 3 deletions crypto/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
};

Expand Down
1 change: 1 addition & 0 deletions crypto/michael_mic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions crypto/rmd128.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crypto/rmd160.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crypto/rmd256.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crypto/rmd320.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions crypto/serpent_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions crypto/tea.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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),
Expand Down
21 changes: 12 additions & 9 deletions crypto/tgr192.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
}
} };

Expand Down
21 changes: 12 additions & 9 deletions crypto/wp512.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
}
} };

Expand Down
1 change: 1 addition & 0 deletions crypto/zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d6ebf52

Please sign in to comment.