12 ANONYMOUS_NAMESPACE_BEGIN
25 inline void SIMECK_Encryption(
const T key, T& left, T& right)
28 left = (left & rotlConstant<5>(left)) ^ rotlConstant<1>(left) ^ right ^ key;
32 ANONYMOUS_NAMESPACE_END
36 #if CRYPTOPP_SIMECK_ADVANCED_PROCESS_BLOCKS 37 # if (CRYPTOPP_SSSE3_AVAILABLE) 38 extern size_t SIMECK64_Enc_AdvancedProcessBlocks_SSSE3(
const word32* subKeys,
size_t rounds,
39 const byte *inBlocks,
const byte *xorBlocks, byte *outBlocks,
size_t length, word32 flags);
41 extern size_t SIMECK64_Dec_AdvancedProcessBlocks_SSSE3(
const word32* subKeys,
size_t rounds,
42 const byte *inBlocks,
const byte *xorBlocks, byte *outBlocks,
size_t length, word32 flags);
43 # endif // CRYPTOPP_SSSE3_AVAILABLE 44 #endif // CRYPTOPP_SIMECK_ADVANCED_PROCESS_BLOCKS 46 std::string SIMECK32::Base::AlgorithmProvider()
const 51 void SIMECK32::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keyLength,
const NameValuePairs ¶ms)
53 CRYPTOPP_UNUSED(params);
54 CRYPTOPP_UNUSED(keyLength);
57 kblock(m_t[3])(m_t[2])(m_t[1])(m_t[0]);
59 word16 constant = 0xFFFC;
60 word32 sequence = 0x9A42BB1F;
61 for (
unsigned int i = 0; i <
ROUNDS; ++i)
66 constant |= sequence & 1;
69 SIMECK_Encryption(static_cast<word16>(constant), m_t[1], m_t[0]);
79 void SIMECK32::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const 83 iblock(m_t[1])(m_t[0]);
85 for (
int idx = 0; idx <
ROUNDS; ++idx)
86 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
89 oblock(m_t[1])(m_t[0]);
92 void SIMECK32::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const 96 iblock(m_t[0])(m_t[1]);
98 for (
int idx =
ROUNDS - 1; idx >= 0; --idx)
99 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
102 oblock(m_t[0])(m_t[1]);
105 std::string SIMECK64::Base::AlgorithmProvider()
const 107 #if (CRYPTOPP_SSSE3_AVAILABLE) 114 void SIMECK64::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keyLength,
const NameValuePairs ¶ms)
116 CRYPTOPP_UNUSED(params);
117 CRYPTOPP_UNUSED(keyLength);
120 kblock(m_t[3])(m_t[2])(m_t[1])(m_t[0]);
122 word64 constant = W64LIT(0xFFFFFFFC);
123 word64 sequence = W64LIT(0x938BCA3083F);
124 for (
unsigned int i = 0; i <
ROUNDS; ++i)
128 constant &= W64LIT(0xFFFFFFFC);
129 constant |= sequence & 1;
132 SIMECK_Encryption(static_cast<word32>(constant), m_t[1], m_t[0]);
142 void SIMECK64::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const 146 iblock(m_t[1])(m_t[0]);
148 for (
int idx = 0; idx <
ROUNDS; ++idx)
149 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
152 oblock(m_t[1])(m_t[0]);
155 void SIMECK64::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const 159 iblock(m_t[0])(m_t[1]);
161 for (
int idx =
ROUNDS - 1; idx >= 0; --idx)
162 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
165 oblock(m_t[0])(m_t[1]);
168 #if CRYPTOPP_SIMECK_ADVANCED_PROCESS_BLOCKS 169 size_t SIMECK64::Enc::AdvancedProcessBlocks(
const byte *inBlocks,
const byte *xorBlocks,
170 byte *outBlocks,
size_t length, word32 flags)
const 172 # if (CRYPTOPP_SSSE3_AVAILABLE) 174 return SIMECK64_Enc_AdvancedProcessBlocks_SSSE3(m_rk,
ROUNDS,
175 inBlocks, xorBlocks, outBlocks, length, flags);
177 # endif // CRYPTOPP_SSSE3_AVAILABLE 181 size_t SIMECK64::Dec::AdvancedProcessBlocks(
const byte *inBlocks,
const byte *xorBlocks,
182 byte *outBlocks,
size_t length, word32 flags)
const 184 # if (CRYPTOPP_SSSE3_AVAILABLE) 186 return SIMECK64_Dec_AdvancedProcessBlocks_SSSE3(m_rk,
ROUNDS,
187 inBlocks, xorBlocks, outBlocks, length, flags);
189 # endif // CRYPTOPP_SSSE3_AVAILABLE 192 #endif // CRYPTOPP_SIMECK_ADVANCED_PROCESS_BLOCKS Utility functions for the Crypto++ library.
bool HasSSSE3()
Determines SSSE3 availability.
Library configuration file.
Classes for the SIMECK block cipher.
T rotlConstant(T x)
Performs a left rotate.
Functions for CPU features and intrinsics.
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
T rotrConstant(T x)
Performs a right rotate.
Access a block of memory.
Access a block of memory.
Crypto++ library namespace.
Interface for retrieving values given their names.