Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
aes.c File Reference
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/errno.h>
#include "rtl_crypto.h"
#include <asm/byteorder.h>

Go to the source code of this file.

Data Structures

struct  aes_ctx
 

Macros

#define AES_MIN_KEY_SIZE   16
 
#define AES_MAX_KEY_SIZE   32
 
#define AES_BLOCK_SIZE   16
 
#define rotl   generic_rotl32
 
#define rotr   generic_rotr32
 
#define u32_in(x)   le32_to_cpu(*(const u32 *)(x))
 
#define u32_out(to, from)   (*(u32 *)(to) = cpu_to_le32(from))
 
#define E_KEY   ctx->E
 
#define D_KEY   ctx->D
 
#define ff_mult(a, b)   (a && b ? f_mult(a, b) : 0)
 
#define f_rn(bo, bi, n, k)
 
#define i_rn(bo, bi, n, k)
 
#define ls_box(x)
 
#define f_rl(bo, bi, n, k)
 
#define i_rl(bo, bi, n, k)
 
#define star_x(x)   (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)
 
#define imix_col(y, x)
 
#define loop4(i)
 
#define loop6(i)
 
#define loop8(i)
 
#define f_nround(bo, bi, k)
 
#define f_lround(bo, bi, k)
 
#define i_nround(bo, bi, k)
 
#define i_lround(bo, bi, k)
 

Functions

 module_init (aes_init)
 
 module_exit (aes_fini)
 
 MODULE_DESCRIPTION ("Rijndael (AES) Cipher Algorithm")
 
 MODULE_LICENSE ("Dual BSD/GPL")
 

Macro Definition Documentation

#define AES_BLOCK_SIZE   16

Definition at line 66 of file aes.c.

#define AES_MAX_KEY_SIZE   32

Definition at line 64 of file aes.c.

#define AES_MIN_KEY_SIZE   16

Definition at line 63 of file aes.c.

#define D_KEY   ctx->D

Definition at line 104 of file aes.c.

#define E_KEY   ctx->E

Definition at line 103 of file aes.c.

#define f_lround (   bo,
  bi,
  k 
)
Value:
f_rl(bo, bi, 0, k); \
f_rl(bo, bi, 1, k); \
f_rl(bo, bi, 2, k); \
f_rl(bo, bi, 3, k)

Definition at line 336 of file aes.c.

#define f_nround (   bo,
  bi,
  k 
)
Value:
f_rn(bo, bi, 0, k); \
f_rn(bo, bi, 1, k); \
f_rn(bo, bi, 2, k); \
f_rn(bo, bi, 3, k); \
k += 4

Definition at line 329 of file aes.c.

#define f_rl (   bo,
  bi,
  n,
  k 
)
Value:
bo[n] = fl_tab[0][byte(bi[n],0)] ^ \
fl_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
fl_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
fl_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)

Definition at line 145 of file aes.c.

#define f_rn (   bo,
  bi,
  n,
  k 
)
Value:
bo[n] = ft_tab[0][byte(bi[n],0)] ^ \
ft_tab[1][byte(bi[(n + 1) & 3],1)] ^ \
ft_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
ft_tab[3][byte(bi[(n + 3) & 3],3)] ^ *(k + n)

Definition at line 127 of file aes.c.

#define ff_mult (   a,
  b 
)    (a && b ? f_mult(a, b) : 0)

Definition at line 125 of file aes.c.

#define i_lround (   bo,
  bi,
  k 
)
Value:
i_rl(bo, bi, 0, k); \
i_rl(bo, bi, 1, k); \
i_rl(bo, bi, 2, k); \
i_rl(bo, bi, 3, k)

Definition at line 389 of file aes.c.

#define i_nround (   bo,
  bi,
  k 
)
Value:
i_rn(bo, bi, 0, k); \
i_rn(bo, bi, 1, k); \
i_rn(bo, bi, 2, k); \
i_rn(bo, bi, 3, k); \
k -= 4

Definition at line 382 of file aes.c.

#define i_rl (   bo,
  bi,
  n,
  k 
)
Value:
bo[n] = il_tab[0][byte(bi[n],0)] ^ \
il_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
il_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
il_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)

Definition at line 151 of file aes.c.

#define i_rn (   bo,
  bi,
  n,
  k 
)
Value:
bo[n] = it_tab[0][byte(bi[n],0)] ^ \
it_tab[1][byte(bi[(n + 3) & 3],1)] ^ \
it_tab[2][byte(bi[(n + 2) & 3],2)] ^ \
it_tab[3][byte(bi[(n + 1) & 3],3)] ^ *(k + n)

Definition at line 133 of file aes.c.

#define imix_col (   y,
  x 
)
Value:
u = star_x(x); \
v = star_x(u); \
w = star_x(v); \
t = w ^ (x); \
(y) = u ^ v ^ w; \
(y) ^= rotr(u ^ t, 8) ^ \
rotr(v ^ t, 16) ^ \
rotr(t,24)

Definition at line 230 of file aes.c.

#define loop4 (   i)
Value:
{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
t ^= E_KEY[4 * i]; E_KEY[4 * i + 4] = t; \
t ^= E_KEY[4 * i + 1]; E_KEY[4 * i + 5] = t; \
t ^= E_KEY[4 * i + 2]; E_KEY[4 * i + 6] = t; \
t ^= E_KEY[4 * i + 3]; E_KEY[4 * i + 7] = t; \
}

Definition at line 242 of file aes.c.

#define loop6 (   i)
Value:
{ t = rotr(t, 8); t = ls_box(t) ^ rco_tab[i]; \
t ^= E_KEY[6 * i]; E_KEY[6 * i + 6] = t; \
t ^= E_KEY[6 * i + 1]; E_KEY[6 * i + 7] = t; \
t ^= E_KEY[6 * i + 2]; E_KEY[6 * i + 8] = t; \
t ^= E_KEY[6 * i + 3]; E_KEY[6 * i + 9] = t; \
t ^= E_KEY[6 * i + 4]; E_KEY[6 * i + 10] = t; \
t ^= E_KEY[6 * i + 5]; E_KEY[6 * i + 11] = t; \
}

Definition at line 250 of file aes.c.

#define loop8 (   i)
Value:
{ t = rotr(t, 8); ; t = ls_box(t) ^ rco_tab[i]; \
t ^= E_KEY[8 * i]; E_KEY[8 * i + 8] = t; \
t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t; \
t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t; \
t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t; \
t = E_KEY[8 * i + 4] ^ ls_box(t); \
E_KEY[8 * i + 12] = t; \
t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t; \
t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t; \
t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t; \
}

Definition at line 260 of file aes.c.

#define ls_box (   x)
Value:
( fl_tab[0][byte(x, 0)] ^ \
fl_tab[1][byte(x, 1)] ^ \
fl_tab[2][byte(x, 2)] ^ \
fl_tab[3][byte(x, 3)] )

Definition at line 139 of file aes.c.

#define rotl   generic_rotl32

Definition at line 82 of file aes.c.

#define rotr   generic_rotr32

Definition at line 83 of file aes.c.

#define star_x (   x)    (((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b)

Definition at line 228 of file aes.c.

#define u32_in (   x)    le32_to_cpu(*(const u32 *)(x))

Definition at line 94 of file aes.c.

#define u32_out (   to,
  from 
)    (*(u32 *)(to) = cpu_to_le32(from))

Definition at line 95 of file aes.c.

Function Documentation

MODULE_DESCRIPTION ( "Rijndael (AES) Cipher Algorithm"  )
module_exit ( aes_fini  )
module_init ( aes_init  )
MODULE_LICENSE ( "Dual BSD/GPL"  )