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]
/
arch
/
i386
/
crypto
/
aes.c
diff --git
a/arch/i386/crypto/aes.c
b/arch/i386/crypto/aes.c
index
5a34ee9
..
49aad93
100644
(file)
--- a/
arch/i386/crypto/aes.c
+++ b/
arch/i386/crypto/aes.c
@@
-36,6
+36,8
@@
* Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
*
*/
* Copyright (c) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
*
*/
+
+#include <asm/byteorder.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@
-43,8
+45,8
@@
#include <linux/crypto.h>
#include <linux/linkage.h>
#include <linux/crypto.h>
#include <linux/linkage.h>
-asmlinkage void aes_enc_blk(
const u8 *src, u8 *dst, void *ctx
);
-asmlinkage void aes_dec_blk(
const u8 *src, u8 *dst, void *ctx
);
+asmlinkage void aes_enc_blk(
struct crypto_tfm *tfm, u8 *dst, const u8 *src
);
+asmlinkage void aes_dec_blk(
struct crypto_tfm *tfm, u8 *dst, const u8 *src
);
#define AES_MIN_KEY_SIZE 16
#define AES_MAX_KEY_SIZE 32
#define AES_MIN_KEY_SIZE 16
#define AES_MAX_KEY_SIZE 32
@@
-59,7
+61,6
@@
struct aes_ctx {
};
#define WPOLY 0x011b
};
#define WPOLY 0x011b
-#define u32_in(x) le32_to_cpu(*(const u32 *)(x))
#define bytes2word(b0, b1, b2, b3) \
(((u32)(b3) << 24) | ((u32)(b2) << 16) | ((u32)(b1) << 8) | (b0))
#define bytes2word(b0, b1, b2, b3) \
(((u32)(b3) << 24) | ((u32)(b2) << 16) | ((u32)(b1) << 8) | (b0))
@@
-93,12
+94,11
@@
static u32 rcon_tab[RC_LENGTH];
u32 ft_tab[4][256];
u32 fl_tab[4][256];
u32 ft_tab[4][256];
u32 fl_tab[4][256];
-u32 ls_tab[4][256];
-u32 im_tab[4][256];
+static u32 im_tab[4][256];
u32 il_tab[4][256];
u32 it_tab[4][256];
u32 il_tab[4][256];
u32 it_tab[4][256];
-void gen_tabs(void)
+
static
void gen_tabs(void)
{
u32 i, w;
u8 pow[512], log[256];
{
u32 i, w;
u8 pow[512], log[256];
@@
-144,15
+144,6
@@
void gen_tabs(void)
fl_tab[2][i] = upr(w, 2);
fl_tab[3][i] = upr(w, 3);
fl_tab[2][i] = upr(w, 2);
fl_tab[3][i] = upr(w, 3);
- /*
- * table for key schedule if fl_tab above is
- * not of the required form
- */
- ls_tab[0][i] = w;
- ls_tab[1][i] = upr(w, 1);
- ls_tab[2][i] = upr(w, 2);
- ls_tab[3][i] = upr(w, 3);
-
b = fi(inv_affine((u8)i));
w = bytes2word(fe(b), f9(b), fd(b), fb(b));
b = fi(inv_affine((u8)i));
w = bytes2word(fe(b), f9(b), fd(b), fb(b));
@@
-387,19
+378,21
@@
void gen_tabs(void)
k[8*(i)+11] = ss[3]; \
}
k[8*(i)+11] = ss[3]; \
}
-static int
-
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags
)
+static int
aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
+
unsigned int key_len
)
{
int i;
u32 ss[8];
{
int i;
u32 ss[8];
- struct aes_ctx *ctx = ctx_arg;
+ struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
+ const __le32 *key = (const __le32 *)in_key;
+ u32 *flags = &tfm->crt_flags;
/* encryption schedule */
/* encryption schedule */
- ctx->ekey[0] = ss[0] =
u32_in(in_key
);
- ctx->ekey[1] = ss[1] =
u32_in(in_key + 4
);
- ctx->ekey[2] = ss[2] =
u32_in(in_key + 8
);
- ctx->ekey[3] = ss[3] =
u32_in(in_key + 12
);
+ ctx->ekey[0] = ss[0] =
le32_to_cpu(key[0]
);
+ ctx->ekey[1] = ss[1] =
le32_to_cpu(key[1]
);
+ ctx->ekey[2] = ss[2] =
le32_to_cpu(key[2]
);
+ ctx->ekey[3] = ss[3] =
le32_to_cpu(key[3]
);
switch(key_len) {
case 16:
switch(key_len) {
case 16:
@@
-410,8
+403,8
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
break;
case 24:
break;
case 24:
- ctx->ekey[4] = ss[4] =
u32_in(in_key + 16
);
- ctx->ekey[5] = ss[5] =
u32_in(in_key + 20
);
+ ctx->ekey[4] = ss[4] =
le32_to_cpu(key[4]
);
+ ctx->ekey[5] = ss[5] =
le32_to_cpu(key[5]
);
for (i = 0; i < 7; i++)
ke6(ctx->ekey, i);
kel6(ctx->ekey, 7);
for (i = 0; i < 7; i++)
ke6(ctx->ekey, i);
kel6(ctx->ekey, 7);
@@
-419,10
+412,10
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
break;
case 32:
break;
case 32:
- ctx->ekey[4] = ss[4] =
u32_in(in_key + 16
);
- ctx->ekey[5] = ss[5] =
u32_in(in_key + 20
);
- ctx->ekey[6] = ss[6] =
u32_in(in_key + 24
);
- ctx->ekey[7] = ss[7] =
u32_in(in_key + 28
);
+ ctx->ekey[4] = ss[4] =
le32_to_cpu(key[4]
);
+ ctx->ekey[5] = ss[5] =
le32_to_cpu(key[5]
);
+ ctx->ekey[6] = ss[6] =
le32_to_cpu(key[6]
);
+ ctx->ekey[7] = ss[7] =
le32_to_cpu(key[7]
);
for (i = 0; i < 6; i++)
ke8(ctx->ekey, i);
kel8(ctx->ekey, 6);
for (i = 0; i < 6; i++)
ke8(ctx->ekey, i);
kel8(ctx->ekey, 6);
@@
-436,10
+429,10
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
/* decryption schedule */
/* decryption schedule */
- ctx->dkey[0] = ss[0] =
u32_in(in_key
);
- ctx->dkey[1] = ss[1] =
u32_in(in_key + 4
);
- ctx->dkey[2] = ss[2] =
u32_in(in_key + 8
);
- ctx->dkey[3] = ss[3] =
u32_in(in_key + 12
);
+ ctx->dkey[0] = ss[0] =
le32_to_cpu(key[0]
);
+ ctx->dkey[1] = ss[1] =
le32_to_cpu(key[1]
);
+ ctx->dkey[2] = ss[2] =
le32_to_cpu(key[2]
);
+ ctx->dkey[3] = ss[3] =
le32_to_cpu(key[3]
);
switch (key_len) {
case 16:
switch (key_len) {
case 16:
@@
-450,8
+443,8
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
break;
case 24:
break;
case 24:
- ctx->dkey[4] = ff(ss[4] =
u32_in(in_key + 16
));
- ctx->dkey[5] = ff(ss[5] =
u32_in(in_key + 20
));
+ ctx->dkey[4] = ff(ss[4] =
le32_to_cpu(key[4]
));
+ ctx->dkey[5] = ff(ss[5] =
le32_to_cpu(key[5]
));
kdf6(ctx->dkey, 0);
for (i = 1; i < 7; i++)
kd6(ctx->dkey, i);
kdf6(ctx->dkey, 0);
for (i = 1; i < 7; i++)
kd6(ctx->dkey, i);
@@
-459,10
+452,10
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
break;
case 32:
break;
case 32:
- ctx->dkey[4] = ff(ss[4] =
u32_in(in_key + 16
));
- ctx->dkey[5] = ff(ss[5] =
u32_in(in_key + 20
));
- ctx->dkey[6] = ff(ss[6] =
u32_in(in_key + 24
));
- ctx->dkey[7] = ff(ss[7] =
u32_in(in_key + 28
));
+ ctx->dkey[4] = ff(ss[4] =
le32_to_cpu(key[4]
));
+ ctx->dkey[5] = ff(ss[5] =
le32_to_cpu(key[5]
));
+ ctx->dkey[6] = ff(ss[6] =
le32_to_cpu(key[6]
));
+ ctx->dkey[7] = ff(ss[7] =
le32_to_cpu(key[7]
));
kdf8(ctx->dkey, 0);
for (i = 1; i < 6; i++)
kd8(ctx->dkey, i);
kdf8(ctx->dkey, 0);
for (i = 1; i < 6; i++)
kd8(ctx->dkey, i);
@@
-472,18
+465,20
@@
aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
return 0;
}
return 0;
}
-static
inline void aes_encrypt(void *ctx
, u8 *dst, const u8 *src)
+static
void aes_encrypt(struct crypto_tfm *tfm
, u8 *dst, const u8 *src)
{
{
- aes_enc_blk(
src, dst, ctx
);
+ aes_enc_blk(
tfm, dst, src
);
}
}
-static inline void aes_decrypt(void *ctx, u8 *dst, const u8 *src)
+
+static void aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
{
{
- aes_dec_blk(
src, dst, ctx
);
+ aes_dec_blk(
tfm, dst, src
);
}
}
-
static struct crypto_alg aes_alg = {
.cra_name = "aes",
static struct crypto_alg aes_alg = {
.cra_name = "aes",
+ .cra_driver_name = "aes-i586",
+ .cra_priority = 200,
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
.cra_blocksize = AES_BLOCK_SIZE,
.cra_ctxsize = sizeof(struct aes_ctx),