File indexing completed on 2025-01-18 09:54:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef CRYPTOPP_CHAM_H
0011 #define CRYPTOPP_CHAM_H
0012
0013 #include "config.h"
0014 #include "seckey.h"
0015 #include "secblock.h"
0016 #include "algparam.h"
0017
0018 #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X86)
0019 # define CRYPTOPP_CHAM128_ADVANCED_PROCESS_BLOCKS 1
0020 #endif
0021
0022
0023
0024 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x5120)
0025 # undef CRYPTOPP_CHAM128_ADVANCED_PROCESS_BLOCKS
0026 #endif
0027
0028 NAMESPACE_BEGIN(CryptoPP)
0029
0030
0031
0032 struct CHAM64_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
0033 {
0034
0035
0036
0037
0038 static const std::string StaticAlgorithmName()
0039 {
0040
0041 return "CHAM-64";
0042 }
0043 };
0044
0045
0046
0047 struct CHAM128_Info : public FixedBlockSize<16>, public VariableKeyLength<16,16,32,16>
0048 {
0049
0050
0051
0052
0053 static const std::string StaticAlgorithmName()
0054 {
0055
0056 return "CHAM-128";
0057 }
0058 };
0059
0060
0061
0062
0063
0064
0065
0066
0067 class CRYPTOPP_NO_VTABLE CHAM64 : public CHAM64_Info, public BlockCipherDocumentation
0068 {
0069 public:
0070
0071
0072
0073 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<CHAM64_Info>
0074 {
0075 protected:
0076 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
0077
0078 SecBlock<word16> m_rk;
0079 mutable FixedSizeSecBlock<word16, 4> m_x;
0080 unsigned int m_kw;
0081 };
0082
0083
0084
0085
0086
0087 class CRYPTOPP_NO_VTABLE Enc : public Base
0088 {
0089 public:
0090 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0091 };
0092
0093
0094
0095
0096
0097 class CRYPTOPP_NO_VTABLE Dec : public Base
0098 {
0099 public:
0100 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0101 };
0102
0103
0104 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0105
0106 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0107 };
0108
0109
0110 typedef CHAM64::Encryption CHAM64Encryption;
0111
0112 typedef CHAM64::Decryption CHAM64Decryption;
0113
0114
0115
0116
0117
0118
0119
0120
0121 class CRYPTOPP_NO_VTABLE CHAM128 : public CHAM128_Info, public BlockCipherDocumentation
0122 {
0123 public:
0124
0125
0126
0127 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<CHAM128_Info>
0128 {
0129 protected:
0130 void UncheckedSetKey(const byte *userKey, unsigned int keyLength, const NameValuePairs ¶ms);
0131 std::string AlgorithmProvider() const;
0132
0133 SecBlock<word32> m_rk;
0134 mutable FixedSizeSecBlock<word32, 4> m_x;
0135 unsigned int m_kw;
0136 };
0137
0138
0139
0140
0141
0142 class CRYPTOPP_NO_VTABLE Enc : public Base
0143 {
0144 public:
0145 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0146
0147 #if CRYPTOPP_CHAM128_ADVANCED_PROCESS_BLOCKS
0148 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0149 #endif
0150 };
0151
0152
0153
0154
0155
0156 class CRYPTOPP_NO_VTABLE Dec : public Base
0157 {
0158 public:
0159 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0160
0161 #if CRYPTOPP_CHAM128_ADVANCED_PROCESS_BLOCKS
0162 size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
0163 #endif
0164 };
0165
0166
0167 typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0168
0169 typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0170 };
0171
0172
0173 typedef CHAM128::Encryption CHAM128Encryption;
0174
0175 typedef CHAM128::Decryption CHAM128Decryption;
0176
0177 NAMESPACE_END
0178
0179 #endif