Add CRYPTOPP_TABLE, remove CRYPTOPP_SECTION

This commit is contained in:
Jeffrey Walton 2018-01-21 14:19:00 -05:00
parent 5631da3697
commit c4e0942a68
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
6 changed files with 28 additions and 32 deletions

View File

@ -6,10 +6,8 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(ARIATab) NAMESPACE_BEGIN(ARIATab)
#define EXPORT_TABLE extern
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
EXPORT_TABLE CRYPTOPP_TABLE
const word32 S1[256]={ const word32 S1[256]={
0x00636363,0x007c7c7c,0x00777777,0x007b7b7b,0x00f2f2f2,0x006b6b6b,0x006f6f6f,0x00c5c5c5, 0x00636363,0x007c7c7c,0x00777777,0x007b7b7b,0x00f2f2f2,0x006b6b6b,0x006f6f6f,0x00c5c5c5,
0x00303030,0x00010101,0x00676767,0x002b2b2b,0x00fefefe,0x00d7d7d7,0x00ababab,0x00767676, 0x00303030,0x00010101,0x00676767,0x002b2b2b,0x00fefefe,0x00d7d7d7,0x00ababab,0x00767676,
@ -46,7 +44,7 @@ const word32 S1[256]={
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
EXPORT_TABLE CRYPTOPP_TABLE
const word32 S2[256]={ const word32 S2[256]={
0xe200e2e2,0x4e004e4e,0x54005454,0xfc00fcfc,0x94009494,0xc200c2c2,0x4a004a4a,0xcc00cccc, 0xe200e2e2,0x4e004e4e,0x54005454,0xfc00fcfc,0x94009494,0xc200c2c2,0x4a004a4a,0xcc00cccc,
0x62006262,0x0d000d0d,0x6a006a6a,0x46004646,0x3c003c3c,0x4d004d4d,0x8b008b8b,0xd100d1d1, 0x62006262,0x0d000d0d,0x6a006a6a,0x46004646,0x3c003c3c,0x4d004d4d,0x8b008b8b,0xd100d1d1,
@ -83,7 +81,7 @@ const word32 S2[256]={
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
EXPORT_TABLE CRYPTOPP_TABLE
const word32 X1[256]={ const word32 X1[256]={
0x52520052,0x09090009,0x6a6a006a,0xd5d500d5,0x30300030,0x36360036,0xa5a500a5,0x38380038, 0x52520052,0x09090009,0x6a6a006a,0xd5d500d5,0x30300030,0x36360036,0xa5a500a5,0x38380038,
0xbfbf00bf,0x40400040,0xa3a300a3,0x9e9e009e,0x81810081,0xf3f300f3,0xd7d700d7,0xfbfb00fb, 0xbfbf00bf,0x40400040,0xa3a300a3,0x9e9e009e,0x81810081,0xf3f300f3,0xd7d700d7,0xfbfb00fb,
@ -120,7 +118,7 @@ const word32 X1[256]={
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
EXPORT_TABLE CRYPTOPP_TABLE
const word32 X2[256]={ const word32 X2[256]={
0x30303000,0x68686800,0x99999900,0x1b1b1b00,0x87878700,0xb9b9b900,0x21212100,0x78787800, 0x30303000,0x68686800,0x99999900,0x1b1b1b00,0x87878700,0xb9b9b900,0x21212100,0x78787800,
0x50505000,0x39393900,0xdbdbdb00,0xe1e1e100,0x72727200,0x09090900,0x62626200,0x3c3c3c00, 0x50505000,0x39393900,0xdbdbdb00,0xe1e1e100,0x72727200,0x09090900,0x62626200,0x3c3c3c00,
@ -157,7 +155,7 @@ const word32 X2[256]={
}; };
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
EXPORT_TABLE CRYPTOPP_TABLE
const word32 KRK[3][4] = { const word32 KRK[3][4] = {
{0x517cc1b7, 0x27220a94, 0xfe13abe8, 0xfa9a6ee0}, {0x517cc1b7, 0x27220a94, 0xfe13abe8, 0xfa9a6ee0},
{0x6db14acc, 0x9e21c820, 0xff28b1d5, 0xef5de2b0}, {0x6db14acc, 0x9e21c820, 0xff28b1d5, 0xef5de2b0},

View File

@ -340,15 +340,6 @@ NAMESPACE_END
#endif #endif
#endif #endif
#ifndef CRYPTOPP_SECTION_ALIGN16
#if defined(__GNUC__) && !defined(__APPLE__)
// the alignment attribute doesn't seem to work without this section attribute when -fdata-sections is turned on
#define CRYPTOPP_SECTION_ALIGN16 __attribute__((section ("CryptoPP_Align16")))
#else
#define CRYPTOPP_SECTION_ALIGN16
#endif
#endif
// The section attribute attempts to initialize CPU flags to avoid Valgrind findings above -O1 // The section attribute attempts to initialize CPU flags to avoid Valgrind findings above -O1
#if ((defined(__MACH__) && defined(__APPLE__)) && ((CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70100) || (CRYPTOPP_GCC_VERSION >= 40300))) #if ((defined(__MACH__) && defined(__APPLE__)) && ((CRYPTOPP_LLVM_CLANG_VERSION >= 30600) || (CRYPTOPP_APPLE_CLANG_VERSION >= 70100) || (CRYPTOPP_GCC_VERSION >= 40300)))
#define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data"))) #define CRYPTOPP_SECTION_INIT __attribute__((section ("__DATA,__data")))
@ -891,10 +882,14 @@ NAMESPACE_END
#define CRYPTOPP_DLL #define CRYPTOPP_DLL
#endif #endif
// C++ makes const internal linkage
#define CRYPTOPP_TABLE extern
#define CRYPTOPP_API __cdecl #define CRYPTOPP_API __cdecl
#else // not CRYPTOPP_WIN32_AVAILABLE #else // not CRYPTOPP_WIN32_AVAILABLE
// C++ makes const internal linkage
#define CRYPTOPP_TABLE extern
#define CRYPTOPP_DLL #define CRYPTOPP_DLL
#define CRYPTOPP_API #define CRYPTOPP_API

View File

@ -1437,7 +1437,11 @@ void Baseline_MultiplyTop16(word *R, const word *AA, const word *BB, word L)
#if CRYPTOPP_INTEGER_SSE2 #if CRYPTOPP_INTEGER_SSE2
CRYPTOPP_ALIGN_DATA(16) static const word32 s_maskLow16[4] CRYPTOPP_SECTION_ALIGN16 = {0xffff,0xffff,0xffff,0xffff}; CRYPTOPP_ALIGN_DATA(16)
CRYPTOPP_TABLE
const word32 s_maskLow16[4] = {
0xffff,0xffff,0xffff,0xffff
};
#undef Mul_Begin #undef Mul_Begin
#undef Mul_Acc #undef Mul_Acc

View File

@ -7,9 +7,7 @@
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(KalynaTab) NAMESPACE_BEGIN(KalynaTab)
#define EXPORT_TABLE extern CRYPTOPP_TABLE
EXPORT_TABLE
const word64 T[8][256] = const word64 T[8][256] =
{ {
{ {
@ -542,7 +540,7 @@ const word64 T[8][256] =
} }
}; };
EXPORT_TABLE CRYPTOPP_TABLE
const word64 IT[8][256] = const word64 IT[8][256] =
{ {
{ {
@ -1075,7 +1073,7 @@ const word64 IT[8][256] =
} }
}; };
EXPORT_TABLE CRYPTOPP_TABLE
const byte S[4][256] = const byte S[4][256] =
{ {
{ {
@ -1152,7 +1150,7 @@ const byte S[4][256] =
} }
}; };
EXPORT_TABLE CRYPTOPP_TABLE
const byte IS[4][256] = const byte IS[4][256] =
{ {
{ {

13
sha.cpp
View File

@ -55,9 +55,6 @@
# undef CRYPTOPP_SSE2_ASM_AVAILABLE # undef CRYPTOPP_SSE2_ASM_AVAILABLE
#endif #endif
// C++ makes const internal linkage
#define EXPORT_TABLE extern
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#if CRYPTOPP_SHANI_AVAILABLE #if CRYPTOPP_SHANI_AVAILABLE
@ -229,8 +226,9 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length)
// ************************************************************* // *************************************************************
CRYPTOPP_ALIGN_DATA(16) EXPORT_TABLE CRYPTOPP_ALIGN_DATA(16)
const word32 SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = { CRYPTOPP_TABLE
const word32 SHA256_K[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
@ -665,7 +663,7 @@ ANONYMOUS_NAMESPACE_END
#ifndef CRYPTOPP_GENERATE_X64_MASM #ifndef CRYPTOPP_GENERATE_X64_MASM
#ifdef CRYPTOPP_X64_MASM_AVAILABLE #ifdef CRYPTOPP_X64_MASM_AVAILABLE
EXPORT_TABLE "C" { extern "C" {
void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word32 *data, size_t len); void CRYPTOPP_FASTCALL SHA256_HashMultipleBlocks_SSE2(word32 *state, const word32 *data, size_t len);
} }
#endif #endif
@ -837,7 +835,8 @@ void SHA512::InitState(HashWordType *state)
// We add extern to export table to sha-simd.cpp, but it // We add extern to export table to sha-simd.cpp, but it
// cleared http://github.com/weidai11/cryptopp/issues/502 // cleared http://github.com/weidai11/cryptopp/issues/502
CRYPTOPP_ALIGN_DATA(16) CRYPTOPP_ALIGN_DATA(16)
extern const word64 SHA512_K[80] CRYPTOPP_SECTION_ALIGN16 = { CRYPTOPP_TABLE
const word64 SHA512_K[80] = {
W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd), W64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),
W64LIT(0xb5c0fbcfec4d3b2f), W64LIT(0xe9b5dba58189dbbc), W64LIT(0xb5c0fbcfec4d3b2f), W64LIT(0xe9b5dba58189dbbc),
W64LIT(0x3956c25bf348b538), W64LIT(0x59f111f1b605d019), W64LIT(0x3956c25bf348b538), W64LIT(0x59f111f1b605d019),

View File

@ -127,9 +127,11 @@ void Whirlpool::TruncatedFinal(byte *hash, size_t size)
*/ */
#if CRYPTOPP_SSE2_ASM_AVAILABLE #if CRYPTOPP_SSE2_ASM_AVAILABLE
CRYPTOPP_ALIGN_DATA(16) static const word64 Whirlpool_C[4*256+R] CRYPTOPP_SECTION_ALIGN16 = { CRYPTOPP_ALIGN_DATA(16)
CRYPTOPP_TABLE
const word64 Whirlpool_C[4*256+R] = {
#else #else
static const word64 Whirlpool_C[4*256+R] = { const word64 Whirlpool_C[4*256+R] = {
#endif #endif
W64LIT(0x18186018c07830d8), W64LIT(0x23238c2305af4626), W64LIT(0xc6c63fc67ef991b8), W64LIT(0xe8e887e8136fcdfb), W64LIT(0x18186018c07830d8), W64LIT(0x23238c2305af4626), W64LIT(0xc6c63fc67ef991b8), W64LIT(0xe8e887e8136fcdfb),
W64LIT(0x878726874ca113cb), W64LIT(0xb8b8dab8a9626d11), W64LIT(0x0101040108050209), W64LIT(0x4f4f214f426e9e0d), W64LIT(0x878726874ca113cb), W64LIT(0xb8b8dab8a9626d11), W64LIT(0x0101040108050209), W64LIT(0x4f4f214f426e9e0d),