Skip to content

Commit 3f2a5d2

Browse files
jkivilinherbertx
authored andcommitted
crypto: blowfish - rename C-version to blowfish_generic
Rename blowfish to blowfish_generic so that assembler versions of blowfish cipher can autoload. Module alias 'blowfish' is added. Also fix checkpatch warnings. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 52ba867 commit 3f2a5d2

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎crypto/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ obj-$(CONFIG_CRYPTO_PCRYPT) += pcrypt.o
6060
obj-$(CONFIG_CRYPTO_CRYPTD) += cryptd.o
6161
obj-$(CONFIG_CRYPTO_DES) += des_generic.o
6262
obj-$(CONFIG_CRYPTO_FCRYPT) += fcrypt.o
63-
obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
63+
obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish_generic.o
6464
obj-$(CONFIG_CRYPTO_BLOWFISH_COMMON) += blowfish_common.o
6565
obj-$(CONFIG_CRYPTO_TWOFISH) += twofish_generic.o
6666
obj-$(CONFIG_CRYPTO_TWOFISH_COMMON) += twofish_common.o
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
#define GET32_0(x) (((x) >> (24)) & (0xff))
3535

3636
#define bf_F(x) (((S[GET32_0(x)] + S[256 + GET32_1(x)]) ^ \
37-
S[512 + GET32_2(x)]) + S[768 + GET32_3(x)])
37+
S[512 + GET32_2(x)]) + S[768 + GET32_3(x)])
3838

39-
#define ROUND(a, b, n) b ^= P[n]; a ^= bf_F (b)
39+
#define ROUND(a, b, n) ({ b ^= P[n]; a ^= bf_F(b); })
4040

4141
static void bf_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
4242
{
@@ -108,6 +108,8 @@ static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
108108

109109
static struct crypto_alg alg = {
110110
.cra_name = "blowfish",
111+
.cra_driver_name = "blowfish-generic",
112+
.cra_priority = 100,
111113
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
112114
.cra_blocksize = BF_BLOCK_SIZE,
113115
.cra_ctxsize = sizeof(struct bf_ctx),
@@ -118,8 +120,8 @@ static struct crypto_alg alg = {
118120
.cia_min_keysize = BF_MIN_KEY_SIZE,
119121
.cia_max_keysize = BF_MAX_KEY_SIZE,
120122
.cia_setkey = blowfish_setkey,
121-
.cia_encrypt = bf_encrypt,
122-
.cia_decrypt = bf_decrypt } }
123+
.cia_encrypt = bf_encrypt,
124+
.cia_decrypt = bf_decrypt } }
123125
};
124126

125127
static int __init blowfish_mod_init(void)
@@ -137,3 +139,4 @@ module_exit(blowfish_mod_fini);
137139

138140
MODULE_LICENSE("GPL");
139141
MODULE_DESCRIPTION("Blowfish Cipher Algorithm");
142+
MODULE_ALIAS("blowfish");

0 commit comments

Comments
 (0)