Commit Graph

84 Commits

Author SHA1 Message Date
Jeffrey Walton
896225069d
Rename files with dashes to underscores (GH #736)
Also see https://groups.google.com/forum/#!topic/cryptopp-users/HBz-6gZZFOA on the mailing list
2018-11-10 08:00:14 -05:00
Jeffrey Walton
1ff6f39ec6
Add proper declaration for Kalyna tables; and split from definitions 2018-10-28 06:09:46 -04:00
Jeffrey Walton
1d0c6dd916
Cleanup SHA SIMD source file
Add proper declaration for SHA256_K and SHA512_K tables; and split from definitions
2018-10-28 04:45:26 -04:00
Jeffrey Walton
1acbedd4f8
Fix spelling and grammar 2018-10-13 22:15:41 -04:00
Jeffrey Walton
1bbbfb6b75
Fix partial specializations for FixedSizeAllocatorWithCleanup (PR #710)
Commit afbd3e60f6 effectively treated a symptom and not the underlying problem. The problem was linkers on 32-bit systems ignore CRYPTOPP_ALIGN_DAT(16) passed down by the compiler and align to 8-bytes or less. We have to use Wei's original code in some places. It is not a bad thing, but the bit fiddling is something we would like to contain a little more by depending more on language or platform features.

This commit keeps the original changes which improve partial specializations; but fixes 32-bit linker behavior by effectively reverting afbd3e60f6 and e054d36dc8. We also add more comments so the next person has understands why things are done they way they are.
2018-08-24 08:13:23 -04:00
Jeffrey Walton
afbd3e60f6
Fix alignment on Win32 and Solaris Sparc (PR #709)
These fixes were interesting in a morbid sort of way. I thought the FixedSizeAllocatorWithCleanup specializations faithfully reproduced semantics but I was wrong on Win32 and Sparc. Also see Commit e054d36dc8.

It seems there was another requirement or dependency that we missed, but it was not readily apparent. If I am parsing results correctly (which I may not be), it appears the bit twiddling using 8 byte alignment had more influence on alignment than I originally thought based on use of CRYPTOPP_BOOL_ALIGN16 and T_Align16. Or maybe the alignment attributes specified by CRYPTOPP_ALIGN_DATA are not being honored like they should for stack allocations.

This check-in avoids some uses of x86 movdqa (aligned) in favor of movdqu (unaligned). The uses were concentrated on memory operands which were 8-byte aligned instead of 16-byte aligned. It is not clear to me how the specializations lost 8-bytes of alignment. The check-in also enlists CRYPTOPP_ASSERT to tell us when there's a problem so we don't need to go hunting for bugs.
2018-08-23 14:42:29 -04:00
Jeffrey Walton
4282f94712
Disable X32 inline assembly (GH #686, PR #704)
Also use CRYPTOPP_DISABLE_XXX_ASM consistently. The pattern is needed for Clang which still can't compile Intel assembly language. Also see http://llvm.org/bugs/show_bug.cgi?id=24232.
2018-08-18 04:44:53 -04:00
Jeffrey Walton
522da15b13
Whitespace check-in 2018-08-17 23:44:01 -04:00
Jeffrey Walton
8019362bd6
Clear unused variable warnings under MSVC 2018-08-03 06:17:22 -04:00
Jeffrey Walton
4aafb0e6a3
Cleanup SHA512::Transform code
The extra code paths added at GH #689 were no longer needed after GH #691
2018-07-21 10:28:48 -04:00
Jeffrey Walton
365e65c2eb
Whitespace check-in 2018-07-20 13:38:55 -04:00
Jeffrey Walton
ca302c952e
Fix Solaris 11/Sparc crash in SHA-384 (GH #689, GH #403)
I believe Andrew Marlow first reported it. At the time we could not get our hands on hardware to fully test things. Instead we were using -xmemalign=4i option as a band-aide to avoid running afoul of the Sparc instruction that moves 64-bits of data in one shot.
2018-07-20 13:24:04 -04:00
Jeffrey Walton
f143534d99
Cleanup defines in sha.cpp
There's no need for extra guards with CRYPTOPP_DISABLE_SHA_ASM because relevant macros are undefined
2018-07-15 12:47:34 -04:00
Jeffrey Walton
31533db421
Disable X32 for SHA (GH #686)
Thanks to Peter Cordes for the feedback
2018-07-15 11:39:41 -04:00
Jeffrey Walton
4e3a1ea962
Add ARMv8.4 cpu feature detection support (GH #685) (#687)
This PR adds ARMv8.4 cpu feature detection support. Previously we only needed ARMv8.1 and things were much easier. For example, ARMv8.1 `__ARM_FEATURE_CRYPTO` meant PMULL, AES, SHA-1 and SHA-256 were available. ARMv8.4 `__ARM_FEATURE_CRYPTO` means PMULL, AES, SHA-1, SHA-256, SHA-512, SHA-3, SM3 and SM4 are  available. 

We still use the same pattern as before. We make something available based on compiler version and/or preprocessor macros. But this time around we had to tighten things up a bit to ensure ARMv8.4 did not cross-pollinate down into ARMv8.1.

ARMv8.4 is largely untested at the moment. There is no hardware in the field and CI lacks QEMU with the relevant patches/support. We will probably have to revisit some of this stuff in the future.

Since this update applies to ARM gadgets we took the time to expand Android and iOS testing on Travis. Travis now tests more platforms, and includes Autotools and CMake builds, too.
2018-07-15 08:35:14 -04:00
Jeffrey Walton
28e20d6e5f
Fix "Error: symbol SHA512_Round is already defined" (GH #684) 2018-07-13 17:05:14 -04:00
Jeffrey Walton
b74a6f4445
Add algorithm provider member function to Algorithm class 2018-07-06 09:23:37 -04:00
Jeffrey Walton
e18de4d5f9
Re-engage SSE2 ASM for SHA-256 (GH# 674)
I'm not usre where exactly the break occured, but it was probably due to the BASE+SIMD rewrite. Thanks to tesbayda for tracking it down.
2018-06-29 21:02:53 -04:00
Jeffrey Walton
c4e0942a68
Add CRYPTOPP_TABLE, remove CRYPTOPP_SECTION 2018-01-21 14:19:00 -05:00
Jeffrey Walton
a074722bfa
Switch to rotlConstant and rotrConstant
This will help Clang and its need for a constexpr
2017-11-25 02:52:19 -05:00
Jeffrey Walton
ced7cff64f
Add Power8 SHA256 and SHA512 support (GH #513) 2017-09-22 09:39:36 -04:00
Jeffrey Walton
3bd01f73ba
Add Power8 SHA256 and SHA512 support (GH #513) 2017-09-22 08:58:50 -04:00
Jeffrey Walton
5296e087ad
Fix func/subfunc parameter names (GH #502) 2017-09-16 00:19:14 -04:00
Jeffrey Walton
7bdb62b336
Fix bad SHA152 hash under IBM XL C/C++ compiler (GH #502) 2017-09-15 18:33:05 -04:00
Jeffrey Walton
d2ad6751d5
Clear uninitialized variable warnings under xlC 2017-09-01 20:37:23 -04:00
Wyatt O'Day
ffbedcefc5 Fix build on FreeBSD 10.3 x86 with clang++ 3.4.1. (#483)
* Fix build on FreeBSD 10.3 x86 with clang++ v. 3.4.1. The x64 build (also clang++ 3.4.1) doesn't require CRYPTOPP_DISABLE_SHA_ASM. It seems to be a bug specific to the x86 version of clang++.

* Based on suggestion from @noloader, don't split x86/x64 clang++ version detection. Just wait until clang++ is consistently working in both x86/x64.
2017-08-30 16:42:36 -04:00
Jeffrey Walton
7851a0d510 Remove BOOL macro value (GH #462)
Currently the CRYPTOPP_BOOL_XXX macros set the macro value to 0 or 1. If we remove setting the 0 value (the #else part of the expression), then the self tests speed up by about 0.3 seconds. I can't explain it, but I have observed it repeatedly.
This check-in prepares for the removal in Upstream master
2017-08-20 21:25:29 -04:00
Jeffrey Walton
e2c377effd Split source files to support Base Implementation + SIMD implementation (GH #461)
Split source files to support Base Implementation + SIMD implementation
2017-08-17 12:33:43 -04:00
Jeffrey Walton
2ee8e3b26d
Move free standing function into anonymous namespace
Update comments and use class constants when available
2017-08-14 00:08:55 -04:00
Jeffrey Walton
2aff92ddb6
Fix bad SHA::Transform calculation (Issue 455)
Reworked SHA class internals to align all the implementations. Formerly all hashes were software based, IterHashBase handled endian conversions, IterHashBase repeatedly called the single block SHA{N}::Transform. The rework added SHA{N}::HashMultipleBlocks, and the SHA classes attempt to always use it.

Now SHA{N}::Transform calls into SHA{N}_HashMultipleBlocks, which is a free standing function. An added wrinkle is hardware wants little endian data and software presents big endian data, so HashMultipleBlocks accepts a ByteOrder for the incoming data. Hardware based SHA{N}_HashMultipleBlocks can often perform the endian swap much easier by setting an EPI mask so it was profitable to defer to hardware when available.

The rework also removed the hacked-in pointers to implementations. The class now looks more like AES, GCM, etc.
2017-08-13 16:05:39 -04:00
Jeffrey Walton
20def29d33
Use MOVDQU for SSE2 in static transform (Issue 455)
Updated documentation
2017-08-05 00:24:02 -04:00
Jeffrey Walton
de1270656c
Avoid extra ByteReverse when using Intel SHA extensions
This gains about 0.6 cpb. SHA-1 is down to 1.7 to 1.9 cpb. SHA-256 is not affected
2017-05-26 01:51:44 -04:00
Jeffrey Walton
bd7aa155a6 Revert "Avoid extra ByteReverse"
This reverts commit 3b56ba118f. It broke Tiger and SEAL. Arg...
2017-05-25 06:46:40 -04:00
Jeffrey Walton
3b56ba118f
Avoid extra ByteReverse
This gains about 0.6 cpb. SHA-1 is down to 1.9 cpb. SHA-256 is not affected
2017-05-25 06:20:00 -04:00
Anton Gorev
1df5fc1e21 Revert "Some fixes related to SunCC compiler bugs."
This reverts commit 72d8cbe917.
2017-04-27 13:50:47 -05:00
Jeffrey Walton
b9abd7141e
Fix endian-reversal and loading of MSG0-MSG3
Initially we performed a 32-bit word-size ByteReverse() on the entire 64-byte buffer being hashed. Then we performed another fix-up when loading each 16-byte portion of the buffer into the SSE2 registers for SHA processing. The [undesired] consequence was byte swapping and reversals happened twice. Worse, the call to ByteReverse() produced 16 bswaps instead of 1 call pshufb, so it was orders of magnitude slower than it needed to be.

This check-in takes the sane approach to byte reversals and swapping. It performs it once when the message is loaded for SSE processing. The result is SHA1 calculations drop from about 3.0 cpb to about 2.5 cpb.
2017-04-22 12:19:55 -04:00
Anton Gorev
72d8cbe917 Some fixes related to SunCC compiler bugs.
Fixes for "invalid address alignment" errors. See https://groups.google.com/d/topic/cryptopp-users/OYaByDEbSI0/discussion for details.
Changed config.h in accordance to Jeffrey Walton's request;
2017-04-21 15:26:16 -05:00
Jeffrey Walton
d9df0961e0
Fix SHA512_SSE2_Transform after whitespace checkin (Issue 365) 2017-01-17 00:49:10 -05:00
Jeffrey Walton
3a1a14c885
Update attribution of ARM SHA extensions
Also see d3bb0e13de (commitcomment-20482554)
2017-01-15 20:41:54 -05:00
Jeffrey Walton
c71803f383
Fix typo 2017-01-14 01:18:31 -05:00
Jeffrey Walton
69f812a7af
Add ARM SHA extensions for SHA-224 and SHA-256 2017-01-14 01:16:47 -05:00
Jeffrey Walton
d3bb0e13de
Add ARM SHA extensions for SHA1
Benchmarking on ARMv8/Aarch64 dev-board shows SHA-1 speeds up by 2.5x
2017-01-13 05:44:19 -05:00
Jeffrey Walton
fc306b6474
Whitespace checkin 2017-01-13 04:23:57 -05:00
Jeffrey Walton
f197549662
Remove temporary array for SHA1. Whitespace and comments 2016-12-06 11:09:31 -05:00
Jeffrey Walton
40230dd3bf
Removed MAINTAIN_BACKWARDS_COMPATIBILITY_562 (Issue 70) 2016-12-03 00:32:07 -05:00
Jeffrey Walton
3fff6251aa
Fix anachronism warning for *_HashBlocks functions under Win64 2016-12-02 00:41:13 -05:00
Jeffrey Walton
b896c13bcb
Fix missing __fastcall for *_HashBlocks functions under Win32 2016-12-02 00:25:58 -05:00
Jeffrey Walton
c8b910aff5
Backed-off automatically setting CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE due to bad interaction with '-march=x86-64'. Disgorge SSE2 implementation from CXX implementation 2016-12-01 23:35:13 -05:00
Jeffrey Walton
50f0c84ea0
Fix "X86_SHA256_HashBlocks was not declared in this scope" when using CRYPTOPP_DISABLE_ASM 2016-12-01 19:00:24 -05:00
Jeffrey Walton
cce56d3f79
Add Intel SHA1 extension support (Issue 139) 2016-12-01 15:05:41 -05:00