23 #ifndef TAO_CRYPT_TWOFISH_HPP
24 #define TAO_CRYPT_TWOFISH_HPP
31 #include "algorithm.hpp"
35 namespace STL = STL_NAMESPACE;
38 #if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
39 #define DO_TWOFISH_ASM
44 enum { TWOFISH_BLOCK_SIZE = 16 };
50 enum { BLOCK_SIZE = TWOFISH_BLOCK_SIZE };
52 Twofish(CipherDir DIR, Mode MODE)
56 void Process(byte*,
const byte*, word32);
58 void SetKey(
const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
59 void SetIV(
const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
61 static const byte q_[2][256];
62 static const word32 mds_[4][256];
67 static word32 h0(word32 x,
const word32 *key,
unsigned int kLen);
68 static word32 h(word32 x,
const word32 *key,
unsigned int kLen);
70 void ProcessAndXorBlock(
const byte*,
const byte*, byte*)
const;
72 void encrypt(
const byte*,
const byte*, byte*)
const;
73 void decrypt(
const byte*,
const byte*, byte*)
const;
75 void AsmEncrypt(
const byte* inBlock, byte* outBlock)
const;
76 void AsmDecrypt(
const byte* inBlock, byte* outBlock)
const;
93 #endif // TAO_CRYPT_TWOFISH_HPP