git://git.onelab.eu
/
linux-2.6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git]
/
crypto
/
blowfish.c
diff --git
a/crypto/blowfish.c
b/crypto/blowfish.c
index
8fd18dc
..
55238c4
100644
(file)
--- a/
crypto/blowfish.c
+++ b/
crypto/blowfish.c
@@
-3,9
+3,9
@@
*
* Blowfish Cipher Algorithm, by Bruce Schneier.
* http://www.counterpane.com/blowfish.html
*
* Blowfish Cipher Algorithm, by Bruce Schneier.
* http://www.counterpane.com/blowfish.html
- *
- * Adap
a
ted from Kerneli implementation.
- *
+ *
+ * Adapted from Kerneli implementation.
+ *
* Copyright (c) Herbert Valerio Riedel <hvr@hvrlab.org>
* Copyright (c) Kyle McMartin <kyle@debian.org>
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
* Copyright (c) Herbert Valerio Riedel <hvr@hvrlab.org>
* Copyright (c) Kyle McMartin <kyle@debian.org>
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
@@
-19,8
+19,10
@@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mm.h>
+#include <asm/byteorder.h>
#include <asm/scatterlist.h>
#include <linux/crypto.h>
#include <asm/scatterlist.h>
#include <linux/crypto.h>
+#include <linux/types.h>
#define BF_BLOCK_SIZE 8
#define BF_MIN_KEY_SIZE 4
#define BF_BLOCK_SIZE 8
#define BF_MIN_KEY_SIZE 4
@@
-316,7
+318,7
@@
static const u32 bf_sbox[256 * 4] = {
* The blowfish encipher, processes 64-bit blocks.
* NOTE: This function MUSTN'T respect endianess
*/
* The blowfish encipher, processes 64-bit blocks.
* NOTE: This function MUSTN'T respect endianess
*/
-static
inline
void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
+static void encrypt_block(struct bf_ctx *bctx, u32 *dst, u32 *src)
{
const u32 *P = bctx->p;
const u32 *S = bctx->s;
{
const u32 *P = bctx->p;
const u32 *S = bctx->s;
@@
-347,25
+349,26
@@
static inline 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
u32 *in_blk = (const u
32 *)src;
-
u32 *const out_blk = (u
32 *)dst;
+ const
__be32 *in_blk = (const __be
32 *)src;
+
__be32 *const out_blk = (__be
32 *)dst;
u32 in32[2], out32[2];
in32[0] = be32_to_cpu(in_blk[0]);
in32[1] = be32_to_cpu(in_blk[1]);
u32 in32[2], out32[2];
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)
{
{
- const u32 *in_blk = (const u32 *)src;
- u32 *const out_blk = (u32 *)dst;
- const u32 *P = ((struct bf_ctx *)ctx)->p;
- const u32 *S = ((struct bf_ctx *)ctx)->s;
+ struct bf_ctx *ctx = crypto_tfm_ctx(tfm);
+ const __be32 *in_blk = (const __be32 *)src;
+ __be32 *const out_blk = (__be32 *)dst;
+ 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]);
@@
-396,12
+399,13
@@
static void bf_decrypt(void *ctx, u8 *dst, const u8 *src)
/*
* 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++)
@@
-451,6
+455,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 = {