diff --git a/3way.cpp b/3way.cpp index f5a3d519..86ba0efb 100644 --- a/3way.cpp +++ b/3way.cpp @@ -15,11 +15,14 @@ void ThreeWay_TestInstantiations() } #endif -static const word32 START_E = 0x0b0b; // round constant of first encryption round -static const word32 START_D = 0xb1b1; // round constant of first decryption round +namespace +{ + const word32 START_E = 0x0b0b; // round constant of first encryption round + const word32 START_D = 0xb1b1; // round constant of first decryption round #ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 -static const word32 RC_MODULUS = 0x11011; + const word32 RC_MODULUS = 0x11011; #endif +} static inline word32 reverseBits(word32 a) { diff --git a/base32.cpp b/base32.cpp index 3c7e6ee9..6444caba 100644 --- a/base32.cpp +++ b/base32.cpp @@ -5,8 +5,11 @@ NAMESPACE_BEGIN(CryptoPP) -static const byte s_vecUpper[] = "ABCDEFGHIJKMNPQRSTUVWXYZ23456789"; -static const byte s_vecLower[] = "abcdefghijkmnpqrstuvwxyz23456789"; +namespace +{ + const byte s_vecUpper[] = "ABCDEFGHIJKMNPQRSTUVWXYZ23456789"; + const byte s_vecLower[] = "abcdefghijkmnpqrstuvwxyz23456789"; +} void Base32Encoder::IsolatedInitialize(const NameValuePairs ¶meters) { diff --git a/base64.cpp b/base64.cpp index 95e6abf2..6f4a11cc 100644 --- a/base64.cpp +++ b/base64.cpp @@ -5,13 +5,12 @@ NAMESPACE_BEGIN(CryptoPP) -// Base64 -static const byte s_stdVec[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -// Base64URL -static const byte s_urlVec[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -static const byte s_padding = '='; +namespace +{ + const byte s_stdVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + const byte s_urlVec[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; + const byte s_padding = '='; +} void Base64Encoder::IsolatedInitialize(const NameValuePairs ¶meters) { diff --git a/des.cpp b/des.cpp index 6e9a393a..7807e752 100644 --- a/des.cpp +++ b/des.cpp @@ -221,7 +221,8 @@ static byte sbox[8][64] = { }; /* 32-bit permutation function P used on the output of the S-boxes */ -static byte p32i[] = { +namespace { + const byte p32i[] = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, @@ -230,11 +231,13 @@ static byte p32i[] = { 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 -}; + }; +} #endif /* permuted choice table (key) */ -static const byte pc1[] = { +namespace { + const byte pc1[] = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, @@ -244,15 +247,19 @@ static const byte pc1[] = { 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 -}; + }; +} /* number left rotations of pc1 */ -static const byte totrot[] = { +namespace { + const byte totrot[] = { 1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 -}; + }; +} /* permuted choice key (table) */ -static const byte pc2[] = { +namespace { + const byte pc2[] = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, @@ -261,14 +268,17 @@ static const byte pc2[] = { 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 -}; + }; +} /* End of DES-defined tables */ /* bit 0 is left-most in byte */ -static const int bytebit[] = { +namespace { + const int bytebit[] = { 0200,0100,040,020,010,04,02,01 -}; + }; +} /* Set key (initialize key schedule array) */ void RawDES::RawSetKey(CipherDir dir, const byte *key) diff --git a/hex.cpp b/hex.cpp index ec09a05c..dbf1cf64 100644 --- a/hex.cpp +++ b/hex.cpp @@ -8,8 +8,11 @@ NAMESPACE_BEGIN(CryptoPP) -static const byte s_vecUpper[] = "0123456789ABCDEF"; -static const byte s_vecLower[] = "0123456789abcdef"; +namespace +{ + const byte s_vecUpper[] = "0123456789ABCDEF"; + const byte s_vecLower[] = "0123456789abcdef"; +} void HexEncoder::IsolatedInitialize(const NameValuePairs ¶meters) { diff --git a/integer.cpp b/integer.cpp index 7cc4d70a..e1d59f8b 100644 --- a/integer.cpp +++ b/integer.cpp @@ -3028,7 +3028,7 @@ struct NewInteger // File scope static due to subtle initialization problems in a threaded // Windows environment. See the comments for Singleton. Thanks DB. -static const Integer& s_zero = Singleton().Ref(); +namespace { const Integer& s_zero = Singleton().Ref(); } const Integer &Integer::Zero() { return s_zero; @@ -3036,7 +3036,7 @@ const Integer &Integer::Zero() // File scope static due to subtle initialization problems in a threaded // Windows environment. See the comments for Singleton. Thanks DB. -static const Integer& s_one = Singleton >().Ref(); +namespace { const Integer& s_one = Singleton >().Ref(); } const Integer &Integer::One() { return s_one; @@ -3044,7 +3044,7 @@ const Integer &Integer::One() // File scope static due to subtle initialization problems in a threaded // Windows environment. See the comments for Singleton. Thanks DB. -static const Integer& s_two = Singleton >().Ref(); +namespace { const Integer& s_two = Singleton >().Ref(); } const Integer &Integer::Two() { return s_two;