File indexing completed on 2025-01-18 09:55:10
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_TEA_H
0007 #define CRYPTOPP_TEA_H
0008
0009 #include "seckey.h"
0010 #include "secblock.h"
0011 #include "misc.h"
0012
0013 NAMESPACE_BEGIN(CryptoPP)
0014
0015
0016 struct TEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
0017 {
0018
0019
0020
0021
0022 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "TEA";}
0023 };
0024
0025
0026
0027 class TEA : public TEA_Info, public BlockCipherDocumentation
0028 {
0029
0030 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<TEA_Info>
0031 {
0032 public:
0033 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
0034
0035 protected:
0036 FixedSizeSecBlock<word32, 4> m_k;
0037 word32 m_limit;
0038 };
0039
0040
0041 class CRYPTOPP_NO_VTABLE Enc : public Base
0042 {
0043 public:
0044 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0045 };
0046
0047
0048 class CRYPTOPP_NO_VTABLE Dec : public Base
0049 {
0050 public:
0051 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0052 };
0053
0054 public:
0055 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0056 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0057 };
0058
0059 typedef TEA::Encryption TEAEncryption;
0060 typedef TEA::Decryption TEADecryption;
0061
0062
0063 struct XTEA_Info : public FixedBlockSize<8>, public FixedKeyLength<16>, public VariableRounds<32>
0064 {
0065
0066
0067
0068
0069 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "XTEA";}
0070 };
0071
0072
0073
0074 class XTEA : public XTEA_Info, public BlockCipherDocumentation
0075 {
0076
0077 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<XTEA_Info>
0078 {
0079 public:
0080 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
0081
0082 protected:
0083 FixedSizeSecBlock<word32, 4> m_k;
0084 word32 m_limit;
0085 };
0086
0087
0088 class CRYPTOPP_NO_VTABLE Enc : public Base
0089 {
0090 public:
0091 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0092 };
0093
0094
0095 class CRYPTOPP_NO_VTABLE Dec : public Base
0096 {
0097 public:
0098 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0099 };
0100
0101 public:
0102 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0103 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0104 };
0105
0106
0107 struct BTEA_Info : public FixedKeyLength<16>
0108 {
0109
0110
0111
0112
0113 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "BTEA";}
0114 };
0115
0116
0117
0118
0119
0120 class BTEA : public BTEA_Info, public BlockCipherDocumentation
0121 {
0122
0123 class CRYPTOPP_NO_VTABLE Base : public AlgorithmImpl<SimpleKeyingInterfaceImpl<BlockCipher, BTEA_Info>, BTEA_Info>
0124 {
0125 public:
0126 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
0127 {
0128 CRYPTOPP_UNUSED(length), CRYPTOPP_UNUSED(params);
0129 m_blockSize = params.GetIntValueWithDefault("BlockSize", 60*4);
0130 GetUserKey(BIG_ENDIAN_ORDER, m_k.begin(), 4, key, KEYLENGTH);
0131 }
0132
0133 unsigned int BlockSize() const {return m_blockSize;}
0134
0135 protected:
0136 FixedSizeSecBlock<word32, 4> m_k;
0137 unsigned int m_blockSize;
0138 };
0139
0140
0141 class CRYPTOPP_NO_VTABLE Enc : public Base
0142 {
0143 public:
0144 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0145 };
0146
0147
0148 class CRYPTOPP_NO_VTABLE Dec : public Base
0149 {
0150 public:
0151 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0152 };
0153
0154 public:
0155 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0156 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0157 };
0158
0159 NAMESPACE_END
0160
0161 #endif