From 92163356db5c31600b9b1ecf9cd4986fb92db76e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 18 Aug 2018 21:41:13 -0400 Subject: [PATCH] Move constant table to unnamed namespace --- wake.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/wake.cpp b/wake.cpp index 77f17985..f4e43dc1 100644 --- a/wake.cpp +++ b/wake.cpp @@ -5,6 +5,15 @@ #include "wake.h" #include "smartptr.h" +ANONYMOUS_NAMESPACE_BEGIN + +const unsigned int TT[8]= { + 0x726a8f3b, 0xe69a3b5c, 0xd3c71fe5, 0xab3c73d2, + 0x4d3a8eb3, 0x0396d6e8, 0x3d4c2f7a, 0x9ee27cf3 +} ; + +ANONYMOUS_NAMESPACE_END + NAMESPACE_BEGIN(CryptoPP) #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) @@ -25,17 +34,7 @@ void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3) { // this code is mostly copied from David Wheeler's paper "A Bulk Data Encryption Algorithm" signed int x, z, p; - // x and z were declared as "long" in Wheeler's paper, which is a signed type. I don't know if that was intentional, but it's too late to change it now. -- Wei 7/4/2010 - CRYPTOPP_COMPILE_ASSERT(sizeof(x) == 4); - static unsigned int tt[10]= { - 0x726a8f3b, // table - 0xe69a3b5c, - 0xd3c71fe5, - 0xab3c73d2, - 0x4d3a8eb3, - 0x0396d6e8, - 0x3d4c2f7a, - 0x9ee27cf3, } ; + t[0] = k0; t[1] = k1; t[2] = k2; @@ -43,7 +42,7 @@ void WAKE_Base::GenKey(word32 k0, word32 k1, word32 k2, word32 k3) for (p=4 ; p<256 ; p++) { x=t[p-4]+t[p-1] ; // fill t - t[p]= (x>>3) ^ tt[x&7] ; + t[p]= (x>>3) ^ TT[x&7] ; } for (p=0 ; p<23 ; p++)