Skip to content

Commit d6ebf52

Browse files
ebiggersherbertx
authored andcommitted
crypto: make all generic algorithms set cra_driver_name
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 <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7545b6c commit d6ebf52

22 files changed

+55
-24
lines changed

crypto/anubis.c

+1
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ static void anubis_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
673673

674674
static struct crypto_alg anubis_alg = {
675675
.cra_name = "anubis",
676+
.cra_driver_name = "anubis-generic",
676677
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
677678
.cra_blocksize = ANUBIS_BLOCK_SIZE,
678679
.cra_ctxsize = sizeof (struct anubis_ctx),

crypto/arc4.c

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static int ecb_arc4_crypt(struct skcipher_request *req)
115115

116116
static struct crypto_alg arc4_cipher = {
117117
.cra_name = "arc4",
118+
.cra_driver_name = "arc4-generic",
118119
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
119120
.cra_blocksize = ARC4_BLOCK_SIZE,
120121
.cra_ctxsize = sizeof(struct arc4_ctx),
@@ -132,6 +133,7 @@ static struct crypto_alg arc4_cipher = {
132133

133134
static struct skcipher_alg arc4_skcipher = {
134135
.base.cra_name = "ecb(arc4)",
136+
.base.cra_driver_name = "ecb(arc4)-generic",
135137
.base.cra_priority = 100,
136138
.base.cra_blocksize = ARC4_BLOCK_SIZE,
137139
.base.cra_ctxsize = sizeof(struct arc4_ctx),

crypto/crypto_null.c

+3
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static struct shash_alg digest_null = {
105105
.final = null_final,
106106
.base = {
107107
.cra_name = "digest_null",
108+
.cra_driver_name = "digest_null-generic",
108109
.cra_blocksize = NULL_BLOCK_SIZE,
109110
.cra_module = THIS_MODULE,
110111
}
@@ -127,6 +128,7 @@ static struct skcipher_alg skcipher_null = {
127128

128129
static struct crypto_alg null_algs[] = { {
129130
.cra_name = "cipher_null",
131+
.cra_driver_name = "cipher_null-generic",
130132
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
131133
.cra_blocksize = NULL_BLOCK_SIZE,
132134
.cra_ctxsize = 0,
@@ -139,6 +141,7 @@ static struct crypto_alg null_algs[] = { {
139141
.cia_decrypt = null_crypt } }
140142
}, {
141143
.cra_name = "compress_null",
144+
.cra_driver_name = "compress_null-generic",
142145
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
143146
.cra_blocksize = NULL_BLOCK_SIZE,
144147
.cra_ctxsize = 0,

crypto/deflate.c

+1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ static int deflate_sdecompress(struct crypto_scomp *tfm, const u8 *src,
279279

280280
static struct crypto_alg alg = {
281281
.cra_name = "deflate",
282+
.cra_driver_name = "deflate-generic",
282283
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
283284
.cra_ctxsize = sizeof(struct deflate_ctx),
284285
.cra_module = THIS_MODULE,

crypto/fcrypt.c

+1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ static int fcrypt_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key
391391

392392
static struct crypto_alg fcrypt_alg = {
393393
.cra_name = "fcrypt",
394+
.cra_driver_name = "fcrypt-generic",
394395
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
395396
.cra_blocksize = 8,
396397
.cra_ctxsize = sizeof(struct fcrypt_ctx),

crypto/khazad.c

+1
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ static void khazad_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
848848

849849
static struct crypto_alg khazad_alg = {
850850
.cra_name = "khazad",
851+
.cra_driver_name = "khazad-generic",
851852
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
852853
.cra_blocksize = KHAZAD_BLOCK_SIZE,
853854
.cra_ctxsize = sizeof (struct khazad_ctx),

crypto/lz4.c

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ static int lz4_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
119119

120120
static struct crypto_alg alg_lz4 = {
121121
.cra_name = "lz4",
122+
.cra_driver_name = "lz4-generic",
122123
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
123124
.cra_ctxsize = sizeof(struct lz4_ctx),
124125
.cra_module = THIS_MODULE,

crypto/lz4hc.c

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ static int lz4hc_decompress_crypto(struct crypto_tfm *tfm, const u8 *src,
120120

121121
static struct crypto_alg alg_lz4hc = {
122122
.cra_name = "lz4hc",
123+
.cra_driver_name = "lz4hc-generic",
123124
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
124125
.cra_ctxsize = sizeof(struct lz4hc_ctx),
125126
.cra_module = THIS_MODULE,

crypto/lzo-rle.c

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static int lzorle_sdecompress(struct crypto_scomp *tfm, const u8 *src,
122122

123123
static struct crypto_alg alg = {
124124
.cra_name = "lzo-rle",
125+
.cra_driver_name = "lzo-rle-generic",
125126
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
126127
.cra_ctxsize = sizeof(struct lzorle_ctx),
127128
.cra_module = THIS_MODULE,

crypto/lzo.c

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static int lzo_sdecompress(struct crypto_scomp *tfm, const u8 *src,
122122

123123
static struct crypto_alg alg = {
124124
.cra_name = "lzo",
125+
.cra_driver_name = "lzo-generic",
125126
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
126127
.cra_ctxsize = sizeof(struct lzo_ctx),
127128
.cra_module = THIS_MODULE,

crypto/md4.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ static struct shash_alg alg = {
216216
.final = md4_final,
217217
.descsize = sizeof(struct md4_ctx),
218218
.base = {
219-
.cra_name = "md4",
220-
.cra_blocksize = MD4_HMAC_BLOCK_SIZE,
221-
.cra_module = THIS_MODULE,
219+
.cra_name = "md4",
220+
.cra_driver_name = "md4-generic",
221+
.cra_blocksize = MD4_HMAC_BLOCK_SIZE,
222+
.cra_module = THIS_MODULE,
222223
}
223224
};
224225

crypto/md5.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,10 @@ static struct shash_alg alg = {
228228
.descsize = sizeof(struct md5_state),
229229
.statesize = sizeof(struct md5_state),
230230
.base = {
231-
.cra_name = "md5",
232-
.cra_blocksize = MD5_HMAC_BLOCK_SIZE,
233-
.cra_module = THIS_MODULE,
231+
.cra_name = "md5",
232+
.cra_driver_name = "md5-generic",
233+
.cra_blocksize = MD5_HMAC_BLOCK_SIZE,
234+
.cra_module = THIS_MODULE,
234235
}
235236
};
236237

crypto/michael_mic.c

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static struct shash_alg alg = {
159159
.descsize = sizeof(struct michael_mic_desc_ctx),
160160
.base = {
161161
.cra_name = "michael_mic",
162+
.cra_driver_name = "michael_mic-generic",
162163
.cra_blocksize = 8,
163164
.cra_alignmask = 3,
164165
.cra_ctxsize = sizeof(struct michael_mic_ctx),

crypto/rmd128.c

+1
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ static struct shash_alg alg = {
303303
.descsize = sizeof(struct rmd128_ctx),
304304
.base = {
305305
.cra_name = "rmd128",
306+
.cra_driver_name = "rmd128-generic",
306307
.cra_blocksize = RMD128_BLOCK_SIZE,
307308
.cra_module = THIS_MODULE,
308309
}

crypto/rmd160.c

+1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ static struct shash_alg alg = {
347347
.descsize = sizeof(struct rmd160_ctx),
348348
.base = {
349349
.cra_name = "rmd160",
350+
.cra_driver_name = "rmd160-generic",
350351
.cra_blocksize = RMD160_BLOCK_SIZE,
351352
.cra_module = THIS_MODULE,
352353
}

crypto/rmd256.c

+1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ static struct shash_alg alg = {
322322
.descsize = sizeof(struct rmd256_ctx),
323323
.base = {
324324
.cra_name = "rmd256",
325+
.cra_driver_name = "rmd256-generic",
325326
.cra_blocksize = RMD256_BLOCK_SIZE,
326327
.cra_module = THIS_MODULE,
327328
}

crypto/rmd320.c

+1
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ static struct shash_alg alg = {
371371
.descsize = sizeof(struct rmd320_ctx),
372372
.base = {
373373
.cra_name = "rmd320",
374+
.cra_driver_name = "rmd320-generic",
374375
.cra_blocksize = RMD320_BLOCK_SIZE,
375376
.cra_module = THIS_MODULE,
376377
}

crypto/serpent_generic.c

+1
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ static struct crypto_alg srp_algs[2] = { {
641641
.cia_decrypt = serpent_decrypt } }
642642
}, {
643643
.cra_name = "tnepres",
644+
.cra_driver_name = "tnepres-generic",
644645
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
645646
.cra_blocksize = SERPENT_BLOCK_SIZE,
646647
.cra_ctxsize = sizeof(struct serpent_ctx),

crypto/tea.c

+3
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ static void xeta_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
221221

222222
static struct crypto_alg tea_algs[3] = { {
223223
.cra_name = "tea",
224+
.cra_driver_name = "tea-generic",
224225
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
225226
.cra_blocksize = TEA_BLOCK_SIZE,
226227
.cra_ctxsize = sizeof (struct tea_ctx),
@@ -234,6 +235,7 @@ static struct crypto_alg tea_algs[3] = { {
234235
.cia_decrypt = tea_decrypt } }
235236
}, {
236237
.cra_name = "xtea",
238+
.cra_driver_name = "xtea-generic",
237239
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
238240
.cra_blocksize = XTEA_BLOCK_SIZE,
239241
.cra_ctxsize = sizeof (struct xtea_ctx),
@@ -247,6 +249,7 @@ static struct crypto_alg tea_algs[3] = { {
247249
.cia_decrypt = xtea_decrypt } }
248250
}, {
249251
.cra_name = "xeta",
252+
.cra_driver_name = "xeta-generic",
250253
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
251254
.cra_blocksize = XTEA_BLOCK_SIZE,
252255
.cra_ctxsize = sizeof (struct xtea_ctx),

crypto/tgr192.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,10 @@ static struct shash_alg tgr_algs[3] = { {
635635
.final = tgr192_final,
636636
.descsize = sizeof(struct tgr192_ctx),
637637
.base = {
638-
.cra_name = "tgr192",
639-
.cra_blocksize = TGR192_BLOCK_SIZE,
640-
.cra_module = THIS_MODULE,
638+
.cra_name = "tgr192",
639+
.cra_driver_name = "tgr192-generic",
640+
.cra_blocksize = TGR192_BLOCK_SIZE,
641+
.cra_module = THIS_MODULE,
641642
}
642643
}, {
643644
.digestsize = TGR160_DIGEST_SIZE,
@@ -646,9 +647,10 @@ static struct shash_alg tgr_algs[3] = { {
646647
.final = tgr160_final,
647648
.descsize = sizeof(struct tgr192_ctx),
648649
.base = {
649-
.cra_name = "tgr160",
650-
.cra_blocksize = TGR192_BLOCK_SIZE,
651-
.cra_module = THIS_MODULE,
650+
.cra_name = "tgr160",
651+
.cra_driver_name = "tgr160-generic",
652+
.cra_blocksize = TGR192_BLOCK_SIZE,
653+
.cra_module = THIS_MODULE,
652654
}
653655
}, {
654656
.digestsize = TGR128_DIGEST_SIZE,
@@ -657,9 +659,10 @@ static struct shash_alg tgr_algs[3] = { {
657659
.final = tgr128_final,
658660
.descsize = sizeof(struct tgr192_ctx),
659661
.base = {
660-
.cra_name = "tgr128",
661-
.cra_blocksize = TGR192_BLOCK_SIZE,
662-
.cra_module = THIS_MODULE,
662+
.cra_name = "tgr128",
663+
.cra_driver_name = "tgr128-generic",
664+
.cra_blocksize = TGR192_BLOCK_SIZE,
665+
.cra_module = THIS_MODULE,
663666
}
664667
} };
665668

crypto/wp512.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,10 @@ static struct shash_alg wp_algs[3] = { {
11261126
.final = wp512_final,
11271127
.descsize = sizeof(struct wp512_ctx),
11281128
.base = {
1129-
.cra_name = "wp512",
1130-
.cra_blocksize = WP512_BLOCK_SIZE,
1131-
.cra_module = THIS_MODULE,
1129+
.cra_name = "wp512",
1130+
.cra_driver_name = "wp512-generic",
1131+
.cra_blocksize = WP512_BLOCK_SIZE,
1132+
.cra_module = THIS_MODULE,
11321133
}
11331134
}, {
11341135
.digestsize = WP384_DIGEST_SIZE,
@@ -1137,9 +1138,10 @@ static struct shash_alg wp_algs[3] = { {
11371138
.final = wp384_final,
11381139
.descsize = sizeof(struct wp512_ctx),
11391140
.base = {
1140-
.cra_name = "wp384",
1141-
.cra_blocksize = WP512_BLOCK_SIZE,
1142-
.cra_module = THIS_MODULE,
1141+
.cra_name = "wp384",
1142+
.cra_driver_name = "wp384-generic",
1143+
.cra_blocksize = WP512_BLOCK_SIZE,
1144+
.cra_module = THIS_MODULE,
11431145
}
11441146
}, {
11451147
.digestsize = WP256_DIGEST_SIZE,
@@ -1148,9 +1150,10 @@ static struct shash_alg wp_algs[3] = { {
11481150
.final = wp256_final,
11491151
.descsize = sizeof(struct wp512_ctx),
11501152
.base = {
1151-
.cra_name = "wp256",
1152-
.cra_blocksize = WP512_BLOCK_SIZE,
1153-
.cra_module = THIS_MODULE,
1153+
.cra_name = "wp256",
1154+
.cra_driver_name = "wp256-generic",
1155+
.cra_blocksize = WP512_BLOCK_SIZE,
1156+
.cra_module = THIS_MODULE,
11541157
}
11551158
} };
11561159

crypto/zstd.c

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ static int zstd_sdecompress(struct crypto_scomp *tfm, const u8 *src,
214214

215215
static struct crypto_alg alg = {
216216
.cra_name = "zstd",
217+
.cra_driver_name = "zstd-generic",
217218
.cra_flags = CRYPTO_ALG_TYPE_COMPRESS,
218219
.cra_ctxsize = sizeof(struct zstd_ctx),
219220
.cra_module = THIS_MODULE,

0 commit comments

Comments
 (0)