1 /* 2 * CAST-256 3 * (C) 1999-2007 Jack Lloyd 4 * 5 * Distributed under the terms of the Botan license 6 */ 7 8 #ifndef BOTAN_CAST256_H__ 9 #define BOTAN_CAST256_H__ 10 11 #include <botan/block_cipher.h> 12 13 namespace Botan { 14 15 /** 16 * CAST-256 17 */ 18 class BOTAN_DLL CAST_256 : public Block_Cipher_Fixed_Params<16, 4, 32, 4> 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-256"; } clone()26 BlockCipher* clone() const { return new CAST_256; } 27 CAST_256()28 CAST_256() : MK(48), RK(48) {} 29 private: 30 void key_schedule(const byte[], size_t); 31 32 static const u32bit KEY_MASK[192]; 33 static const byte KEY_ROT[32]; 34 35 SecureVector<u32bit> MK; 36 SecureVector<byte> RK; 37 }; 38 39 extern const u32bit CAST_SBOX1[256]; 40 extern const u32bit CAST_SBOX2[256]; 41 extern const u32bit CAST_SBOX3[256]; 42 extern const u32bit CAST_SBOX4[256]; 43 44 } 45 46 #endif 47