Add statics to anonymous namespace

This commit is contained in:
Jeffrey Walton 2016-10-10 18:20:49 -04:00
parent 145a83e4cd
commit 2d8992a547
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
6 changed files with 45 additions and 27 deletions

View File

@ -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)
{

View File

@ -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 &parameters)
{

View File

@ -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 &parameters)
{

30
des.cpp
View File

@ -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)

View File

@ -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 &parameters)
{

View File

@ -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<Integer>().Ref();
namespace { const Integer& s_zero = Singleton<Integer>().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<Integer, NewInteger<1> >().Ref();
namespace { const Integer& s_one = Singleton<Integer, NewInteger<1> >().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<Integer, NewInteger<2> >().Ref();
namespace { const Integer& s_two = Singleton<Integer, NewInteger<2> >().Ref(); }
const Integer &Integer::Two()
{
return s_two;