X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=crypto%2Fblowfish.c;h=6f5b487319220ebd3bfe9caef96c169e019b7ac2;hb=c4ede64a6e0220c9b30f07ab41080c8e90245116;hp=7f710b201f2059cf66f8e2ffb4c2002cd8e14115;hpb=a429d2609c153882c421b067ad5ae5a38851459e;p=safe%2Fjmp%2Flinux-2.6 diff --git a/crypto/blowfish.c b/crypto/blowfish.c index 7f710b2..6f5b487 100644 --- a/crypto/blowfish.c +++ b/crypto/blowfish.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include @@ -349,7 +348,7 @@ static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src) dst[1] = yl; } -static void bf_encrypt(void *ctx, u8 *dst, const u8 *src) +static void bf_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { const __be32 *in_blk = (const __be32 *)src; __be32 *const out_blk = (__be32 *)dst; @@ -357,17 +356,18 @@ static void bf_encrypt(void *ctx, u8 *dst, const u8 *src) in32[0] = be32_to_cpu(in_blk[0]); in32[1] = be32_to_cpu(in_blk[1]); - encrypt_block(ctx, out32, in32); + encrypt_block(crypto_tfm_ctx(tfm), out32, in32); out_blk[0] = cpu_to_be32(out32[0]); out_blk[1] = cpu_to_be32(out32[1]); } -static void bf_decrypt(void *ctx, u8 *dst, const u8 *src) +static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) { + struct bf_ctx *ctx = crypto_tfm_ctx(tfm); const __be32 *in_blk = (const __be32 *)src; __be32 *const out_blk = (__be32 *)dst; - const u32 *P = ((struct bf_ctx *)ctx)->p; - const u32 *S = ((struct bf_ctx *)ctx)->s; + const u32 *P = ctx->p; + const u32 *S = ctx->s; u32 yl = be32_to_cpu(in_blk[0]); u32 yr = be32_to_cpu(in_blk[1]); @@ -398,12 +398,13 @@ static void bf_decrypt(void *ctx, u8 *dst, const u8 *src) /* * Calculates the blowfish S and P boxes for encryption and decryption. */ -static int bf_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags) +static int bf_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { + struct bf_ctx *ctx = crypto_tfm_ctx(tfm); + u32 *P = ctx->p; + u32 *S = ctx->s; short i, j, count; u32 data[2], temp; - u32 *P = ((struct bf_ctx *)ctx)->p; - u32 *S = ((struct bf_ctx *)ctx)->s; /* Copy the initialization s-boxes */ for (i = 0, count = 0; i < 256; i++) @@ -464,18 +465,18 @@ static struct crypto_alg alg = { .cia_decrypt = bf_decrypt } } }; -static int __init init(void) +static int __init blowfish_mod_init(void) { return crypto_register_alg(&alg); } -static void __exit fini(void) +static void __exit blowfish_mod_fini(void) { crypto_unregister_alg(&alg); } -module_init(init); -module_exit(fini); +module_init(blowfish_mod_init); +module_exit(blowfish_mod_fini); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Blowfish Cipher Algorithm");