Security Scol plugin
tea.h
Go to the documentation of this file.
1// tea.h - originally 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
13NAMESPACE_BEGIN(CryptoPP)
14
15
16struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
17{
22 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "TEA";}
23};
24
28{
30 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<TEA_Info>
31 {
32 public:
33 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
34
35 protected:
37 word32 m_limit;
38 };
39
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
48 class CRYPTOPP_NO_VTABLE Dec : public Base
49 {
50 public:
51 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
52 };
53
54public:
57};
58
61
63struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
64{
69 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "XTEA";}
70};
71
75{
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:
84 word32 m_limit;
85 };
86
88 class CRYPTOPP_NO_VTABLE Enc : public Base
89 {
90 public:
91 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
92 };
93
95 class CRYPTOPP_NO_VTABLE Dec : public Base
96 {
97 public:
98 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
99 };
100
101public:
104};
105
107struct BTEA_Info : public FixedKeyLength<16>
108{
113 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "BTEA";}
114};
115
121{
123 class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BlockCipher, BTEA_Info>, 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
141 class CRYPTOPP_NO_VTABLE Enc : public Base
142 {
143 public:
144 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
145 };
146
148 class CRYPTOPP_NO_VTABLE Dec : public Base
149 {
150 public:
151 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
152 };
153
154public:
157};
158
159NAMESPACE_END
160
161#endif
Base class information.
Definition simple.h:40
BTEA block cipher.
Definition tea.h:121
Provides class member functions to key a block cipher.
Definition seckey.h:318
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition seckey.h:306
Inherited by algorithms with fixed block size.
Definition seckey.h:41
Inherited by keyed algorithms with fixed key length.
Definition seckey.h:125
Fixed size stack-based SecBlock.
Definition secblock.h:1246
Interface for retrieving values given their names.
Definition cryptlib.h:322
CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Definition cryptlib.h:424
TEA block cipher.
Definition tea.h:28
Inherited by algorithms with variable number of rounds.
Definition seckey.h:65
XTEA block cipher.
Definition tea.h:75
unsigned int word32
32-bit unsigned datatype
Definition config_int.h:62
@ BIG_ENDIAN_ORDER
byte order is big-endian
Definition cryptlib.h:147
Utility functions for the Crypto++ library.
void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, size_t inlen)
Copy bytes in a buffer to an array of elements in big-endian order.
Definition misc.h:2291
Classes and functions for secure memory allocations.
Classes and functions for implementing secret key algorithms.
BTEA block cipher information.
Definition tea.h:108
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
The algorithm name.
Definition tea.h:113
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher.
Definition seckey.h:399
TEA block cipher information.
Definition tea.h:17
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
The algorithm name.
Definition tea.h:22
XTEA block cipher information.
Definition tea.h:64
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
The algorithm name.
Definition tea.h:69