thig_table.h File Reference


Detailed Description

Tables, macros, constants for Twofish S-boxes and MDS matrix.

Note:
Code taken from http://www.schneier.com/twofish-download.html
TABLE.H -- Tables, macros, constants for Twofish S-boxes and MDS matrix

Submitters: Bruce Schneier, Counterpane Systems Doug Whiting, Hi/fn John Kelsey, Counterpane Systems Chris Hall, Counterpane Systems David Wagner, UC Berkeley

Code Author: Doug Whiting, Hi/fn

Version 1.00 April 1998

Copyright 1998, Hi/fn and Counterpane Systems. All rights reserved.

Notes: Tab size is set to 4 characters in this file These definitions should be used in optimized and unoptimized versions to insure consistency.

Definition in file thig_table.h.

Go to the source code of this file.

Defines

#define SK_STEP   0x02020202u
#define SK_BUMP   0x01010101u
#define SK_ROTL   9
#define RS_GF_FDBK   0x14D
#define RS_rem(x)
#define MDS_GF_FDBK   0x169
 primitive polynomial for GF(256)
#define LFSR1(x)   ( ((x) >> 1) ^ (((x) & 0x01) ? MDS_GF_FDBK/2 : 0))
#define LFSR2(x)
#define Mx_1(x)   ((DWORD) (x))
#define Mx_X(x)   ((DWORD) ((x) ^ LFSR2(x)))
#define Mx_Y(x)   ((DWORD) ((x) ^ LFSR1(x) ^ LFSR2(x)))
#define M00   Mul_1
#define M01   Mul_Y
#define M02   Mul_X
#define M03   Mul_X
#define M10   Mul_X
#define M11   Mul_Y
#define M12   Mul_Y
#define M13   Mul_1
#define M20   Mul_Y
#define M21   Mul_X
#define M22   Mul_1
#define M23   Mul_Y
#define M30   Mul_Y
#define M31   Mul_1
#define M32   Mul_Y
#define M33   Mul_X
#define Mul_1   Mx_1
#define Mul_X   Mx_X
#define Mul_Y   Mx_Y
#define P_00   1
 Define the fixed p0/p1 permutations used in keyed S-box lookup. "outermost" permutation.
#define P_01   0
#define P_02   0
#define P_03   (P_01^1)
 "extend" to larger key sizes
#define P_04   1
#define P_10   0
#define P_11   0
#define P_12   1
#define P_13   (P_11^1)
#define P_14   0
#define P_20   1
#define P_21   1
#define P_22   0
#define P_23   (P_21^1)
#define P_24   0
#define P_30   0
#define P_31   1
#define P_32   1
#define P_33   (P_31^1)
#define P_34   1
#define p8(N)   P8x8[P_##N]

Variables

CONST BYTE P8x8 [2][256]
 fixed 8x8 permutation S-boxes


Define Documentation

#define SK_STEP   0x02020202u

Definition at line 34 of file thig_table.h.

Referenced by reKey().

#define SK_BUMP   0x01010101u

Definition at line 35 of file thig_table.h.

Referenced by reKey().

#define SK_ROTL   9

Definition at line 36 of file thig_table.h.

Referenced by reKey().

#define RS_GF_FDBK   0x14D

Definition at line 41 of file thig_table.h.

#define RS_rem (  ) 

Value:

{ BYTE  b  = (BYTE) (x >> 24);                                           \
      DWORD g2 = ((b << 1) ^ ((b & 0x80) ? RS_GF_FDBK : 0 )) & 0xFF;         \
      DWORD g3 = ((b >> 1) & 0x7F) ^ ((b & 1) ? RS_GF_FDBK >> 1 : 0 ) ^ g2 ; \
      x = (x << 8) ^ (g3 << 24) ^ (g2 << 16) ^ (g3 << 8) ^ b;                \
    }

Definition at line 42 of file thig_table.h.

Referenced by RS_MDS_Encode().

#define MDS_GF_FDBK   0x169

primitive polynomial for GF(256)

Definition at line 73 of file thig_table.h.

#define LFSR1 (  )     ( ((x) >> 1) ^ (((x) & 0x01) ? MDS_GF_FDBK/2 : 0))

Definition at line 74 of file thig_table.h.

#define LFSR2 (  ) 

Value:

( ((x) >> 2)  ^ (((x) & 0x02) ?   MDS_GF_FDBK/2 : 0)  \
                               ^ (((x) & 0x01) ?   MDS_GF_FDBK/4 : 0))

Definition at line 75 of file thig_table.h.

#define Mx_1 (  )     ((DWORD) (x))

Definition at line 78 of file thig_table.h.

#define Mx_X (  )     ((DWORD) ((x) ^ LFSR2(x)))

Definition at line 79 of file thig_table.h.

#define Mx_Y (  )     ((DWORD) ((x) ^ LFSR1(x) ^ LFSR2(x)))

Definition at line 80 of file thig_table.h.

#define M00   Mul_1

Definition at line 82 of file thig_table.h.

Referenced by f32().

#define M01   Mul_Y

Definition at line 83 of file thig_table.h.

Referenced by f32().

#define M02   Mul_X

Definition at line 84 of file thig_table.h.

Referenced by f32().

#define M03   Mul_X

Definition at line 85 of file thig_table.h.

Referenced by f32().

#define M10   Mul_X

Definition at line 87 of file thig_table.h.

Referenced by f32().

#define M11   Mul_Y

Definition at line 88 of file thig_table.h.

Referenced by f32().

#define M12   Mul_Y

Definition at line 89 of file thig_table.h.

Referenced by f32().

#define M13   Mul_1

Definition at line 90 of file thig_table.h.

Referenced by f32().

#define M20   Mul_Y

Definition at line 92 of file thig_table.h.

Referenced by f32().

#define M21   Mul_X

Definition at line 93 of file thig_table.h.

Referenced by f32().

#define M22   Mul_1

Definition at line 94 of file thig_table.h.

Referenced by f32().

#define M23   Mul_Y

Definition at line 95 of file thig_table.h.

Referenced by f32().

#define M30   Mul_Y

Definition at line 97 of file thig_table.h.

Referenced by f32().

#define M31   Mul_1

Definition at line 98 of file thig_table.h.

Referenced by f32().

#define M32   Mul_Y

Definition at line 99 of file thig_table.h.

Referenced by f32().

#define M33   Mul_X

Definition at line 100 of file thig_table.h.

Referenced by f32().

#define Mul_1   Mx_1

Definition at line 102 of file thig_table.h.

#define Mul_X   Mx_X

Definition at line 103 of file thig_table.h.

#define Mul_Y   Mx_Y

Definition at line 104 of file thig_table.h.

#define P_00   1

Define the fixed p0/p1 permutations used in keyed S-box lookup. "outermost" permutation.

By changing the following constant definitions for P_ij, the S-boxes will automatically get changed in all the Twofish source code. Note that P_i0 is the "outermost" 8x8 permutation applied. See the f32() function to see how these constants are to be used.

Definition at line 112 of file thig_table.h.

Referenced by f32().

#define P_01   0

Definition at line 113 of file thig_table.h.

#define P_02   0

Definition at line 114 of file thig_table.h.

#define P_03   (P_01^1)

"extend" to larger key sizes

Definition at line 115 of file thig_table.h.

#define P_04   1

Definition at line 116 of file thig_table.h.

#define P_10   0

Definition at line 118 of file thig_table.h.

Referenced by f32().

#define P_11   0

Definition at line 119 of file thig_table.h.

#define P_12   1

Definition at line 120 of file thig_table.h.

#define P_13   (P_11^1)

Definition at line 121 of file thig_table.h.

#define P_14   0

Definition at line 122 of file thig_table.h.

#define P_20   1

Definition at line 124 of file thig_table.h.

Referenced by f32().

#define P_21   1

Definition at line 125 of file thig_table.h.

#define P_22   0

Definition at line 126 of file thig_table.h.

#define P_23   (P_21^1)

Definition at line 127 of file thig_table.h.

#define P_24   0

Definition at line 128 of file thig_table.h.

#define P_30   0

Definition at line 130 of file thig_table.h.

Referenced by f32().

#define P_31   1

Definition at line 131 of file thig_table.h.

#define P_32   1

Definition at line 132 of file thig_table.h.

#define P_33   (P_31^1)

Definition at line 133 of file thig_table.h.

#define P_34   1

Definition at line 134 of file thig_table.h.

#define p8 (  )     P8x8[P_##N]

Definition at line 136 of file thig_table.h.

Referenced by f32().


Variable Documentation

CONST BYTE P8x8[2][256]

fixed 8x8 permutation S-boxes

Definition at line 150 of file thig_table.h.


Generated on Thu Oct 23 04:14:41 2008 for Open IMS Core CSCFs by  doxygen 1.5.2