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
34NAMESPACE_BEGIN(CryptoPP)
36std::string SIMECK32::Base::AlgorithmProvider()
const
41void SIMECK32::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keyLength,
const NameValuePairs ¶ms)
43 CRYPTOPP_UNUSED(params);
44 CRYPTOPP_UNUSED(keyLength);
47 kblock(m_t[3])(m_t[2])(m_t[1])(m_t[0]);
50 word32 sequence = 0x9A42BB1F;
51 for (
unsigned int i = 0; i < ROUNDS; ++i)
56 constant |= sequence & 1;
59 SIMECK_Encryption(
static_cast<word16>(constant), m_t[1], m_t[0]);
69void SIMECK32::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
73 iblock(m_t[1])(m_t[0]);
75 for (
int idx = 0; idx < ROUNDS; ++idx)
76 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
79 oblock(m_t[1])(m_t[0]);
82void SIMECK32::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
86 iblock(m_t[0])(m_t[1]);
88 for (
int idx = ROUNDS - 1; idx >= 0; --idx)
89 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
92 oblock(m_t[0])(m_t[1]);
95std::string SIMECK64::Base::AlgorithmProvider()
const
100void SIMECK64::Base::UncheckedSetKey(
const byte *userKey,
unsigned int keyLength,
const NameValuePairs ¶ms)
102 CRYPTOPP_UNUSED(params);
103 CRYPTOPP_UNUSED(keyLength);
106 kblock(m_t[3])(m_t[2])(m_t[1])(m_t[0]);
108 word64 constant = W64LIT(0xFFFFFFFC);
109 word64 sequence = W64LIT(0x938BCA3083F);
110 for (
unsigned int i = 0; i < ROUNDS; ++i)
114 constant &= W64LIT(0xFFFFFFFC);
115 constant |= sequence & 1;
118 SIMECK_Encryption(
static_cast<word32>(constant), m_t[1], m_t[0]);
128void SIMECK64::Enc::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
132 iblock(m_t[1])(m_t[0]);
134 for (
int idx = 0; idx < ROUNDS; ++idx)
135 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
138 oblock(m_t[1])(m_t[0]);
141void SIMECK64::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
145 iblock(m_t[0])(m_t[1]);
147 for (
int idx = ROUNDS - 1; idx >= 0; --idx)
148 SIMECK_Encryption(m_rk[idx], m_t[1], m_t[0]);
151 oblock(m_t[0])(m_t[1]);
Access a block of memory.
Interface for retrieving values given their names.
Access a block of memory.
Library configuration file.
unsigned int word32
32-bit unsigned datatype
unsigned short word16
16-bit unsigned datatype
Functions for CPU features and intrinsics.
Utility functions for the Crypto++ library.
Classes for the SIMECK block cipher.