Back to home page

EIC code displayed by LXR

 
 

    


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

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

0002 
0003 /// \file gost.h

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

0005 
0006 #ifndef CRYPTOPP_GOST_H
0007 #define CRYPTOPP_GOST_H
0008 
0009 #include "seckey.h"
0010 #include "secblock.h"
0011 
0012 NAMESPACE_BEGIN(CryptoPP)
0013 
0014 /// \brief GOST block cipher information

0015 /// \since Crypto++ 2.1

0016 struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
0017 {
0018     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "GOST";}
0019 };
0020 
0021 /// \brief GOST block cipher

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

0023 /// \since Crypto++ 2.1

0024 class GOST : public GOST_Info, public BlockCipherDocumentation
0025 {
0026     /// \brief GOST block cipher default operation

0027     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info>
0028     {
0029     public:
0030         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
0031 
0032     protected:
0033         static void PrecalculateSTable();
0034 
0035         static const byte sBox[8][16];
0036         static volatile bool sTableCalculated;
0037         static word32 sTable[4][256];
0038 
0039         FixedSizeSecBlock<word32, 8> m_key;
0040     };
0041 
0042     /// \brief GOST block cipher encryption operation

0043     class CRYPTOPP_NO_VTABLE Enc : public Base
0044     {
0045     public:
0046         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0047     };
0048 
0049     /// \brief GOST block cipher decryption operation

0050     class CRYPTOPP_NO_VTABLE Dec : public Base
0051     {
0052     public:
0053         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0054     };
0055 
0056 public:
0057     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0058     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0059 };
0060 
0061 typedef GOST::Encryption GOSTEncryption;
0062 typedef GOST::Decryption GOSTDecryption;
0063 
0064 NAMESPACE_END
0065 
0066 #endif