12ANONYMOUS_NAMESPACE_BEGIN
14using CryptoPP::rotlConstant;
15using CryptoPP::rotrConstant;
25inline void SIMECK_Encryption(
const T key, T& left, T& right)
32ANONYMOUS_NAMESPACE_END
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);
46 GetBlock<word16, BigEndian> kblock(userKey);
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
72 GetBlock<word16, BigEndian> iblock(inBlock);
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]);
78 PutBlock<word16, BigEndian> oblock(xorBlock, outBlock);
79 oblock(m_t[1])(m_t[0]);
82void SIMECK32::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
85 GetBlock<word16, BigEndian> iblock(inBlock);
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]);
91 PutBlock<word16, BigEndian> oblock(xorBlock, outBlock);
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);
105 GetBlock<word32, BigEndian> kblock(userKey);
106 kblock(m_t[3])(m_t[2])(m_t[1])(m_t[0]);
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
131 GetBlock<word32, BigEndian> iblock(inBlock);
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]);
137 PutBlock<word32, BigEndian> oblock(xorBlock, outBlock);
138 oblock(m_t[1])(m_t[0]);
141void SIMECK64::Dec::ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock,
byte *outBlock)
const
144 GetBlock<word32, BigEndian> iblock(inBlock);
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]);
150 PutBlock<word32, BigEndian> oblock(xorBlock, outBlock);
151 oblock(m_t[0])(m_t[1]);
Library configuration file.
#define W64LIT(x)
Declare an unsigned word64.
unsigned int word32
32-bit unsigned datatype
unsigned short word16
16-bit unsigned datatype
unsigned long long word64
64-bit unsigned datatype
Functions for CPU features and intrinsics.
Utility functions for the Crypto++ library.
T rotlConstant(T x)
Performs a left rotate.
Crypto++ library namespace.
Classes for the SIMECK block cipher.