File indexing completed on 2025-01-18 09:55:09
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_SQUARE_H
0007 #define CRYPTOPP_SQUARE_H
0008
0009 #include "seckey.h"
0010 #include "secblock.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015
0016 struct Square_Info : public FixedBlockSize<16>, public FixedKeyLength<16>, FixedRounds<8>
0017 {
0018 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Square";}
0019 };
0020
0021
0022
0023
0024 class Square : public Square_Info, public BlockCipherDocumentation
0025 {
0026 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Square_Info>
0027 {
0028 public:
0029 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
0030
0031 protected:
0032 FixedSizeSecBlock<word32, 4*(ROUNDS+1)> m_roundkeys;
0033 };
0034
0035 class CRYPTOPP_NO_VTABLE Enc : public Base
0036 {
0037 public:
0038 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0039 private:
0040 static const byte Se[256];
0041 static const word32 Te[4][256];
0042 };
0043
0044 class CRYPTOPP_NO_VTABLE Dec : public Base
0045 {
0046 public:
0047 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0048 private:
0049 static const byte Sd[256];
0050 static const word32 Td[4][256];
0051 };
0052
0053 public:
0054 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0055 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0056 };
0057
0058 typedef Square::Encryption SquareEncryption;
0059 typedef Square::Decryption SquareDecryption;
0060
0061 NAMESPACE_END
0062
0063 #endif