Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:53

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

0002 
0003 /// \file 3way.h

0004 /// \brief Classes for the 3-Way block cipher

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

0016 struct ThreeWay_Info : public FixedBlockSize<12>, public FixedKeyLength<12>, public VariableRounds<11>
0017 {
0018     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "3-Way";}
0019 };
0020 
0021 /// \brief ThreeWay block cipher

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

0023 class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
0024 {
0025     /// \brief Class specific implementation and overrides used to operate the cipher.

0026     /// \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions

0027     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ThreeWay_Info>
0028     {
0029     public:
0030         void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
0031 
0032     protected:
0033         unsigned int m_rounds;
0034         FixedSizeSecBlock<word32, 3> m_k;
0035     };
0036 
0037     /// \brief Class specific methods used to operate the cipher in the forward direction.

0038     /// \details Implementations and overrides in \p Enc apply to \p ENCRYPTION.

0039     class CRYPTOPP_NO_VTABLE Enc : public Base
0040     {
0041     public:
0042         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0043     };
0044 
0045     /// \brief Class specific methods used to operate the cipher in the reverse direction.

0046     /// \details Implementations and overrides in \p Dec apply to \p DECRYPTION.

0047     class CRYPTOPP_NO_VTABLE Dec : public Base
0048     {
0049     public:
0050         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0051     };
0052 
0053 public:
0054     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0055     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0056 };
0057 
0058 typedef ThreeWay::Encryption ThreeWayEncryption;
0059 typedef ThreeWay::Decryption ThreeWayDecryption;
0060 
0061 NAMESPACE_END
0062 
0063 #endif