summaryrefslogtreecommitdiff
path: root/simon.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-11-25 02:52:19 -0500
committerJeffrey Walton <noloader@gmail.com>2017-11-25 02:52:19 -0500
commita074722bfa82d82c12879b8fdd9a62bac8bcaf89 (patch)
tree6321fd7bb3c9a3340ce8463242854a19bc0ef4e1 /simon.cpp
parent2d4614084a4250ce4d60d535ccf506605477e4ed (diff)
downloadcryptopp-git-a074722bfa82d82c12879b8fdd9a62bac8bcaf89.tar.gz
Switch to rotlConstant and rotrConstant
This will help Clang and its need for a constexpr
Diffstat (limited to 'simon.cpp')
-rw-r--r--simon.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/simon.cpp b/simon.cpp
index c1bee040..a9ea38d7 100644
--- a/simon.cpp
+++ b/simon.cpp
@@ -10,8 +10,8 @@ ANONYMOUS_NAMESPACE_BEGIN
using CryptoPP::word32;
using CryptoPP::word64;
-using CryptoPP::rotlFixed;
-using CryptoPP::rotrFixed;
+using CryptoPP::rotlConstant;
+using CryptoPP::rotrConstant;
//! \brief Round transformation helper
//! \tparam W word type
@@ -19,7 +19,7 @@ using CryptoPP::rotrFixed;
template <class W>
inline W f(const W v)
{
- return (rotlFixed(v, 1) & rotlFixed(v, 8)) ^ rotlFixed(v, 2);
+ return (rotlConstant<1>(v) & rotlConstant<8>(v)) ^ rotlConstant<2>(v);
}
//! \brief Round transformation
@@ -103,7 +103,7 @@ inline void SPECK64_ExpandKey_42R3K(word32 key[42], const word32 k[3])
key[0] = k[2]; key[1] = k[1]; key[2] = k[0];
for (size_t i = 3; i<42; ++i)
{
- key[i] = c ^ (z & 1) ^ key[i-3] ^ rotrFixed(key[i-1], 3) ^ rotrFixed(key[i-1], 4);
+ key[i] = c ^ (z & 1) ^ key[i - 3] ^ rotrConstant<3>(key[i - 1]) ^ rotrConstant<4>(key[i - 1]);
z >>= 1;
}
}
@@ -121,7 +121,7 @@ inline void SPECK64_ExpandKey_44R4K(word32 key[44], const word32 k[4])
key[0] = k[3]; key[1] = k[2]; key[2] = k[1]; key[3] = k[0];
for (size_t i = 4; i<44; ++i)
{
- key[i] = c ^ (z & 1) ^ key[i-4] ^ rotrFixed(key[i-1], 3) ^ key[i-3] ^ rotrFixed(key[i-1], 4) ^ rotrFixed(key[i-3], 1);
+ key[i] = c ^ (z & 1) ^ key[i - 4] ^ rotrConstant<3>(key[i - 1]) ^ key[i - 3] ^ rotrConstant<4>(key[i - 1]) ^ rotrConstant<1>(key[i - 3]);
z >>= 1;
}
}
@@ -139,12 +139,12 @@ inline void SIMON128_ExpandKey_68R2K(word64 key[68], const word64 k[2])
key[0] = k[1]; key[1] = k[0];
for (size_t i=2; i<66; ++i)
{
- key[i] = c^(z&1)^key[i-2]^rotrFixed(key[i-1],3)^rotrFixed(key[i-1],4);
+ key[i] = c ^ (z & 1) ^ key[i - 2] ^ rotrConstant<3>(key[i - 1]) ^ rotrConstant<4>(key[i - 1]);
z>>=1;
}
- key[66] = c^1^key[64]^rotrFixed(key[65],3)^rotrFixed(key[65],4);
- key[67] = c^key[65]^rotrFixed(key[66],3)^rotrFixed(key[66],4);
+ key[66] = c ^ 1 ^ key[64] ^ rotrConstant<3>(key[65]) ^ rotrConstant<4>(key[65]);
+ key[67] = c^key[65] ^ rotrConstant<3>(key[66]) ^ rotrConstant<4>(key[66]);
}
//! \brief Subkey generation function
@@ -160,12 +160,12 @@ inline void SIMON128_ExpandKey_69R3K(word64 key[69], const word64 k[3])
key[0]=k[2]; key[1]=k[1]; key[2]=k[0];
for (size_t i=3; i<67; ++i)
{
- key[i] = c^(z&1)^key[i-3]^rotrFixed(key[i-1],3)^rotrFixed(key[i-1],4);
+ key[i] = c ^ (z & 1) ^ key[i - 3] ^ rotrConstant<3>(key[i - 1]) ^ rotrConstant<4>(key[i - 1]);
z>>=1;
}
- key[67] = c^key[64]^rotrFixed(key[66],3)^rotrFixed(key[66],4);
- key[68] = c^1^key[65]^rotrFixed(key[67],3)^rotrFixed(key[67],4);
+ key[67] = c^key[64] ^ rotrConstant<3>(key[66]) ^ rotrConstant<4>(key[66]);
+ key[68] = c ^ 1 ^ key[65] ^ rotrConstant<3>(key[67]) ^ rotrConstant<4>(key[67]);
}
//! \brief Subkey generation function
@@ -181,14 +181,14 @@ inline void SIMON128_ExpandKey_72R4K(word64 key[72], const word64 k[4])
key[0]=k[3]; key[1]=k[2]; key[2]=k[1]; key[3]=k[0];
for (size_t i=4; i<68; ++i)
{
- key[i] = c^(z&1)^key[i-4]^rotrFixed(key[i-1],3)^key[i-3]^rotrFixed(key[i-1],4)^rotrFixed(key[i-3],1);
+ key[i] = c ^ (z & 1) ^ key[i - 4] ^ rotrConstant<3>(key[i - 1]) ^ key[i - 3] ^ rotrConstant<4>(key[i - 1]) ^ rotrConstant<1>(key[i - 3]);
z>>=1;
}
- key[68] = c^key[64]^rotrFixed(key[67],3)^key[65]^rotrFixed(key[67],4)^rotrFixed(key[65],1);
- key[69] = c^1^key[65]^rotrFixed(key[68],3)^key[66]^rotrFixed(key[68],4)^rotrFixed(key[66],1);
- key[70] = c^key[66]^rotrFixed(key[69],3)^key[67]^rotrFixed(key[69],4)^rotrFixed(key[67],1);
- key[71] = c^key[67]^rotrFixed(key[70],3)^key[68]^rotrFixed(key[70],4)^rotrFixed(key[68],1);
+ key[68] = c^key[64] ^ rotrConstant<3>(key[67]) ^ key[65] ^ rotrConstant<4>(key[67]) ^ rotrConstant<1>(key[65]);
+ key[69] = c ^ 1 ^ key[65] ^ rotrConstant<3>(key[68]) ^ key[66] ^ rotrConstant<4>(key[68]) ^ rotrConstant<1>(key[66]);
+ key[70] = c^key[66] ^ rotrConstant<3>(key[69]) ^ key[67] ^ rotrConstant<4>(key[69]) ^ rotrConstant<1>(key[67]);
+ key[71] = c^key[67] ^ rotrConstant<3>(key[70]) ^ key[68] ^ rotrConstant<4>(key[70]) ^ rotrConstant<1>(key[68]);
}
ANONYMOUS_NAMESPACE_END