Crypto++
tea.h
Go to the documentation of this file.
1 #ifndef CRYPTOPP_TEA_H
2 #define CRYPTOPP_TEA_H
3 
4 /** \file
5 */
6 
7 #include "seckey.h"
8 #include "secblock.h"
9 
10 NAMESPACE_BEGIN(CryptoPP)
11 
12 //! _
13 struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
14 {
15  static const char *StaticAlgorithmName() {return "TEA";}
16 };
17 
18 /// <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">TEA</a>
19 class TEA : public TEA_Info, public BlockCipherDocumentation
20 {
21  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<TEA_Info>
22  {
23  public:
24  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
25 
26  protected:
28  word32 m_limit;
29  };
30 
31  class CRYPTOPP_NO_VTABLE Enc : public Base
32  {
33  public:
34  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
35  };
36 
37  class CRYPTOPP_NO_VTABLE Dec : public Base
38  {
39  public:
40  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
41  };
42 
43 public:
46 };
47 
50 
51 //! _
52 struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
53 {
54  static const char *StaticAlgorithmName() {return "XTEA";}
55 };
56 
57 /// <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">XTEA</a>
58 class XTEA : public XTEA_Info, public BlockCipherDocumentation
59 {
60  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<XTEA_Info>
61  {
62  public:
63  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
64 
65  protected:
67  word32 m_limit;
68  };
69 
70  class CRYPTOPP_NO_VTABLE Enc : public Base
71  {
72  public:
73  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
74  };
75 
76  class CRYPTOPP_NO_VTABLE Dec : public Base
77  {
78  public:
79  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
80  };
81 
82 public:
85 };
86 
87 //! _
88 struct BTEA_Info : public FixedKeyLength<16>
89 {
90  static const char *StaticAlgorithmName() {return "BTEA";}
91 };
92 
93 //! <a href="http://www.weidai.com/scan-mirror/cs.html#TEA">corrected Block TEA</a> (as described in "xxtea").
94 /*! This class hasn't been tested yet. */
95 class BTEA : public BTEA_Info, public BlockCipherDocumentation
96 {
97  class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BlockCipher, BTEA_Info>, BTEA_Info>, public BTEA_Info
98  {
99  public:
100  void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
101  {
102  m_blockSize = params.GetIntValueWithDefault("BlockSize", 60*4);
103  GetUserKey(BIG_ENDIAN_ORDER, m_k.begin(), 4, key, KEYLENGTH);
104  }
105 
106  unsigned int BlockSize() const {return m_blockSize;}
107 
108  protected:
110  unsigned int m_blockSize;
111  };
112 
113  class CRYPTOPP_NO_VTABLE Enc : public Base
114  {
115  public:
116  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
117  };
118 
119  class CRYPTOPP_NO_VTABLE Dec : public Base
120  {
121  public:
122  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
123  };
124 
125 public:
128 };
129 
130 NAMESPACE_END
131 
132 #endif
to be inherited by keyed algorithms with fixed key length
Definition: seckey.h:66
These objects usually should not be used directly. See CipherModeDocumentation instead.
Definition: seckey.h:188
interface for one direction (encryption or decryption) of a block cipher
Definition: cryptlib.h:603
corrected Block TEA (as described in "xxtea").
Definition: tea.h:95
to be inherited by block ciphers with fixed block size
Definition: seckey.h:21
to be inherited by ciphers with variable number of rounds
Definition: seckey.h:39
int GetIntValueWithDefault(const char *name, int defaultValue) const
get a named value with type int, with default
Definition: cryptlib.h:285
_
Definition: tea.h:52
XTEA
Definition: tea.h:58
_
Definition: tea.h:13
TEA
Definition: tea.h:19
_
Definition: tea.h:88
interface for retrieving values given their names
Definition: cryptlib.h:224