Fabcoin Core  0.16.2
P2P Digital Currency
tea.h
Go to the documentation of this file.
1 // tea.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_TEA_H
7 #define CRYPTOPP_TEA_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 #include "misc.h"
12 
14 
15 struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
18 {
19  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "TEA";}
20 };
21 
25 class TEA : public TEA_Info, public BlockCipherDocumentation
26 {
29  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<TEA_Info>
30  {
31  public:
32  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
33 
34  protected:
37  };
38 
41  class CRYPTOPP_NO_VTABLE Enc : public Base
42  {
43  public:
44  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
45  };
46 
49  class CRYPTOPP_NO_VTABLE Dec : public Base
50  {
51  public:
52  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
53  };
54 
55 public:
58 };
59 
62 
65 struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
66 {
67  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "XTEA";}
68 };
69 
73 class XTEA : public XTEA_Info, public BlockCipherDocumentation
74 {
77  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<XTEA_Info>
78  {
79  public:
80  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
81 
82  protected:
85  };
86 
89  class CRYPTOPP_NO_VTABLE Enc : public Base
90  {
91  public:
92  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
93  };
94 
97  class CRYPTOPP_NO_VTABLE Dec : public Base
98  {
99  public:
100  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
101  };
102 
103 public:
106 };
107 
110 struct BTEA_Info : public FixedKeyLength<16>
111 {
112  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "BTEA";}
113 };
114 
120 {
123  class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BlockCipher, BTEA_Info>, BTEA_Info>, public BTEA_Info
124  {
125  public:
126  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
127  {
128  CRYPTOPP_UNUSED(length), CRYPTOPP_UNUSED(params);
129  m_blockSize = params.GetIntValueWithDefault("BlockSize", 60*4);
130  GetUserKey(BIG_ENDIAN_ORDER, m_k.begin(), 4, key, KEYLENGTH);
131  }
132 
133  unsigned int BlockSize() const {return m_blockSize;}
134 
135  protected:
137  unsigned int m_blockSize;
138  };
139 
142  class CRYPTOPP_NO_VTABLE Enc : public Base
143  {
144  public:
145  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
146  };
147 
150  class CRYPTOPP_NO_VTABLE Dec : public Base
151  {
152  public:
153  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
154  };
155 
156 public:
159 };
160 
162 
163 #endif
BlockCipherFinal< ENCRYPTION, Enc > Encryption
Definition: tea.h:104
void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, size_t inlen)
Definition: misc.h:1879
TEA block cipher encryption operation.
Definition: tea.h:41
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:127
uint8_t byte
Definition: Common.h:57
Utility functions for the Crypto++ library.
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: tea.h:67
TEA::Encryption TEAEncryption
Definition: tea.h:60
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: tea.h:19
BlockCipherFinal< ENCRYPTION, Enc > Encryption
Definition: tea.h:157
Classes and functions for secure memory allocations.
BTEA block cipher.
Definition: tea.h:119
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
BTEA block cipher default operation.
Definition: tea.h:123
Inherited by algorithms with variable number of rounds.
Definition: seckey.h:66
TEA::Decryption TEADecryption
Definition: tea.h:61
unsigned int m_blockSize
Definition: tea.h:137
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: tea.h:112
Classes and functions for implementing secret key algorithms.
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition: cryptlib.h:382
FixedSizeSecBlock< word32, 4 > m_k
Definition: tea.h:35
TEA block cipher default operation.
Definition: tea.h:29
XTEA block cipher information.
Definition: tea.h:65
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
Sets the key for this object without performing parameter validation.
Definition: tea.h:126
XTEA block cipher.
Definition: tea.h:73
TEA block cipher information.
Definition: tea.h:17
unsigned int BlockSize() const
Provides the block size of the cipher.
Definition: tea.h:133
FixedSizeSecBlock< word32, 4 > m_k
Definition: tea.h:136
TEA block cipher.
Definition: tea.h:25
byte order is big-endian
Definition: cryptlib.h:128
BTEA block cipher encryption operation.
Definition: tea.h:142
BlockCipherFinal< DECRYPTION, Dec > Decryption
Definition: tea.h:105
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
XTEA block cipher default operation.
Definition: tea.h:77
BTEA block cipher decryption operation.
Definition: tea.h:150
XTEA block cipher encryption operation.
Definition: tea.h:89
TEA block cipher decryption operation.
Definition: tea.h:49
word32 m_limit
Definition: tea.h:36
XTEA block cipher decryption operation.
Definition: tea.h:97
BlockCipherFinal< DECRYPTION, Dec > Decryption
Definition: tea.h:57
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
FixedSizeSecBlock< word32, 4 > m_k
Definition: tea.h:83
BlockCipherFinal< DECRYPTION, Dec > Decryption
Definition: tea.h:158
word32 m_limit
Definition: tea.h:84
#define NAMESPACE_END
Definition: config.h:201
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
BTEA block cipher information.
Definition: tea.h:110
unsigned int word32
Definition: config.h:231
BlockCipherFinal< ENCRYPTION, Enc > Encryption
Definition: tea.h:56
Interface for retrieving values given their names.
Definition: cryptlib.h:279
Base class for identifying alogorithm.
Definition: simple.h:38