Crypto++ 8.6 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
BlockCipherFinal< ENCRYPTION, Enc >
BlockCipherImpl
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:306
FixedBlockSize
Inherited by algorithms with fixed block size.
Definition: seckey.h:41
FixedKeyLength
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:125
FixedSizeSecBlock< word32, 3 >
NameValuePairs
Interface for retrieving values given their names.
Definition: cryptlib.h:327
ThreeWay
ThreeWay block cipher.
Definition: 3way.h:24
VariableRounds
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:65
config.h
Library configuration file.
CryptoPP
Crypto++ library namespace.
secblock.h
Classes and functions for secure memory allocations.
seckey.h
Classes and functions for implementing secret key algorithms.
BlockCipherDocumentation
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition: seckey.h:399
ThreeWay_Info
ThreeWay block cipher information.
Definition: 3way.h:17