aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/block/aes/aes.cpp2
-rw-r--r--src/lib/block/kasumi/kasumi.cpp2
-rw-r--r--src/lib/block/misty1/misty1.cpp2
-rw-r--r--src/lib/block/seed/seed.cpp4
-rw-r--r--src/lib/hash/streebog/streebog.cpp2
-rw-r--r--src/tests/test_ocb.cpp11
-rw-r--r--src/tests/test_octetstring.cpp10
7 files changed, 18 insertions, 15 deletions
diff --git a/src/lib/block/aes/aes.cpp b/src/lib/block/aes/aes.cpp
index a632c01ac..71a8c6a44 100644
--- a/src/lib/block/aes/aes.cpp
+++ b/src/lib/block/aes/aes.cpp
@@ -94,7 +94,7 @@ const uint8_t SD[256] = {
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63,
0x55, 0x21, 0x0C, 0x7D };
-inline uint8_t xtime(uint8_t s) { return (s << 1) ^ ((s >> 7) * 0x1B); }
+inline uint8_t xtime(uint8_t s) { return static_cast<uint8_t>(s << 1) ^ ((s >> 7) * 0x1B); }
inline uint8_t xtime4(uint8_t s) { return xtime(xtime(s)); }
inline uint8_t xtime8(uint8_t s) { return xtime(xtime(xtime(s))); }
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp
index 92ad5dd14..ed2524e0b 100644
--- a/src/lib/block/kasumi/kasumi.cpp
+++ b/src/lib/block/kasumi/kasumi.cpp
@@ -100,7 +100,7 @@ uint16_t FI(uint16_t I, uint16_t K)
D7 ^= (K >> 9);
D9 = KASUMI_SBOX_S9[D9 ^ (K & 0x1FF)] ^ D7;
D7 = KASUMI_SBOX_S7[D7] ^ (D9 & 0x7F);
- return (D7 << 9) | D9;
+ return static_cast<uint16_t>(D7 << 9) | D9;
}
}
diff --git a/src/lib/block/misty1/misty1.cpp b/src/lib/block/misty1/misty1.cpp
index d6ac5f9a9..eaef86c8c 100644
--- a/src/lib/block/misty1/misty1.cpp
+++ b/src/lib/block/misty1/misty1.cpp
@@ -93,7 +93,7 @@ uint16_t FI(uint16_t input, uint16_t key7, uint16_t key9)
D9 = MISTY1_SBOX_S9[D9] ^ D7;
D7 = (MISTY1_SBOX_S7[D7] ^ key7 ^ D9) & 0x7F;
D9 = MISTY1_SBOX_S9[D9 ^ key9] ^ D7;
- return static_cast<uint16_t>((D7 << 9) | D9);
+ return static_cast<uint16_t>(D7 << 9) | D9;
}
}
diff --git a/src/lib/block/seed/seed.cpp b/src/lib/block/seed/seed.cpp
index 0df35383f..700283042 100644
--- a/src/lib/block/seed/seed.cpp
+++ b/src/lib/block/seed/seed.cpp
@@ -303,9 +303,9 @@ void SEED::key_schedule(const uint8_t key[], size_t)
m_K[2*i ] = SEED_G(WK[0] + WK[2] - RC[i]);
m_K[2*i+1] = SEED_G(WK[1] - WK[3] + RC[i]) ^ m_K[2*i];
- uint8_t T = get_byte(3, WK[0]);
+ uint32_t T = (WK[0] & 0xFF) << 24;
WK[0] = (WK[0] >> 8) | (get_byte(3, WK[1]) << 24);
- WK[1] = (WK[1] >> 8) | (T << 24);
+ WK[1] = (WK[1] >> 8) | T;
m_K[2*i+2] = SEED_G(WK[0] + WK[2] - RC[i+1]);
m_K[2*i+3] = SEED_G(WK[1] - WK[3] + RC[i+1]) ^ m_K[2*i+2];
diff --git a/src/lib/hash/streebog/streebog.cpp b/src/lib/hash/streebog/streebog.cpp
index 07286e9c8..cd67256cb 100644
--- a/src/lib/hash/streebog/streebog.cpp
+++ b/src/lib/hash/streebog/streebog.cpp
@@ -29,7 +29,7 @@ static inline void addm(const uint8_t* m, uint64_t* h)
const uint64_t hi = load_le<uint64_t>(reinterpret_cast<uint8_t*>(h), i);
const uint64_t t = hi + m64;
- const uint64_t overflow = (t < hi) | (t < m64);
+ const uint64_t overflow = (t < hi ? 1 : 0) | (t < m64 ? 1 : 0);
store_le(t + carry, reinterpret_cast<uint8_t*>(&h[i]));
carry = overflow;
}
diff --git a/src/tests/test_ocb.cpp b/src/tests/test_ocb.cpp
index 07f216f96..490a52f4f 100644
--- a/src/tests/test_ocb.cpp
+++ b/src/tests/test_ocb.cpp
@@ -69,9 +69,9 @@ class OCB_Wide_Test_Block_Cipher final : public Botan::BlockCipher
for(size_t i = 0; i != m_bs; ++i)
out[i] = in[i] ^ m_key[i];
- const uint8_t bottom_carry = in[m_bs-1] & 0x01;
+ uint8_t carry = in[m_bs-1] & 0x01;
- if(bottom_carry)
+ if(carry)
{
if(m_bs == 16 || m_bs == 24)
{
@@ -91,13 +91,14 @@ class OCB_Wide_Test_Block_Cipher final : public Botan::BlockCipher
throw Test_Error("Bad OCB test block size");
}
- uint8_t carry = bottom_carry << 7;
+ carry <<= 7;
for(size_t i = 0; i != m_bs; ++i)
{
- uint8_t temp = out[i];
+ const uint8_t temp = out[i];
out[i] = (temp >> 1) | carry;
- carry = (temp & 0x1) << 7;
+ carry = (temp & 0x1);
+ carry <<= 7;
}
blocks--;
diff --git a/src/tests/test_octetstring.cpp b/src/tests/test_octetstring.cpp
index 1010b5464..b9692559e 100644
--- a/src/tests/test_octetstring.cpp
+++ b/src/tests/test_octetstring.cpp
@@ -99,11 +99,13 @@ Test::Result test_equality()
{
Test::Result result("OctetString");
- Botan::OctetString os1("0000000000000000");
- Botan::OctetString os2("FFFFFFFFFFFFFFFF");
+ const Botan::OctetString os1("0000000000000000");
+ const Botan::OctetString os1_copy = os1;
+ const Botan::OctetString os2("FFFFFFFFFFFFFFFF");
+ const Botan::OctetString os2_copy = os2;
- result.confirm("OctetString equality operations works as expected", os1 == os1);
- result.confirm("OctetString equality operations works as expected", os2 == os2);
+ result.confirm("OctetString equality operations works as expected", os1 == os1_copy);
+ result.confirm("OctetString equality operations works as expected", os2 == os2_copy);
result.confirm("OctetString equality operations works as expected", os1 != os2);
return result;