00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_SQUARE_H
00007 #define CRYPTOPP_SQUARE_H
00008
00009 #include "seckey.h"
00010 #include "secblock.h"
00011
00012 NAMESPACE_BEGIN(CryptoPP)
00013
00014
00015 struct Square_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, FixedRounds<8>
00016 {
00017 static const char *StaticAlgorithmName() {return "Square";}
00018 };
00019
00020
00021 class Square : public Square_Info, public BlockCipherDocumentation
00022 {
00023 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Square_Info>
00024 {
00025 public:
00026 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
00027
00028 protected:
00029 FixedSizeSecBlock<word32, 4*(ROUNDS+1)> m_roundkeys;
00030 };
00031
00032 class CRYPTOPP_NO_VTABLE Enc : public Base
00033 {
00034 public:
00035 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00036 private:
00037 static const byte Se[256];
00038 static const word32 Te[4][256];
00039 };
00040
00041 class CRYPTOPP_NO_VTABLE Dec : public Base
00042 {
00043 public:
00044 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00045 private:
00046 static const byte Sd[256];
00047 static const word32 Td[4][256];
00048 };
00049
00050 public:
00051 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00052 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00053 };
00054
00055 typedef Square::Encryption SquareEncryption;
00056 typedef Square::Decryption SquareDecryption;
00057
00058 NAMESPACE_END
00059
00060 #endif