46 void Init(
unsigned char* gseed );
47 void Decrypt(
unsigned char* in,
unsigned char* out,
int len );
49 unsigned char subData3[256];
52 static unsigned int RS_MDS_Encode(
unsigned int k0,
unsigned int k1 );
53 static unsigned int F32(
unsigned int x,
unsigned int* k32,
int keyLen );
55 static void CipherInit(
CipherInstance* cipher,
unsigned char mode,
char* IV );
58 int inputLen,
unsigned char* outBuffer );
62 unsigned char tabUsed[256];
72 #define p8( N ) P8x8[P_##N] 75 unsigned char b = (unsigned char)( x >> 24 ); \ 76 unsigned int g2 = ( ( b << 1 ) ^ ( ( b & 0x80 ) ? 0x14D : 0 ) ) & 0xFF; \ 77 unsigned int g3 = ( ( b >> 1 ) & 0x7F ) ^ ( ( b & 1 ) ? 0x14D >> 1 : 0 ) ^ g2; \ 78 x = ( x << 8 ) ^ ( g3 << 24 ) ^ ( g2 << 16 ) ^ ( g3 << 8 ) ^ b; \ 81 #define LFSR1( x ) ( ( ( x ) >> 1 ) ^ ( ( (x)&0x01 ) ? 0x169 / 2 : 0 ) ) 83 ( ( ( x ) >> 2 ) ^ ( ( (x)&0x02 ) ? 0x169 / 2 : 0 ) ^ ( ( (x)&0x01 ) ? 0x169 / 4 : 0 ) ) 84 #define Mx_1( x ) ( (unsigned int)( x ) ) 85 #define Mx_X( x ) ( (unsigned int)( ( x ) ^ LFSR2( x ) ) ) 86 #define Mx_Y( x ) ( (unsigned int)( ( x ) ^ LFSR1( x ) ^ LFSR2( x ) ) ) 109 #define P_03 ( P_01 ^ 1 ) 114 #define P_13 ( P_11 ^ 1 ) 119 #define P_23 ( P_21 ^ 1 ) 124 #define P_33 ( P_31 ^ 1 ) 126 #define ROL( x, n ) ( ( ( x ) << ( (n)&0x1F ) ) | ( ( x ) >> ( 32 - ( (n)&0x1F ) ) ) ) 127 #define ROR( x, n ) ( ( ( x ) >> ( (n)&0x1F ) ) | ( ( x ) << ( 32 - ( (n)&0x1F ) ) ) ) 128 #define Bswap( x ) ( x ) 129 #define _b( x, N ) ( ( (unsigned char*)&x )[( (N)&3 ) ^ 0] ) 132 #endif //__TWOFISH_H__
struct Pol::Crypt::tagcipherInstance CipherInstance
struct Pol::Crypt::tagkeyInstance KeyInstance