git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hwmon: add TI ads7871 a/d converter driver
[safe/jmp/linux-2.6]
/
crypto
/
blowfish.c
diff --git
a/crypto/blowfish.c
b/crypto/blowfish.c
index
99fc459
..
a67d52e
100644
(file)
--- a/
crypto/blowfish.c
+++ b/
crypto/blowfish.c
@@
-1,4
+1,4
@@
-/*
+/*
* Cryptographic API.
*
* Blowfish Cipher Algorithm, by Bruce Schneier.
* Cryptographic API.
*
* Blowfish Cipher Algorithm, by Bruce Schneier.
@@
-20,7
+20,6
@@
#include <linux/module.h>
#include <linux/mm.h>
#include <asm/byteorder.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <asm/byteorder.h>
-#include <asm/scatterlist.h>
#include <linux/crypto.h>
#include <linux/types.h>
#include <linux/crypto.h>
#include <linux/types.h>
@@
-300,7
+299,7
@@
static const u32 bf_sbox[256 * 4] = {
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
};
0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
};
-/*
+/*
* Round loop unrolling macros, S is a pointer to a S-Box array
* organized in 4 unsigned longs at a row.
*/
* Round loop unrolling macros, S is a pointer to a S-Box array
* organized in 4 unsigned longs at a row.
*/
@@
-316,7
+315,7
@@
static const u32 bf_sbox[256 * 4] = {
/*
* The blowfish encipher, processes 64-bit blocks.
/*
* The blowfish encipher, processes 64-bit blocks.
- * NOTE: This function MUSTN'T respect endianess
+ * NOTE: This function MUSTN'T respect endianess
*/
static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
{
*/
static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
{
@@
-349,7
+348,7
@@
static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
dst[1] = yl;
}
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;
{
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]);
in32[0] = be32_to_cpu(in_blk[0]);
in32[1] = be32_to_cpu(in_blk[1]);
- encrypt_block(c
tx
, out32, in32);
+ encrypt_block(c
rypto_tfm_ctx(tfm)
, out32, in32);
out_blk[0] = cpu_to_be32(out32[0]);
out_blk[1] = cpu_to_be32(out32[1]);
}
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 __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]);
u32 yl = be32_to_cpu(in_blk[0]);
u32 yr = be32_to_cpu(in_blk[1]);
@@
-395,15
+395,16
@@
static void bf_decrypt(void *ctx, u8 *dst, const u8 *src)
out_blk[1] = cpu_to_be32(yl);
}
out_blk[1] = cpu_to_be32(yl);
}
-/*
+/*
* Calculates the blowfish S and P boxes for encryption and decryption.
*/
* 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;
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++)
/* Copy the initialization s-boxes */
for (i = 0, count = 0; i < 256; i++)
@@
-416,10
+417,10
@@
static int bf_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
/* Actual subkey generation */
for (j = 0, i = 0; i < 16 + 2; i++) {
/* Actual subkey generation */
for (j = 0, i = 0; i < 16 + 2; i++) {
- temp = (((u32
)key[j] << 24) |
- ((u32
)key[(j + 1) % keylen] << 16) |
- ((u32
)key[(j + 2) % keylen] << 8) |
- ((u32
)key[(j + 3) % keylen]));
+ temp = (((u32)key[j] << 24) |
+ ((u32)key[(j + 1) % keylen] << 16) |
+ ((u32)key[(j + 2) % keylen] << 8) |
+ ((u32)key[(j + 3) % keylen]));
P[i] = P[i] ^ temp;
j = (j + 4) % keylen;
P[i] = P[i] ^ temp;
j = (j + 4) % keylen;
@@
-443,7
+444,7
@@
static int bf_setkey(void *ctx, const u8 *key, unsigned int keylen, u32 *flags)
S[count + 1] = data[1];
}
}
S[count + 1] = data[1];
}
}
-
+
/* Bruce says not to bother with the weak key check. */
return 0;
}
/* Bruce says not to bother with the weak key check. */
return 0;
}
@@
-453,6
+454,7
@@
static struct crypto_alg alg = {
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = BF_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct bf_ctx),
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = BF_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct bf_ctx),
+ .cra_alignmask = 3,
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(alg.cra_list),
.cra_u = { .cipher = {
.cra_module = THIS_MODULE,
.cra_list = LIST_HEAD_INIT(alg.cra_list),
.cra_u = { .cipher = {
@@
-463,18
+465,18
@@
static struct crypto_alg alg = {
.cia_decrypt = bf_decrypt } }
};
.cia_decrypt = bf_decrypt } }
};
-static int __init init(void)
+static int __init
blowfish_mod_
init(void)
{
return crypto_register_alg(&alg);
}
{
return crypto_register_alg(&alg);
}
-static void __exit fini(void)
+static void __exit
blowfish_mod_
fini(void)
{
crypto_unregister_alg(&alg);
}
{
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");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Blowfish Cipher Algorithm");