1 /* 2 * CAST-128 3 * (C) 1999-2007 Jack Lloyd 4 * 5 * Distributed under the terms of the Botan license 6 */ 7 8 #ifndef BOTAN_CAST128_H__ 9 #define BOTAN_CAST128_H__ 10 11 #include <botan/block_cipher.h> 12 13 namespace Botan { 14 15 /** 16 * CAST-128 17 */ 18 class BOTAN_DLL CAST_128 : public Block_Cipher_Fixed_Params<8, 11, 16> 19 { 20 public: 21 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 22 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 23 clear()24 void clear() { zeroise(MK); zeroise(RK); } name()25 std::string name() const { return "CAST-128"; } clone()26 BlockCipher* clone() const { return new CAST_128; } 27 CAST_128()28 CAST_128() : MK(16), RK(16) {} 29 private: 30 void key_schedule(const byte[], size_t); 31 32 static void cast_ks(MemoryRegion<u32bit>& ks, 33 MemoryRegion<u32bit>& user_key); 34 35 static const u32bit S5[256]; 36 static const u32bit S6[256]; 37 static const u32bit S7[256]; 38 static const u32bit S8[256]; 39 40 SecureVector<u32bit> MK, RK; 41 }; 42 43 extern const u32bit CAST_SBOX1[256]; 44 extern const u32bit CAST_SBOX2[256]; 45 extern const u32bit CAST_SBOX3[256]; 46 extern const u32bit CAST_SBOX4[256]; 47 48 } 49 50 #endif 51