Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
twofish_common.c File Reference
#include <crypto/twofish.h>
#include <linux/bitops.h>
#include <linux/crypto.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/types.h>

Go to the source code of this file.

Macros

#define CALC_S(a, b, c, d, i, w, x, y, z)
 
#define CALC_SB_2(i, a, b)
 
#define CALC_SB192_2(i, a, b)
 
#define CALC_SB256_2(i, a, b)
 
#define CALC_K_2(a, b, c, d, j)
 
#define CALC_K(a, j, k, l, m, n)
 
#define CALC_K192_2(a, b, c, d, j)
 
#define CALC_K192(a, j, k, l, m, n)
 
#define CALC_K256_2(a, b, j)
 
#define CALC_K256(a, j, k, l, m, n)
 

Functions

int __twofish_setkey (struct twofish_ctx *ctx, const u8 *key, unsigned int key_len, u32 *flags)
 
 EXPORT_SYMBOL_GPL (__twofish_setkey)
 
int twofish_setkey (struct crypto_tfm *tfm, const u8 *key, unsigned int key_len)
 
 EXPORT_SYMBOL_GPL (twofish_setkey)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_DESCRIPTION ("Twofish cipher common functions")
 

Macro Definition Documentation

#define CALC_K (   a,
  j,
  k,
  l,
  m,
  n 
)
Value:
x = CALC_K_2 (k, l, k, l, 0); \
y = CALC_K_2 (m, n, m, n, 4); \
y = rol32(y, 8); \
x += y; y += x; ctx->a[j] = x; \
ctx->a[(j) + 1] = rol32(y, 9)

Definition at line 549 of file twofish_common.c.

#define CALC_K192 (   a,
  j,
  k,
  l,
  m,
  n 
)
Value:
x = CALC_K192_2 (l, l, k, k, 0); \
y = CALC_K192_2 (n, n, m, m, 4); \
y = rol32(y, 8); \
x += y; y += x; ctx->a[j] = x; \
ctx->a[(j) + 1] = rol32(y, 9)

Definition at line 562 of file twofish_common.c.

#define CALC_K192_2 (   a,
  b,
  c,
  d,
  j 
)
Value:
CALC_K_2 (q0[a ^ key[(j) + 16]], \
q1[b ^ key[(j) + 17]], \
q0[c ^ key[(j) + 18]], \
q1[d ^ key[(j) + 19]], j)

Definition at line 556 of file twofish_common.c.

#define CALC_K256 (   a,
  j,
  k,
  l,
  m,
  n 
)
Value:
x = CALC_K256_2 (k, l, 0); \
y = CALC_K256_2 (m, n, 4); \
y = rol32(y, 8); \
x += y; y += x; ctx->a[j] = x; \
ctx->a[(j) + 1] = rol32(y, 9)

Definition at line 575 of file twofish_common.c.

#define CALC_K256_2 (   a,
  b,
  j 
)
Value:
CALC_K192_2 (q1[b ^ key[(j) + 24]], \
q1[a ^ key[(j) + 25]], \
q0[a ^ key[(j) + 26]], \
q0[b ^ key[(j) + 27]], j)

Definition at line 569 of file twofish_common.c.

#define CALC_K_2 (   a,
  b,
  c,
  d,
  j 
)
Value:
mds[0][q0[a ^ key[(j) + 8]] ^ key[j]] \
^ mds[1][q0[b ^ key[(j) + 9]] ^ key[(j) + 1]] \
^ mds[2][q1[c ^ key[(j) + 10]] ^ key[(j) + 2]] \
^ mds[3][q1[d ^ key[(j) + 11]] ^ key[(j) + 3]]

Definition at line 543 of file twofish_common.c.

#define CALC_S (   a,
  b,
  c,
  d,
  i,
  w,
  x,
  y,
 
)
Value:
if (key[i]) { \
tmp = poly_to_exp[key[i] - 1]; \
(a) ^= exp_to_poly[tmp + (w)]; \
(b) ^= exp_to_poly[tmp + (x)]; \
(c) ^= exp_to_poly[tmp + (y)]; \
(d) ^= exp_to_poly[tmp + (z)]; \
}

Definition at line 482 of file twofish_common.c.

#define CALC_SB192_2 (   i,
  a,
  b 
)
Value:
ctx->s[0][i] = mds[0][q0[q0[(b) ^ sa] ^ se] ^ si]; \
ctx->s[1][i] = mds[1][q0[q1[(b) ^ sb] ^ sf] ^ sj]; \
ctx->s[2][i] = mds[2][q1[q0[(a) ^ sc] ^ sg] ^ sk]; \
ctx->s[3][i] = mds[3][q1[q1[(a) ^ sd] ^ sh] ^ sl];

Definition at line 505 of file twofish_common.c.

#define CALC_SB256_2 (   i,
  a,
  b 
)
Value:
ctx->s[0][i] = mds[0][q0[q0[q1[(b) ^ sa] ^ se] ^ si] ^ sm]; \
ctx->s[1][i] = mds[1][q0[q1[q1[(a) ^ sb] ^ sf] ^ sj] ^ sn]; \
ctx->s[2][i] = mds[2][q1[q0[q0[(a) ^ sc] ^ sg] ^ sk] ^ so]; \
ctx->s[3][i] = mds[3][q1[q1[q0[(b) ^ sd] ^ sh] ^ sl] ^ sp];

Definition at line 513 of file twofish_common.c.

#define CALC_SB_2 (   i,
  a,
  b 
)
Value:
ctx->s[0][i] = mds[0][q0[(a) ^ sa] ^ se]; \
ctx->s[1][i] = mds[1][q0[(b) ^ sb] ^ sf]; \
ctx->s[2][i] = mds[2][q1[(a) ^ sc] ^ sg]; \
ctx->s[3][i] = mds[3][q1[(b) ^ sd] ^ sh]

Definition at line 497 of file twofish_common.c.

Function Documentation

int __twofish_setkey ( struct twofish_ctx ctx,
const u8 key,
unsigned int  key_len,
u32 flags 
)

Definition at line 583 of file twofish_common.c.

EXPORT_SYMBOL_GPL ( __twofish_setkey  )
EXPORT_SYMBOL_GPL ( twofish_setkey  )
MODULE_DESCRIPTION ( "Twofish cipher common functions"  )
MODULE_LICENSE ( "GPL"  )
int twofish_setkey ( struct crypto_tfm tfm,
const u8 key,
unsigned int  key_len 
)

Definition at line 703 of file twofish_common.c.