12ANONYMOUS_NAMESPACE_BEGIN
14using CryptoPP::rotlConstant;
15using CryptoPP::rotrConstant;
25inline void SIMECK_Encryption(
const T key, T& left, T& right)
28 left = (left & rotlConstant<5>(left)) ^ rotlConstant<1>(left) ^ right ^ key;
32ANONYMOUS_NAMESPACE_END
36#if CRYPTOPP_SIMECK_ADVANCED_PROCESS_BLOCKS
37# if (CRYPTOPP_SSSE3_AVAILABLE)
38extern 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);
41extern 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);
46std::string SIMECK32::Base::AlgorithmProvider()
const
51void 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]);
79void 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]);
92void 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]);
105std::string SIMECK64::Base::AlgorithmProvider()
const
107#if (CRYPTOPP_SSSE3_AVAILABLE)
114void 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]);
142void 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]);
155void 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
169size_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);
181size_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);
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
Access a block of memory.
Interface for retrieving values given their names.
Access a block of memory.
Library configuration file.
Functions for CPU features and intrinsics.
bool HasSSSE3()
Determines SSSE3 availability.
Utility functions for the Crypto++ library.
Crypto++ library namespace.
Classes for the SIMECK block cipher.