diff --git a/cryptdll.vcxproj b/cryptdll.vcxproj index 9553cd14..e86a9791 100644 --- a/cryptdll.vcxproj +++ b/cryptdll.vcxproj @@ -1,4 +1,4 @@ - + @@ -21,20 +21,17 @@ {94a428a1-9ba8-4db2-b76e-bd2e3c08f257} cryptdll - v100 + v110 DynamicLibrary - - - DynamicLibrary @@ -46,7 +43,6 @@ $(Platform)\DLL_Output\$(Configuration)\ $(Platform)\$(ProjectName)\$(Configuration)\ - @@ -67,7 +63,6 @@ $(TargetDir)\cryptopp.lib - @@ -83,7 +78,6 @@ 0x0409 - @@ -105,7 +99,6 @@ true - @@ -116,7 +109,6 @@ true - @@ -126,7 +118,6 @@ MachineX64 - @@ -142,7 +133,6 @@ Properties="Configuration=Debug;Platform=Win32;"/> --> - Creating Win32/Debug cryptest.exe for MAC computation @@ -152,7 +142,6 @@ - @@ -165,7 +154,6 @@ $(OutDir)cryptopp.mac.done;%(Outputs) - @@ -174,7 +162,6 @@ $(IntDir)x64dll.obj;%(Outputs) - @@ -239,7 +226,6 @@ - @@ -310,7 +296,6 @@ - @@ -319,4 +304,4 @@ - + \ No newline at end of file diff --git a/cryptest.vcxproj b/cryptest.vcxproj index c857b673..8fe70017 100644 --- a/cryptest.vcxproj +++ b/cryptest.vcxproj @@ -1,4 +1,4 @@ - + @@ -34,16 +34,14 @@ x64 - {09cdac08-e6ae-48a9-8de7-0fbc779eebde} cryptest - v100 + v110 Application - @@ -52,7 +50,6 @@ - Application @@ -62,7 +59,6 @@ MultiByte true - @@ -77,7 +73,6 @@ $(Platform)\DLL_Output\Release\ $(Platform)\$(ProjectName)\$(Configuration)\ - @@ -97,7 +92,6 @@ Console - @@ -113,7 +107,6 @@ 0x0409 - @@ -135,7 +128,6 @@ true - @@ -155,7 +147,6 @@ cryptopp.lib;cryptlib.lib;Ws2_32.lib - @@ -166,7 +157,6 @@ true - @@ -176,7 +166,6 @@ MachineX64 - @@ -190,14 +179,12 @@ - - @@ -215,14 +202,12 @@ - - diff --git a/cryptest.vcxproj.filters b/cryptest.vcxproj.filters index 2d2177b0..ec0ae192 100644 --- a/cryptest.vcxproj.filters +++ b/cryptest.vcxproj.filters @@ -1,4 +1,4 @@ - + @@ -75,9 +75,6 @@ TestVectors - - TestVectors - TestVectors diff --git a/cryptest.vcxproj.user b/cryptest.vcxproj.user index ceb23602..08271a53 100644 --- a/cryptest.vcxproj.user +++ b/cryptest.vcxproj.user @@ -1,6 +1,9 @@ - + - v + tv kalyna - + + WindowsLocalDebugger + + \ No newline at end of file diff --git a/cryptlib.vcxproj b/cryptlib.vcxproj index 22d3e4d7..fcfe505b 100644 --- a/cryptlib.vcxproj +++ b/cryptlib.vcxproj @@ -1,4 +1,4 @@ - + @@ -37,7 +37,7 @@ {c39f4b46-6e89-4074-902e-ca57073044d2} cryptlib - v100 + v110 StaticLibrary @@ -50,7 +50,6 @@ - StaticLibrary @@ -60,7 +59,6 @@ MultiByte true - @@ -75,7 +73,6 @@ $(Platform)\DLL_Output\Release\ $(Platform)\$(ProjectName)\$(Configuration)\ - @@ -89,7 +86,6 @@ NoErrorReport - @@ -105,7 +101,6 @@ 0x0409 - @@ -123,7 +118,6 @@ 0x0409 - @@ -135,7 +129,6 @@ NDEBUG;USE_PRECOMPILED_HEADERS;CRYPTOPP_IMPORTS;%(PreprocessorDefinitions) - @@ -146,7 +139,6 @@ true - @@ -156,9 +148,7 @@ MachineX64 - - diff --git a/dlltest.vcxproj b/dlltest.vcxproj index f008456c..c82c557a 100644 --- a/dlltest.vcxproj +++ b/dlltest.vcxproj @@ -1,4 +1,4 @@ - + @@ -21,20 +21,17 @@ {1974a53a-9863-41c9-886d-b2b8c2fc3c8b} dlltest - v100 + v110 Application - - - Application @@ -44,7 +41,6 @@ $(Platform)\DLL_Output\$(Configuration)\ $(Platform)\$(ProjectName)\$(Configuration)\ - @@ -61,7 +57,6 @@ true - @@ -77,7 +72,6 @@ 0x0409 - @@ -99,7 +93,6 @@ true - @@ -110,7 +103,6 @@ true - @@ -120,14 +112,12 @@ MachineX64 - - - + \ No newline at end of file diff --git a/kalyna.cpp b/kalyna.cpp index 864f139d..eba64846 100644 --- a/kalyna.cpp +++ b/kalyna.cpp @@ -929,20 +929,16 @@ void Kalyna::Base::SetKey_88(const word64 key[8]) // *********************** ProcessAndXorBlock specializations *********************** // -void Kalyna::Base::ProcessBlock_22(const word64 inBlock[2], word64 outBlock[2]) const +void Kalyna::Base::ProcessBlock_22(const word64 inBlock[2], const word64 xorBlock[2], word64 outBlock[2]) const { -#if defined(IS_BIG_ENDIAN) word64 *t1 = m_wspace+0, *t2 = m_wspace+2, *msg = m_wspace+4; - { - typedef GetBlock Block; - Block block(inBlock); - block(msg[0])(msg[1]); - inBlock = msg; - } -#else - word64 *t1 = outBlock, *t2 = m_wspace+2; -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef GetBlock InBlock; + InBlock iblk(inBlock); + iblk(msg[0])(msg[1]); + + inBlock = msg; if (IsForwardTransformation()) { AddKey<2>(inBlock, t1, m_rkeys); @@ -973,29 +969,22 @@ void Kalyna::Base::ProcessBlock_22(const word64 inBlock[2], word64 outBlock[2]) IGL128(t2, t1, &m_rkeys[0]); } -#if defined(IS_BIG_ENDIAN) - { - typedef GetBlock Block; - Block block(t1); - block(outBlock[0])(outBlock[1]); - } -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef PutBlock OutBlock; + OutBlock oblk(xorBlock, outBlock); + oblk(t1[0])(t1[1]); } -void Kalyna::Base::ProcessBlock_24(const word64 inBlock[2], word64 outBlock[2]) const +void Kalyna::Base::ProcessBlock_24(const word64 inBlock[2], const word64 xorBlock[2], word64 outBlock[2]) const { -#if defined(IS_BIG_ENDIAN) word64 *t1 = m_wspace+0, *t2 = m_wspace+2, *msg = m_wspace+4; - { - typedef GetBlock Block; - Block block(inBlock); - block(msg[0])(msg[1]); - inBlock = msg; - } -#else - word64 *t1 = outBlock, *t2 = m_wspace+2; -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef GetBlock InBlock; + InBlock iblk(inBlock); + iblk(msg[0])(msg[1]); + + inBlock = msg; if (IsForwardTransformation()) { AddKey<2>(inBlock, t1, m_rkeys); @@ -1034,29 +1023,22 @@ void Kalyna::Base::ProcessBlock_24(const word64 inBlock[2], word64 outBlock[2]) IGL128(t2, t1, &m_rkeys[0]); } -#if defined(IS_BIG_ENDIAN) - { - typedef GetBlock Block; - Block block(t1); - block(outBlock[0])(outBlock[1]); - } -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef PutBlock OutBlock; + OutBlock oblk(xorBlock, outBlock); + oblk(t1[0])(t1[1]); } -void Kalyna::Base::ProcessBlock_44(const word64 inBlock[4], word64 outBlock[4]) const +void Kalyna::Base::ProcessBlock_44(const word64 inBlock[4], const word64 xorBlock[4], word64 outBlock[4]) const { -#if defined(IS_BIG_ENDIAN) word64 *t1 = m_wspace+0, *t2 = m_wspace+4, *msg = m_wspace+8; - { - typedef GetBlock Block; - Block block(inBlock); - block(msg[0])(msg[1])(msg[2])(msg[3]); - inBlock = msg; - } -#else - word64 *t1 = outBlock, *t2 = m_wspace+4; -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef GetBlock InBlock; + InBlock iblk(inBlock); + iblk(msg[0])(msg[1])(msg[2])(msg[3]); + + inBlock = msg; if (IsForwardTransformation()) { AddKey<4>(inBlock, t1, m_rkeys); @@ -1095,32 +1077,25 @@ void Kalyna::Base::ProcessBlock_44(const word64 inBlock[4], word64 outBlock[4]) IGL256(t2, t1, &m_rkeys[0]); } -#if defined(IS_BIG_ENDIAN) - { - typedef GetBlock Block; - Block block(t1); - block(outBlock[0])(outBlock[1])(outBlock[2])(outBlock[3]); - } -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef PutBlock OutBlock; + OutBlock oblk(xorBlock, outBlock); + oblk(t1[0])(t1[1])(t1[2])(t1[3]); } -void Kalyna::Base::ProcessBlock_48(const word64 inBlock[4], word64 outBlock[4]) const +void Kalyna::Base::ProcessBlock_48(const word64 inBlock[4], const word64 xorBlock[4], word64 outBlock[4]) const { -#if defined(IS_BIG_ENDIAN) word64 *t1 = m_wspace+0, *t2 = m_wspace+4, *msg = m_wspace+8; - { - typedef GetBlock Block; - Block block(inBlock); - block(msg[0])(msg[1])(msg[2])(msg[3]); - inBlock = msg; - } -#else - word64 *t1 = outBlock, *t2 = m_wspace+4; -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef GetBlock InBlock; + InBlock iblk(inBlock); + iblk(msg[0])(msg[1])(msg[2])(msg[3]); + + inBlock = msg; if (IsForwardTransformation()) { - AddKey<4>((const word64*)inBlock, t1, m_rkeys); + AddKey<4>(inBlock, t1, m_rkeys); G256(t1, t2, &m_rkeys[4]); // 1 G256(t2, t1, &m_rkeys[8]); // 2 G256(t1, t2, &m_rkeys[12]); // 3 @@ -1164,29 +1139,22 @@ void Kalyna::Base::ProcessBlock_48(const word64 inBlock[4], word64 outBlock[4]) IGL256(t2, t1, &m_rkeys[0]); } -#if defined(IS_BIG_ENDIAN) - { - typedef GetBlock Block; - Block block(t1); - block(outBlock[0])(outBlock[1])(outBlock[2])(outBlock[3]); - } -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef PutBlock OutBlock; + OutBlock oblk(xorBlock, outBlock); + oblk(t1[0])(t1[1])(t1[2])(t1[3]); } -void Kalyna::Base::ProcessBlock_88(const word64 inBlock[8], word64 outBlock[8]) const +void Kalyna::Base::ProcessBlock_88(const word64 inBlock[8], const word64 xorBlock[8], word64 outBlock[8]) const { -#if defined(IS_BIG_ENDIAN) word64 *t1 = m_wspace+0, *t2 = m_wspace+8, *msg = m_wspace+16; - { - typedef GetBlock Block; - Block block(inBlock); - block(msg[0])(msg[1])(msg[2])(msg[3])(msg[4])(msg[5])(msg[6])(msg[7]); - inBlock = msg; - } -#else - word64 *t1 = outBlock, *t2 = m_wspace+8; -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef GetBlock InBlock; + InBlock iblk(inBlock); + iblk(msg[0])(msg[1])(msg[2])(msg[3])(msg[4])(msg[5])(msg[6])(msg[7]); + + inBlock = msg; if (IsForwardTransformation()) { AddKey<8>(inBlock, t1, m_rkeys); @@ -1233,14 +1201,10 @@ void Kalyna::Base::ProcessBlock_88(const word64 inBlock[8], word64 outBlock[8]) IGL512(t2, t1, &m_rkeys[0]); } -#if defined(IS_BIG_ENDIAN) - { - typedef GetBlock Block; - Block block(t1); - block(outBlock[0])(outBlock[1])(outBlock[2])(outBlock[3]) - (outBlock[4])(outBlock[5])(outBlock[6])(outBlock[7]); - } -#endif + // Reverse bytes on BigEndian; Align pointer on LittleEndian + typedef PutBlock OutBlock; + OutBlock oblk(xorBlock, outBlock); + oblk(t1[0])(t1[1])(t1[2])(t1[3])(t1[4])(t1[5])(t1[6])(t1[7]); } // *********************** Library routines *********************** // @@ -1324,32 +1288,34 @@ void Kalyna::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, const byte* p = reinterpret_cast(KalynaTab::S); for (unsigned int i=0; i<256; i+=cacheLineSize) - u &= *reinterpret_cast(p+i); + u ^= *reinterpret_cast(p+i); m_wspace[0] = u; switch ((m_nb << 8) | m_nk) { case (2 << 8) | 2: - ProcessBlock_22(reinterpret_cast(inBlock), reinterpret_cast(outBlock)); + ProcessBlock_22(reinterpret_cast(inBlock), + reinterpret_cast(xorBlock), reinterpret_cast(outBlock)); break; case (2 << 8) | 4: - ProcessBlock_24(reinterpret_cast(inBlock), reinterpret_cast(outBlock)); + ProcessBlock_24(reinterpret_cast(inBlock), + reinterpret_cast(xorBlock), reinterpret_cast(outBlock)); break; case (4 << 8) | 4: - ProcessBlock_44(reinterpret_cast(inBlock), reinterpret_cast(outBlock)); + ProcessBlock_44(reinterpret_cast(inBlock), + reinterpret_cast(xorBlock), reinterpret_cast(outBlock)); break; case (4 << 8) | 8: - ProcessBlock_48(reinterpret_cast(inBlock), reinterpret_cast(outBlock)); + ProcessBlock_48(reinterpret_cast(inBlock), + reinterpret_cast(xorBlock), reinterpret_cast(outBlock)); break; case (8 << 8) | 8: - ProcessBlock_88(reinterpret_cast(inBlock), reinterpret_cast(outBlock)); + ProcessBlock_88(reinterpret_cast(inBlock), + reinterpret_cast(xorBlock), reinterpret_cast(outBlock)); break; default: CRYPTOPP_ASSERT(0); } - - for (size_t i=0; xorBlock && i // void ProcessBlock_Template(const word64 inBlock[NB], const word64 outBlock[NB]) const; - void ProcessBlock_22(const word64 inBlock[2], word64 outBlock[2]) const; - void ProcessBlock_24(const word64 inBlock[2], word64 outBlock[2]) const; - void ProcessBlock_44(const word64 inBlock[4], word64 outBlock[4]) const; - void ProcessBlock_48(const word64 inBlock[4], word64 outBlock[4]) const; - void ProcessBlock_88(const word64 inBlock[8], word64 outBlock[8]) const; + void ProcessBlock_22(const word64 inBlock[2], const word64 xorBlock[2], word64 outBlock[2]) const; + void ProcessBlock_24(const word64 inBlock[2], const word64 xorBlock[2] ,word64 outBlock[2]) const; + void ProcessBlock_44(const word64 inBlock[4], const word64 xorBlock[4], word64 outBlock[4]) const; + void ProcessBlock_48(const word64 inBlock[4], const word64 xorBlock[4], word64 outBlock[4]) const; + void ProcessBlock_88(const word64 inBlock[8], const word64 xorBlock[8], word64 outBlock[8]) const; private: typedef SecBlock > AlignedSecBlock64; diff --git a/regtest2.cpp b/regtest2.cpp index b5528869..0e9d3d2d 100644 --- a/regtest2.cpp +++ b/regtest2.cpp @@ -135,6 +135,7 @@ void RegisterFactories2() RegisterSymmetricCipherDefaultFactories >(); RegisterSymmetricCipherDefaultFactories >(); RegisterSymmetricCipherDefaultFactories >(); // Test Vectors + RegisterSymmetricCipherDefaultFactories >(); // Test Vectors RegisterSymmetricCipherDefaultFactories >(); // Benchmarks RegisterDefaultFactoryFor >();