23 #ifndef TAO_CRYPT_BLOWFISH_HPP
24 #define TAO_CRYPT_BLOWFISH_HPP
31 #include "algorithm.hpp"
35 namespace STL = STL_NAMESPACE;
38 #if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)
39 #define DO_BLOWFISH_ASM
45 enum { BLOWFISH_BLOCK_SIZE = 8 };
51 enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };
54 :
Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {}
56 #ifdef DO_BLOWFISH_ASM
57 void Process(byte*,
const byte*, word32);
59 void SetKey(
const byte* key, word32 sz, CipherDir fake = ENCRYPTION);
60 void SetIV(
const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }
62 static const word32 p_init_[ROUNDS + 2];
63 static const word32 s_init_[4 * 256];
65 word32 pbox_[ROUNDS + 2 + 4 * 256];
68 void crypt_block(
const word32 in[2], word32 out[2])
const;
69 void AsmProcess(
const byte* in, byte* out)
const;
70 void ProcessAndXorBlock(
const byte*,
const byte*, byte*)
const;
87 #endif // TAO_CRYPT_BLOWFISH_HPP