aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/block
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-01-17 09:16:50 -0500
committerJack Lloyd <[email protected]>2019-01-17 09:16:50 -0500
commit377ed5445083af5703fe8b0411ad162af1766012 (patch)
tree77936fb806a62f37508803651b7d73bb8af3b11c /src/lib/block
parent4c3016578da7b9840bb77563f4257df11c9f1de9 (diff)
Fix some warnings from PVS-Studio
No real bugs, but pointed out some odd constructs and duplicated logic
Diffstat (limited to 'src/lib/block')
-rw-r--r--src/lib/block/aria/aria.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib/block/aria/aria.cpp b/src/lib/block/aria/aria.cpp
index e92580361..2a02330c9 100644
--- a/src/lib/block/aria/aria.cpp
+++ b/src/lib/block/aria/aria.cpp
@@ -280,12 +280,13 @@ void transform(const uint8_t in[], uint8_t out[], size_t blocks,
}
// n-bit right shift of Y XORed to X
-template <unsigned int N>
+template<size_t N>
inline void ARIA_ROL128(const uint32_t X[4], const uint32_t Y[4], uint32_t KS[4])
{
// MSVC is not generating a "rotate immediate". Constify to help it along.
- static const unsigned int Q = 4 - (N / 32);
- static const unsigned int R = N % 32;
+ static const size_t Q = 4 - (N / 32);
+ static const size_t R = N % 32;
+ static_assert(R > 0 && R < 32, "Rotation in range for type");
KS[0] = (X[0]) ^ ((Y[(Q )%4])>>R) ^ ((Y[(Q+3)%4])<<(32-R));
KS[1] = (X[1]) ^ ((Y[(Q+1)%4])>>R) ^ ((Y[(Q )%4])<<(32-R));
KS[2] = (X[2]) ^ ((Y[(Q+2)%4])>>R) ^ ((Y[(Q+1)%4])<<(32-R));