Pol  Revision:3cfda13
twofish.h File Reference

Go to the source code of this file.

Classes

struct  Pol::Crypt::tagcipherInstance
 
struct  Pol::Crypt::tagkeyInstance
 
class  Pol::Crypt::TwoFish
 

Namespaces

 Pol
 
 Pol::Crypt
 

Macros

#define _b(x, N)   ( ( (unsigned char*)&x )[( (N)&3 ) ^ 0] )
 
#define Bswap(x)   ( x )
 
#define LFSR1(x)   ( ( ( x ) >> 1 ) ^ ( ( (x)&0x01 ) ? 0x169 / 2 : 0 ) )
 
#define LFSR2(x)   ( ( ( x ) >> 2 ) ^ ( ( (x)&0x02 ) ? 0x169 / 2 : 0 ) ^ ( ( (x)&0x01 ) ? 0x169 / 4 : 0 ) )
 
#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 Mx_1(x)   ( (unsigned int)( x ) )
 
#define Mx_X(x)   ( (unsigned int)( ( x ) ^ LFSR2( x ) ) )
 
#define Mx_Y(x)   ( (unsigned int)( ( x ) ^ LFSR1( x ) ^ LFSR2( x ) ) )
 
#define p8(N)   P8x8[P_##N]
 
#define P_00   1
 
#define P_01   0
 
#define P_02   0
 
#define P_03   ( P_01 ^ 1 )
 
#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 ROL(x, n)   ( ( ( x ) << ( (n)&0x1F ) ) | ( ( x ) >> ( 32 - ( (n)&0x1F ) ) ) )
 
#define ROR(x, n)   ( ( ( x ) >> ( (n)&0x1F ) ) | ( ( x ) << ( 32 - ( (n)&0x1F ) ) ) )
 
#define RS_rem(x)
 

Typedefs

typedef struct Pol::Crypt::tagcipherInstance Pol::Crypt::CipherInstance
 
typedef struct Pol::Crypt::tagkeyInstance Pol::Crypt::KeyInstance
 

Macro Definition Documentation

#define _b (   x,
 
)    ( ( (unsigned char*)&x )[( (N)&3 ) ^ 0] )

Definition at line 129 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

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

Definition at line 81 of file twofish.h.

#define LFSR2 (   x)    ( ( ( x ) >> 2 ) ^ ( ( (x)&0x02 ) ? 0x169 / 2 : 0 ) ^ ( ( (x)&0x01 ) ? 0x169 / 4 : 0 ) )

Definition at line 82 of file twofish.h.

#define M00   Mul_1

Definition at line 87 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M01   Mul_Y

Definition at line 88 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M02   Mul_X

Definition at line 89 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M03   Mul_X

Definition at line 90 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M10   Mul_X

Definition at line 91 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M11   Mul_Y

Definition at line 92 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M12   Mul_Y

Definition at line 93 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M13   Mul_1

Definition at line 94 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M20   Mul_Y

Definition at line 95 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M21   Mul_X

Definition at line 96 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M22   Mul_1

Definition at line 97 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M23   Mul_Y

Definition at line 98 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M30   Mul_Y

Definition at line 99 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M31   Mul_1

Definition at line 100 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M32   Mul_Y

Definition at line 101 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define M33   Mul_X

Definition at line 102 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define Mul_1   Mx_1

Definition at line 103 of file twofish.h.

#define Mul_X   Mx_X

Definition at line 104 of file twofish.h.

#define Mul_Y   Mx_Y

Definition at line 105 of file twofish.h.

#define Mx_1 (   x)    ( (unsigned int)( x ) )

Definition at line 84 of file twofish.h.

#define Mx_X (   x)    ( (unsigned int)( ( x ) ^ LFSR2( x ) ) )

Definition at line 85 of file twofish.h.

#define Mx_Y (   x)    ( (unsigned int)( ( x ) ^ LFSR1( x ) ^ LFSR2( x ) ) )

Definition at line 86 of file twofish.h.

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

Definition at line 72 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::F32().

#define P_00   1

Definition at line 106 of file twofish.h.

#define P_01   0

Definition at line 107 of file twofish.h.

#define P_02   0

Definition at line 108 of file twofish.h.

#define P_03   ( P_01 ^ 1 )

Definition at line 109 of file twofish.h.

#define P_04   1

Definition at line 110 of file twofish.h.

#define P_10   0

Definition at line 111 of file twofish.h.

#define P_11   0

Definition at line 112 of file twofish.h.

#define P_12   1

Definition at line 113 of file twofish.h.

#define P_13   ( P_11 ^ 1 )

Definition at line 114 of file twofish.h.

#define P_14   0

Definition at line 115 of file twofish.h.

#define P_20   1

Definition at line 116 of file twofish.h.

#define P_21   1

Definition at line 117 of file twofish.h.

#define P_22   0

Definition at line 118 of file twofish.h.

#define P_23   ( P_21 ^ 1 )

Definition at line 119 of file twofish.h.

#define P_24   0

Definition at line 120 of file twofish.h.

#define P_30   0

Definition at line 121 of file twofish.h.

#define P_31   1

Definition at line 122 of file twofish.h.

#define P_32   1

Definition at line 123 of file twofish.h.

#define P_33   ( P_31 ^ 1 )

Definition at line 124 of file twofish.h.

#define P_34   1

Definition at line 125 of file twofish.h.

#define ROL (   x,
 
)    ( ( ( x ) << ( (n)&0x1F ) ) | ( ( x ) >> ( 32 - ( (n)&0x1F ) ) ) )

Definition at line 126 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::BlockEncrypt(), and Pol::Crypt::TwoFish::ReKey().

#define ROR (   x,
 
)    ( ( ( x ) >> ( (n)&0x1F ) ) | ( ( x ) << ( 32 - ( (n)&0x1F ) ) ) )

Definition at line 127 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::BlockEncrypt().

#define RS_rem (   x)
Value:
{ \
unsigned char b = (unsigned char)( x >> 24 ); \
unsigned int g2 = ( ( b << 1 ) ^ ( ( b & 0x80 ) ? 0x14D : 0 ) ) & 0xFF; \
unsigned int g3 = ( ( b >> 1 ) & 0x7F ) ^ ( ( b & 1 ) ? 0x14D >> 1 : 0 ) ^ g2; \
x = ( x << 8 ) ^ ( g3 << 24 ) ^ ( g2 << 16 ) ^ ( g3 << 8 ) ^ b; \
}

Definition at line 73 of file twofish.h.

Referenced by Pol::Crypt::TwoFish::RS_MDS_Encode().