Skip to content

Commit 1fd5a46

Browse files
author
Linus Torvalds
committed
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
2 parents 2cc6055 + dff2c03 commit 1fd5a46

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1022
-747
lines changed

arch/i386/crypto/aes-i586-asm.S

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,17 @@ aes_enc_blk:
255255
xor 8(%ebp),%r4
256256
xor 12(%ebp),%r5
257257

258-
sub $8,%esp // space for register saves on stack
259-
add $16,%ebp // increment to next round key
260-
sub $10,%r3
261-
je 4f // 10 rounds for 128-bit key
262-
add $32,%ebp
263-
sub $2,%r3
264-
je 3f // 12 rounds for 128-bit key
265-
add $32,%ebp
266-
267-
2: fwd_rnd1( -64(%ebp) ,ft_tab) // 14 rounds for 128-bit key
258+
sub $8,%esp // space for register saves on stack
259+
add $16,%ebp // increment to next round key
260+
cmp $12,%r3
261+
jb 4f // 10 rounds for 128-bit key
262+
lea 32(%ebp),%ebp
263+
je 3f // 12 rounds for 192-bit key
264+
lea 32(%ebp),%ebp
265+
266+
2: fwd_rnd1( -64(%ebp) ,ft_tab) // 14 rounds for 256-bit key
268267
fwd_rnd2( -48(%ebp) ,ft_tab)
269-
3: fwd_rnd1( -32(%ebp) ,ft_tab) // 12 rounds for 128-bit key
268+
3: fwd_rnd1( -32(%ebp) ,ft_tab) // 12 rounds for 192-bit key
270269
fwd_rnd2( -16(%ebp) ,ft_tab)
271270
4: fwd_rnd1( (%ebp) ,ft_tab) // 10 rounds for 128-bit key
272271
fwd_rnd2( +16(%ebp) ,ft_tab)
@@ -334,18 +333,17 @@ aes_dec_blk:
334333
xor 8(%ebp),%r4
335334
xor 12(%ebp),%r5
336335

337-
sub $8,%esp // space for register saves on stack
338-
sub $16,%ebp // increment to next round key
339-
sub $10,%r3
340-
je 4f // 10 rounds for 128-bit key
341-
sub $32,%ebp
342-
sub $2,%r3
343-
je 3f // 12 rounds for 128-bit key
344-
sub $32,%ebp
336+
sub $8,%esp // space for register saves on stack
337+
sub $16,%ebp // increment to next round key
338+
cmp $12,%r3
339+
jb 4f // 10 rounds for 128-bit key
340+
lea -32(%ebp),%ebp
341+
je 3f // 12 rounds for 192-bit key
342+
lea -32(%ebp),%ebp
345343

346-
2: inv_rnd1( +64(%ebp), it_tab) // 14 rounds for 128-bit key
344+
2: inv_rnd1( +64(%ebp), it_tab) // 14 rounds for 256-bit key
347345
inv_rnd2( +48(%ebp), it_tab)
348-
3: inv_rnd1( +32(%ebp), it_tab) // 12 rounds for 128-bit key
346+
3: inv_rnd1( +32(%ebp), it_tab) // 12 rounds for 192-bit key
349347
inv_rnd2( +16(%ebp), it_tab)
350348
4: inv_rnd1( (%ebp), it_tab) // 10 rounds for 128-bit key
351349
inv_rnd2( -16(%ebp), it_tab)

arch/i386/crypto/aes.c

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
* Copyright (c) 2004 Red Hat, Inc., James Morris <[email protected]>
3737
*
3838
*/
39+
40+
#include <asm/byteorder.h>
3941
#include <linux/kernel.h>
4042
#include <linux/module.h>
4143
#include <linux/init.h>
@@ -59,7 +61,6 @@ struct aes_ctx {
5961
};
6062

6163
#define WPOLY 0x011b
62-
#define u32_in(x) le32_to_cpup((const __le32 *)(x))
6364
#define bytes2word(b0, b1, b2, b3) \
6465
(((u32)(b3) << 24) | ((u32)(b2) << 16) | ((u32)(b1) << 8) | (b0))
6566

@@ -93,7 +94,6 @@ static u32 rcon_tab[RC_LENGTH];
9394

9495
u32 ft_tab[4][256];
9596
u32 fl_tab[4][256];
96-
static u32 ls_tab[4][256];
9797
static u32 im_tab[4][256];
9898
u32 il_tab[4][256];
9999
u32 it_tab[4][256];
@@ -144,15 +144,6 @@ static void gen_tabs(void)
144144
fl_tab[2][i] = upr(w, 2);
145145
fl_tab[3][i] = upr(w, 3);
146146

147-
/*
148-
* table for key schedule if fl_tab above is
149-
* not of the required form
150-
*/
151-
ls_tab[0][i] = w;
152-
ls_tab[1][i] = upr(w, 1);
153-
ls_tab[2][i] = upr(w, 2);
154-
ls_tab[3][i] = upr(w, 3);
155-
156147
b = fi(inv_affine((u8)i));
157148
w = bytes2word(fe(b), f9(b), fd(b), fb(b));
158149

@@ -393,13 +384,14 @@ aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
393384
int i;
394385
u32 ss[8];
395386
struct aes_ctx *ctx = ctx_arg;
387+
const __le32 *key = (const __le32 *)in_key;
396388

397389
/* encryption schedule */
398390

399-
ctx->ekey[0] = ss[0] = u32_in(in_key);
400-
ctx->ekey[1] = ss[1] = u32_in(in_key + 4);
401-
ctx->ekey[2] = ss[2] = u32_in(in_key + 8);
402-
ctx->ekey[3] = ss[3] = u32_in(in_key + 12);
391+
ctx->ekey[0] = ss[0] = le32_to_cpu(key[0]);
392+
ctx->ekey[1] = ss[1] = le32_to_cpu(key[1]);
393+
ctx->ekey[2] = ss[2] = le32_to_cpu(key[2]);
394+
ctx->ekey[3] = ss[3] = le32_to_cpu(key[3]);
403395

404396
switch(key_len) {
405397
case 16:
@@ -410,19 +402,19 @@ aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
410402
break;
411403

412404
case 24:
413-
ctx->ekey[4] = ss[4] = u32_in(in_key + 16);
414-
ctx->ekey[5] = ss[5] = u32_in(in_key + 20);
405+
ctx->ekey[4] = ss[4] = le32_to_cpu(key[4]);
406+
ctx->ekey[5] = ss[5] = le32_to_cpu(key[5]);
415407
for (i = 0; i < 7; i++)
416408
ke6(ctx->ekey, i);
417409
kel6(ctx->ekey, 7);
418410
ctx->rounds = 12;
419411
break;
420412

421413
case 32:
422-
ctx->ekey[4] = ss[4] = u32_in(in_key + 16);
423-
ctx->ekey[5] = ss[5] = u32_in(in_key + 20);
424-
ctx->ekey[6] = ss[6] = u32_in(in_key + 24);
425-
ctx->ekey[7] = ss[7] = u32_in(in_key + 28);
414+
ctx->ekey[4] = ss[4] = le32_to_cpu(key[4]);
415+
ctx->ekey[5] = ss[5] = le32_to_cpu(key[5]);
416+
ctx->ekey[6] = ss[6] = le32_to_cpu(key[6]);
417+
ctx->ekey[7] = ss[7] = le32_to_cpu(key[7]);
426418
for (i = 0; i < 6; i++)
427419
ke8(ctx->ekey, i);
428420
kel8(ctx->ekey, 6);
@@ -436,10 +428,10 @@ aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
436428

437429
/* decryption schedule */
438430

439-
ctx->dkey[0] = ss[0] = u32_in(in_key);
440-
ctx->dkey[1] = ss[1] = u32_in(in_key + 4);
441-
ctx->dkey[2] = ss[2] = u32_in(in_key + 8);
442-
ctx->dkey[3] = ss[3] = u32_in(in_key + 12);
431+
ctx->dkey[0] = ss[0] = le32_to_cpu(key[0]);
432+
ctx->dkey[1] = ss[1] = le32_to_cpu(key[1]);
433+
ctx->dkey[2] = ss[2] = le32_to_cpu(key[2]);
434+
ctx->dkey[3] = ss[3] = le32_to_cpu(key[3]);
443435

444436
switch (key_len) {
445437
case 16:
@@ -450,19 +442,19 @@ aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
450442
break;
451443

452444
case 24:
453-
ctx->dkey[4] = ff(ss[4] = u32_in(in_key + 16));
454-
ctx->dkey[5] = ff(ss[5] = u32_in(in_key + 20));
445+
ctx->dkey[4] = ff(ss[4] = le32_to_cpu(key[4]));
446+
ctx->dkey[5] = ff(ss[5] = le32_to_cpu(key[5]));
455447
kdf6(ctx->dkey, 0);
456448
for (i = 1; i < 7; i++)
457449
kd6(ctx->dkey, i);
458450
kdl6(ctx->dkey, 7);
459451
break;
460452

461453
case 32:
462-
ctx->dkey[4] = ff(ss[4] = u32_in(in_key + 16));
463-
ctx->dkey[5] = ff(ss[5] = u32_in(in_key + 20));
464-
ctx->dkey[6] = ff(ss[6] = u32_in(in_key + 24));
465-
ctx->dkey[7] = ff(ss[7] = u32_in(in_key + 28));
454+
ctx->dkey[4] = ff(ss[4] = le32_to_cpu(key[4]));
455+
ctx->dkey[5] = ff(ss[5] = le32_to_cpu(key[5]));
456+
ctx->dkey[6] = ff(ss[6] = le32_to_cpu(key[6]));
457+
ctx->dkey[7] = ff(ss[7] = le32_to_cpu(key[7]));
466458
kdf8(ctx->dkey, 0);
467459
for (i = 1; i < 6; i++)
468460
kd8(ctx->dkey, i);
@@ -484,6 +476,8 @@ static inline void aes_decrypt(void *ctx, u8 *dst, const u8 *src)
484476

485477
static struct crypto_alg aes_alg = {
486478
.cra_name = "aes",
479+
.cra_driver_name = "aes-i586",
480+
.cra_priority = 200,
487481
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
488482
.cra_blocksize = AES_BLOCK_SIZE,
489483
.cra_ctxsize = sizeof(struct aes_ctx),

arch/x86_64/crypto/aes.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ static inline u8 byte(const u32 x, const unsigned n)
7474
return x >> (n << 3);
7575
}
7676

77-
#define u32_in(x) le32_to_cpu(*(const __le32 *)(x))
78-
7977
struct aes_ctx
8078
{
8179
u32 key_length;
@@ -234,6 +232,7 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len,
234232
u32 *flags)
235233
{
236234
struct aes_ctx *ctx = ctx_arg;
235+
const __le32 *key = (const __le32 *)in_key;
237236
u32 i, j, t, u, v, w;
238237

239238
if (key_len != 16 && key_len != 24 && key_len != 32) {
@@ -243,10 +242,10 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len,
243242

244243
ctx->key_length = key_len;
245244

246-
D_KEY[key_len + 24] = E_KEY[0] = u32_in(in_key);
247-
D_KEY[key_len + 25] = E_KEY[1] = u32_in(in_key + 4);
248-
D_KEY[key_len + 26] = E_KEY[2] = u32_in(in_key + 8);
249-
D_KEY[key_len + 27] = E_KEY[3] = u32_in(in_key + 12);
245+
D_KEY[key_len + 24] = E_KEY[0] = le32_to_cpu(key[0]);
246+
D_KEY[key_len + 25] = E_KEY[1] = le32_to_cpu(key[1]);
247+
D_KEY[key_len + 26] = E_KEY[2] = le32_to_cpu(key[2]);
248+
D_KEY[key_len + 27] = E_KEY[3] = le32_to_cpu(key[3]);
250249

251250
switch (key_len) {
252251
case 16:
@@ -256,17 +255,17 @@ static int aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len,
256255
break;
257256

258257
case 24:
259-
E_KEY[4] = u32_in(in_key + 16);
260-
t = E_KEY[5] = u32_in(in_key + 20);
258+
E_KEY[4] = le32_to_cpu(key[4]);
259+
t = E_KEY[5] = le32_to_cpu(key[5]);
261260
for (i = 0; i < 8; ++i)
262261
loop6 (i);
263262
break;
264263

265264
case 32:
266-
E_KEY[4] = u32_in(in_key + 16);
267-
E_KEY[5] = u32_in(in_key + 20);
268-
E_KEY[6] = u32_in(in_key + 24);
269-
t = E_KEY[7] = u32_in(in_key + 28);
265+
E_KEY[4] = le32_to_cpu(key[4]);
266+
E_KEY[5] = le32_to_cpu(key[5]);
267+
E_KEY[6] = le32_to_cpu(key[6]);
268+
t = E_KEY[7] = le32_to_cpu(key[7]);
270269
for (i = 0; i < 7; ++i)
271270
loop8(i);
272271
break;
@@ -290,6 +289,8 @@ extern void aes_decrypt(void *ctx_arg, u8 *out, const u8 *in);
290289

291290
static struct crypto_alg aes_alg = {
292291
.cra_name = "aes",
292+
.cra_driver_name = "aes-x86_64",
293+
.cra_priority = 200,
293294
.cra_flags = CRYPTO_ALG_TYPE_CIPHER,
294295
.cra_blocksize = AES_BLOCK_SIZE,
295296
.cra_ctxsize = sizeof(struct aes_ctx),

crypto/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ config CRYPTO_SERPENT
157157

158158
config CRYPTO_AES
159159
tristate "AES cipher algorithms"
160-
depends on CRYPTO && !(X86 || UML_X86)
160+
depends on CRYPTO
161161
help
162162
AES cipher algorithms (FIPS-197). AES uses the Rijndael
163163
algorithm.

0 commit comments

Comments
 (0)