Commit Graph

2714 Commits

Author SHA1 Message Date
Jeffrey Walton
04908cca48
Improve x86 and x64 ARIA performance
The changes were meant to improve Windows, but GCC benefited more. Windows gained 0.3 cpb, while GCC gained 1.2 cpb
2017-04-13 06:52:56 -04:00
Jeffrey Walton
35f95fb739
Fix unaligned pointer crash on Win32 due to _mm_load_si128
The SSSE3 intrinsics were performing aligned loads using _mm_load_si128 using user supplied pointers. The pointers are only a byte pointer, so its alignment can drop to 1 or 2. Switching to _mm_loadu_si128 will sidestep potential problems. The crash surfaced under Win32 testing.

Switch to memcpy's when performing bulk assignment x[0]=y[0] ... x[3]=y[3]. I believe Yun used the pattern to promote vectorization. Some compilers appear to be braindead and issue integer move's one word at a time. Non-braindead compiler will still take the optimization when advantageous, and slower compilers will benefit from the bulk move. We also cherry picked vectorization opportunities, like in ARIA_GSRK_NEON.

Remove keyBits variable. We now use UncheckedSetKey's keylen throughout.

Also fix a typo in CRYPTOPP_BOOL_SSSE3_INTRINSICS_AVAILABLE. __SSSE3__ was listed twice.
2017-04-13 04:28:02 -04:00
Jeffrey Walton
59767be52e
Add Intel and ARM intrinsics
Win32 and Win64 benefited from the Intel intrinsics. A32 and Aarch64 benefited from the ARM intrinsics. The intrinsics shaved 150 to 350 cycles from key setup.

The intrinsics slowed modern GCC down a small bit, and did not appear to affect old GCC. As such, Intel intrinsics were only enabled for Microsoft compilers.

We were not able to improve encryption and decryption. In fact, some of the attempted macro conversions and intrinsics attempts slowed things down considerably. For example, GCC 5.4 on x86_64 went from 120 MB/s to about 70 MB/s when we tried to improve code around the Key XOR Layer (ARIA_KXL).
2017-04-12 23:28:41 -04:00
Jeffrey Walton
f44e705c16 Add NEON intrinsics for ARIA_GSRK_NEON
Update documentation
2017-04-12 12:15:32 -04:00
Jeffrey Walton
af561758df
Rework ARIA_GSRK to have MSVC generate "rotate imm" rather than "rot reg"
The immediate version of rotate can be 4 to 6 times faster than the register version
2017-04-11 20:47:54 -04:00
Jeffrey Walton
d6b295203b
Additional library integration for ARIA 2017-04-11 16:19:36 -04:00
Jeffrey Walton
0d742591e0
Switch to code based on 32-bit implementation
The 32-bit code is based on Aaram Yun's code. Yun's code combined with a few library specific tweaks improves performance to roughly Camellia.
2017-04-11 11:39:45 -04:00
Jeffrey Walton
7990da2c02
Reformat aria.txt test vectors 2017-04-11 06:53:44 -04:00
Jeffrey Walton
8ca0f47939
Add ARIA block cipher
This is the reference implementation, test data and test vectors from the ARIA.zip package on the KISA website. The website is located at http://seed.kisa.or.kr/iwt/ko/bbs/EgovReferenceList.do?bbsId=BBSMSTR_000000000002.

We have optimized routines that improve Key Setup and Bulk Encryption performance, but they are not being checked-in at the moment. The ARIA team is updating its implementation for contemporary hardware and we would like to use it as a starting point before we wander too far away from the KISA implementation.
2017-04-10 10:52:40 -04:00
Jeffrey Walton
8c7408bcd5
Fix typo 2017-04-03 20:27:49 -04:00
anonimal
a9f2518a2c
Build: apply patch for GNU assembler errors to CMake
References weidai11/cryptopp#395
2017-03-29 07:01:04 +00:00
Jeffrey Walton
c21023e2dc
Removed 'aligned' makefile target. It was made default in 5.6.5 2017-03-28 23:49:58 -04:00
Jeffrey Walton
c305e88127
Fix runtime crash when CRYPTOPP_INIT_PRIORITY=0
Couple use of initialization priorities to no NO_OS_DEPENDENCE
Add comments explaining what integer does, how it does it, and why we want to inprove on the Singleton pattern as a resource manager.
Update documentation.
2017-03-27 06:06:12 -04:00
Jeffrey Walton
0e55f5ac7d
Remove g_pAssignIntToInteger pointer, add CRYPTOPP_NO_ASSIGN_TO_INTEGER (Issue 389)
This effectively decouples Integer and Public Key from the rest of the library. The change means a compile time define is used rather than a runtime pointer. It avoids the race with Issue 389.
The Public Key algorithms will fail if you use them. For example, running the self tests with CRYPTOPP_NO_ASSIGN_TO_INTEGER in effect results in "CryptoPP::Exception caught: NameValuePairs: type mismatch for 'EquivalentTo', stored 'i', trying to retrieve 'N8CryptoPP7IntegerE'". The exception is expected, and the same happend when g_pAssignIntToInteger was present.
2017-03-25 16:38:42 -04:00
Jeffrey Walton
6c50a99254
Fix GNUmakefile to keep *.s files
The distclean recipe deleted ASM files (*.s) rather than preprocessed ASM files (*.S). Leave them both now.
2017-03-25 01:42:23 -04:00
Jeffrey Walton
661ddad1f2
Fix Solaris compile due to StreamState
"validate.h", line 155: Error: Overloading ambiguity between "std::ios::basic_ios(std::streambuf *)" and "std::ios::basic_ios(int)".
2017-03-24 23:24:46 -04:00
Jeffrey Walton
effe103641 Merge pull request #392 from janblome/issue391
Remove unnecessary static from reference to singleton
2017-03-23 16:45:18 -04:00
Jeffrey Walton
6381faf277
Rename rdrand.S to rdrand.s 2017-03-23 16:05:30 -04:00
Jeffrey Walton
30263ee497 Rename rdrand.S to rdrand.s
The file is not preprocessed
2017-03-23 15:39:43 -04:00
Jeffrey Walton
d865cf9e62
Fix OpenBSD 6.0 compile with GCC 4.9 (Issue 395)
This check-in also enables the 64-bit RDRAND routines for X32. The changes were with held until they could be tested. The testing occurred with Issue 395
2017-03-22 17:26:25 -04:00
Jeffrey Walton
2ea91ba1b9
Fix ARM compile under VS2013 2017-03-20 15:11:27 -04:00
Jeffrey Walton
f502ee9218
Simplify C++ dynamic object initialization
Wrap DetectArmFeatures and DetectX86Features in InitializeCpu class
Use init_priority for InitializeCpu
Remove HAVE_GCC_CONSTRUCTOR1 and HAVE_GCC_CONSTRUCTOR0
Use init_seg(<name>) on Windows and explicitly insert at XCU segment
Simplify logic for HAVE_GAS
Remove special recipies for MACPORTS_GCC_COMPILER
Move C++ static initializers into anonymous namespace when possible
Add default NullNameValuePairs ctor for Clang
2017-03-20 08:51:10 -04:00
Jeffrey Walton
0c6510b0a5
Guard string assignment
Visual Studio 2005 fired an assert on the negative self tests because the SecByteBlock was 0-sized and returned a null pointer.
2017-03-19 22:13:12 -04:00
Jeffrey Walton
e7fa88083c
Add DRBG, Poly1305 and SipHash to VS2005 project files 2017-03-19 21:49:43 -04:00
Jeffrey Walton
b0a151a8c0
Fix VS2015/MSVC 19.00 compiler crash 2017-03-19 10:10:56 -04:00
Jeffrey Walton
a3d0da2e0e
Fix VS2008/MSVC 14.00 compiler crash 2017-03-19 06:57:51 -04:00
Jeffrey Walton
7fb6b3df74
Fix compile under Visual Studio 2005/MSC 14.00
Previous testing occurred with Visual Studio 2005 SP 1, and it lacks some of the Safe C++/security enhanced functions.
2017-03-18 16:56:14 -04:00
Jeffrey Walton
71afcadadb
Clear Coverity STREAM_FORMAT_STATE (CID 177736, 177737, 177732)
Yet another attempt to clear the stream state finding.
2017-03-18 09:48:54 -04:00
Jeffrey Walton
6c6391bfda
Clear Coverity CHECKED_RETURN (CID 177729)
This was by design, but we cleared it because we want a dark and silent cockpit.
2017-03-18 08:52:32 -04:00
Jeffrey Walton
13bcfbe249
Add width field to StreamState 2017-03-18 08:18:05 -04:00
Jeffrey Walton
ad47231dc0
Switch to std::ostream::char_type for StreamState 2017-03-18 08:11:44 -04:00
Jeffrey Walton
342b4505fb
Clear Coverity IDENTICAL_BRANCHES (CID 177731)
This was by design, but we cleared it because we want a dark and silent cockpit.
2017-03-18 07:18:30 -04:00
Jeffrey Walton
bc6d48df59
Cleared C4456 "declaration hides previous local declaration" for MSVC 2017-03-18 07:06:59 -04:00
Jeffrey Walton
1bfb6be934
Clear Coverity STREAM_FORMAT_STATE (CID 177735)
This was a valid finding in the Test suite. The stream state findings are annoying.
2017-03-18 05:08:04 -04:00
Jeffrey Walton
e6817b73e5
Cleared -Wunused-but-set-variable for GCC when using word128 2017-03-18 04:51:43 -04:00
Jeffrey Walton
8ad6782bec
Clear Coverity UNINIT_CTOR (CID 177743, 177744)
This was a valid finding, but the only way to get into the codepath was leaving the drbg unkeyed.
2017-03-17 21:53:38 -04:00
Jeffrey Walton
08f9b3ff9e
Clear Coverity UNINIT_CTOR (CID 177741)
This was a valid finding, but the only way to get into the codepath leaving the hash unkeyed.
2017-03-17 21:48:52 -04:00
Jeffrey Walton
690baaae97
Clear Coverity UNINIT_CTOR (CID 177739)
This was a valid finding, but the only way to get into the codepath leaving the hash unkeyed.
2017-03-17 21:45:35 -04:00
Jeffrey Walton
80bbc834fe
Clear Coverity UNINIT (CID 171239)
It was a false positive, but dark and silent cockpits trump the uneeded initialization. The optimizer can remove it.
2017-03-17 21:29:15 -04:00
Jeffrey Walton
301437e693
Updated static initializers
When MSVC init_seg or GCC init_priority is available, we don't need to use the Singleton. We only need to create a file scope class variable and place it in the segment for MSVC or provide the attribute for GCC.
An additional upside is we cleared all the memory leaks that used to be reported by MSVC for debug builds.
2017-03-17 20:47:32 -04:00
Jeffrey Walton
bed31de2f6
Whitespace check-in 2017-03-17 18:31:40 -04:00
Jeffrey Walton
c90a63196a
Add StringWiden function
StringWiden converts a narrow C-style string to a wide string. It serves the opposite role of StringNarrow function. The function is useful on Windows platforms where the OS favors wide functions with the UTF-16 character set. For example, the Data Proction API (DPAPI) allows a description, but its a wide character C-string. There is no narrwo version of the API.
2017-03-17 04:57:38 -04:00
Jeffrey Walton
e55560e1a2
Update Coverity modeling file 2017-03-15 15:46:23 -04:00
Jeffrey Walton
01cea29692
Remove MSVC C4297 warning suppression (Issue 19) 2017-03-15 08:08:43 -04:00
jan-dominik.blome
fcdf293356 Remove unnecessary static from reference to singleton 2017-03-15 12:29:36 +01:00
Jeffrey Walton
46c9cc725c
Use C++03 Singleton on select Microsoft platforms (Issues 372, 373, 389, 391)
We are back to the "... one object may end up being memory leaked" if faced with concurrent initialization
2017-03-15 06:20:45 -04:00
Jeffrey Walton
354502d59d
Change HAS_NASM to USE_NASM. The makefile does not etect it automatically 2017-03-14 18:38:37 -04:00
Jeffrey Walton
d8570a3435
Avoid inlining LibraryVersion (Issue 371) 2017-03-14 10:26:51 -04:00
Jeffrey Walton
f9773d2961
Updated RDRAND and RDSEED under NASM
Port rdrand.S to Solaris
Port rdrand.S to X32
The X32 port is responsible for the loop unwinding. The unwind generates a 32-byte block (X64 and X32) or 16-byte block (X86). On X32, it increases throughut by 100% (doubles it). On X86 and X64, throughput increases by about 6%. Anything over 4 machine words slows things down.
2017-03-14 06:07:37 -04:00
Jeffrey Walton
4bcaabbe26
Updated RDRAND and RDSEED under NASM
Port rdrand.S to Cygwin and OS X
Add DISABLE_NATIVE_ARCH to CmakefileList and GNUmakefile. It supresses the addition of -march=native. DISABLE_NATIVE_ARCH replaces DISABLE_CXXFLAGS_OPTIMIZATIONS in CmakefileList (the latter is now deprecated).
2017-03-13 15:57:47 -04:00