Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

cast.h

Go to the documentation of this file.
00001 #ifndef CRYPTOPP_CAST_H 00002 #define CRYPTOPP_CAST_H 00003 00004 /** \file 00005 */ 00006 00007 #include "seckey.h" 00008 #include "secblock.h" 00009 00010 NAMESPACE_BEGIN(CryptoPP) 00011 00012 class CAST 00013 { 00014 protected: 00015 static const word32 S[8][256]; 00016 }; 00017 00018 //! algorithm info 00019 struct CAST128_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 5, 16> 00020 { 00021 static const char *StaticAlgorithmName() {return "CAST-128";} 00022 }; 00023 00024 /// <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-128">CAST-128</a> 00025 class CAST128 : public CAST128_Info, public BlockCipherDocumentation 00026 { 00027 class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST128_Info> 00028 { 00029 public: 00030 void UncheckedSetKey(CipherDir direction, const byte *userKey, unsigned int length); 00031 00032 protected: 00033 bool reduced; 00034 FixedSizeSecBlock<word32, 32> K; 00035 }; 00036 00037 class CRYPTOPP_NO_VTABLE Enc : public Base 00038 { 00039 public: 00040 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 00041 }; 00042 00043 class CRYPTOPP_NO_VTABLE Dec : public Base 00044 { 00045 public: 00046 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 00047 }; 00048 00049 public: 00050 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption; 00051 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption; 00052 }; 00053 00054 //! algorithm info 00055 struct CAST256_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 16, 32> 00056 { 00057 static const char *StaticAlgorithmName() {return "CAST-256";} 00058 }; 00059 00060 //! <a href="http://www.weidai.com/scan-mirror/cs.html#CAST-256">CAST-256</a> 00061 class CAST256 : public CAST256_Info, public BlockCipherDocumentation 00062 { 00063 class CRYPTOPP_NO_VTABLE Base : public CAST, public BlockCipherImpl<CAST256_Info> 00064 { 00065 public: 00066 void UncheckedSetKey(CipherDir direction, const byte *userKey, unsigned int length = 8); 00067 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; 00068 00069 protected: 00070 static const word32 t_m[8][24]; 00071 static const unsigned int t_r[8][24]; 00072 00073 static void Omega(int i, word32 kappa[8]); 00074 00075 FixedSizeSecBlock<word32, 8*12> K; 00076 }; 00077 00078 public: 00079 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption; 00080 typedef BlockCipherFinal<DECRYPTION, Base> Decryption; 00081 }; 00082 00083 typedef CAST128::Encryption CAST128Encryption; 00084 typedef CAST128::Decryption CAST128Decryption; 00085 00086 typedef CAST256::Encryption CAST256Encryption; 00087 typedef CAST256::Decryption CAST256Decryption; 00088 00089 NAMESPACE_END 00090 00091 #endif

Generated on Wed Jul 21 19:15:21 2004 for Crypto++ by doxygen 1.3.7-20040704