Crypto++ 8.1 Free C++ class library of cryptographic schemes

3way.h
Go to the documentation of this file.
1 // 3way.h - originally written and placed in the public domain by Wei Dai
2
3 /// \file 3way.h
4 /// \brief Classes for the 3-Way block cipher
5
6 #ifndef CRYPTOPP_THREEWAY_H
7 #define CRYPTOPP_THREEWAY_H
8
9 #include "config.h"
10 #include "seckey.h"
11 #include "secblock.h"
12
13 NAMESPACE_BEGIN(CryptoPP)
14
15 /// \brief ThreeWay block cipher information
16 struct ThreeWay_Info : public FixedBlockSize<12>, public FixedKeyLength<12>, public VariableRounds<11>
17 {
18 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "3-Way";}
19 };
20
21 /// \brief ThreeWay block cipher
22 /// \sa <a href="http://www.cryptopp.com/wiki/3-Way">3-Way</a>
23 class ThreeWay : public ThreeWay_Info, public BlockCipherDocumentation
24 {
25 /// \brief Class specific implementation and overrides used to operate the cipher.
26 /// \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions
27 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<ThreeWay_Info>
28 {
29 public:
30 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
31
32 protected:
33 unsigned int m_rounds;
34 FixedSizeSecBlock<word32, 3> m_k;
35 };
36
37 /// \brief Class specific methods used to operate the cipher in the forward direction.
38 /// \details Implementations and overrides in \p Enc apply to \p ENCRYPTION.
39 class CRYPTOPP_NO_VTABLE Enc : public Base
40 {
41 public:
42 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
43 };
44
45 /// \brief Class specific methods used to operate the cipher in the reverse direction.
46 /// \details Implementations and overrides in \p Dec apply to \p DECRYPTION.
47 class CRYPTOPP_NO_VTABLE Dec : public Base
48 {
49 public:
50 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
51 };
52
53 public:
54 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
55 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
56 };
57
58 typedef ThreeWay::Encryption ThreeWayEncryption;
59 typedef ThreeWay::Decryption ThreeWayDecryption;
60
61 NAMESPACE_END
62
63 #endif
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:124
BlockCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:398
config.h
Library configuration file.
secblock.h
Classes and functions for secure memory allocations.
FixedBlockSize
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
VariableRounds
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:64
seckey.h
Classes and functions for implementing secret key algorithms.
BlockCipherFinal< ENCRYPTION, Enc >
ThreeWay
ThreeWay block cipher.
Definition: 3way.h:23
FixedSizeSecBlock< word32, 3 >
ThreeWay_Info
ThreeWay block cipher information.
Definition: 3way.h:16
BlockCipherImpl
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:305
CryptoPP
Crypto++ library namespace.
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:293