summaryrefslogtreecommitdiff
path: root/seed.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-12-16 18:18:53 -0500
committerJeffrey Walton <noloader@gmail.com>2017-12-16 18:18:53 -0500
commit19deccf3ba64a50c97c29d519ca9bfaec234c267 (patch)
tree277732b4d323593c88566bd689f6bf9ed53f3f45 /seed.cpp
parentdc21de24831a140e38597166d2e62febfd19b0fb (diff)
downloadcryptopp-git-19deccf3ba64a50c97c29d519ca9bfaec234c267.tar.gz
Fix Clang 5.0 "runtime error: addition of unsigned offset to 0xXXXX overflowed to 0xYYYY" (GH #549)
Diffstat (limited to 'seed.cpp')
-rw-r--r--seed.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/seed.cpp b/seed.cpp
index a610b3e6..4e99d759 100644
--- a/seed.cpp
+++ b/seed.cpp
@@ -3,14 +3,18 @@
#include "pch.h"
#include "seed.h"
#include "misc.h"
+#include "stdcpp.h"
-NAMESPACE_BEGIN(CryptoPP)
+ANONYMOUS_NAMESPACE_BEGIN
+
+using CryptoPP::byte;
+using CryptoPP::word32;
-static const word32 s_kc[16] = {
+const word32 s_kc[16] = {
0x9e3779b9, 0x3c6ef373, 0x78dde6e6, 0xf1bbcdcc, 0xe3779b99, 0xc6ef3733, 0x8dde6e67, 0x1bbcdccf,
0x3779b99e, 0x6ef3733c, 0xdde6e678, 0xbbcdccf1, 0x779b99e3, 0xef3733c6, 0xde6e678d, 0xbcdccf1b};
-static const byte s_s0[256] = {
+const byte s_s0[256] = {
0xA9, 0x85, 0xD6, 0xD3, 0x54, 0x1D, 0xAC, 0x25, 0x5D, 0x43, 0x18, 0x1E, 0x51, 0xFC, 0xCA, 0x63, 0x28,
0x44, 0x20, 0x9D, 0xE0, 0xE2, 0xC8, 0x17, 0xA5, 0x8F, 0x03, 0x7B, 0xBB, 0x13, 0xD2, 0xEE, 0x70, 0x8C,
0x3F, 0xA8, 0x32, 0xDD, 0xF6, 0x74, 0xEC, 0x95, 0x0B, 0x57, 0x5C, 0x5B, 0xBD, 0x01, 0x24, 0x1C, 0x73,
@@ -52,6 +56,10 @@ static const byte s_s1[256] = {
#define SS3(x) ((s_s1[x]*0x01010101UL) & 0xCFF3FC3F)
#define G(x) (SS0(GETBYTE(x, 0)) ^ SS1(GETBYTE(x, 1)) ^ SS2(GETBYTE(x, 2)) ^ SS3(GETBYTE(x, 3)))
+ANONYMOUS_NAMESPACE_END
+
+NAMESPACE_BEGIN(CryptoPP)
+
void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs& /*params*/)
{
AssertValidKeyLength(length);
@@ -60,7 +68,8 @@ void SEED::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const
GetBlock<word64, BigEndian> get(userKey);
get(key01)(key23);
word32 *k = m_k;
- size_t kInc = 2;
+ ptrdiff_t kInc = 2;
+
if (!IsForwardTransformation())
{
k = k+30;