Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:09

0001 // square.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file square.h

0004 /// \brief Classes for the Square block cipher

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 /// \brief Square block cipher information

0015 /// \since Crypto++ 2.2

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 /// \brief Square block cipher

0022 /// \sa <a href="http://www.cryptopp.com/wiki/Square">Square</a>

0023 /// \since Crypto++ 2.2

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 &params);
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