Commit Graph

206 Commits

Author SHA1 Message Date
Jeffrey Walton
652d0e42bf
Use __IBM_ATTRIBUTES and __IBM_ALIGNOF__ from IBM compiler manual 2018-11-22 19:18:08 -05:00
Jeffrey Walton
c601213ce1
Sync CRYPTOPP_{BIG|LITTLE}_ENDIAN with Autotools
Autotools sets up its config.h file with the '#define XXX 0' or '#define XXX 1' pattern. This check-in makes the sources Autotools aware. We need to verify CMake does the same
2018-10-28 04:24:22 -04:00
Jeffrey Walton
e185cbd803 Revert "Sync CRYPTOPP_{BIG|LITTLE}_ENDIAN with Autotools"
This reverts commit 04306f86ac. It broke GCC 4.8 on PowerPC.
2018-10-28 03:42:50 -04:00
Jeffrey Walton
04306f86ac
Sync CRYPTOPP_{BIG|LITTLE}_ENDIAN with Autotools 2018-10-27 07:30:15 -04:00
Jeffrey Walton
3063c6e1d9
Whitespace check-in 2018-10-20 06:11:46 -04:00
Jeffrey Walton
180b39facc
Disable SecureWipe specializations when CRYPTOPP_DISABLE_ASM (GH #719) 2018-10-20 05:54:49 -04:00
Jeffrey Walton
4fb9fbf5ac
Update comments 2018-08-24 12:19:42 -04:00
Jeffrey Walton
beed647df2
Update assert 2018-08-24 09:25:19 -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
d4f86d7320
Add SunCC code path to GetAlignmentOf
It looks like GetAlignmentOf was returning the "UnsignedMin(4U, sizeof(T))" for SunCC. It was causing SIGBUSes on Sparc when T=word64. OpenCSW provided access to their build farm and we were able to test "__alignof__(T)" back to an early SunCC on Solaris 9.
2018-07-21 06:29:20 -04:00
Jeffrey Walton
414c5c5438
Fix Tiger crash on Sparc (GH #690)
Man, Sparc does not mess around with unaligned buffers. Without -xmemalign=4i the hardware wants 8-byte aligned word64's so it can use the high performance 64-bit move or add.
Since we do not use -xmemalign we get the default behavior of either -xmemalgin=8i or -xmemalgin=8s. It shoul dnot matter to us since we removed unaligned data access at GH #682.
2018-07-20 20:12:54 -04:00
Jeffrey Walton
25179e00d3
Fix PtrByteDiff cast
A quick testing pass that loaded the code with asserts caused a compile failure
2018-07-12 09:37:43 -04:00
Jeffrey Walton
b3fe24b8b5
Remove CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS support (GH #682)
We were able to gut CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS for everything except Rijndael. Rijndael uses unaligned accesses on x86 to harden against timing attacks.
There's a little more to CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS and Rijndael. If we remove unaligned access then AliasedWithTable hangs in an endless loop on non-AESNI machines. So care must be taken when trying to remove the vestige from Rijndael.
2018-07-11 11:40:25 -04:00
Jeffrey Walton
722d3e38c1
Avoid cast in PtrDiff
ptrdiff_t is the return type
2018-07-10 11:55:50 -04:00
Jeffrey Walton
50f99ae802
Increase use of ptrdiff_t when performing pointer math 2018-07-10 09:21:52 -04:00
Jeffrey Walton
c6c44aa5d1
Add PtrAdd and PtrSub helper functions
This helps contain UB on pointer subtraction by ensuring a ptrdiff_t is used. The code is a little uglier but it is also more portable.
2018-07-10 05:00:02 -04:00
Marcel Raad
7c1d296283 Fix clang warnings in headers (#655)
* remove superfluous semicolon

* Remove C-style casts from public headers

clang warns about them with -Wold-style-cast. It also warns about
implicitly casting away const with -Wcast-qual. Fix both by removing
unnecessary casts and converting the remaining ones to C++ casts.
2018-05-10 19:59:21 -04:00
Ilja
c2e4ee60b3 Remove extra ;s (GH #605) 2018-03-26 11:36:54 -04:00
Jeffrey Walton
63d038fa18
Update documentation
The commit also adds an assert on memcpy_s pointers. GCC 8 claims the pointers are the same. We think it is a spurious finding. The assert never fired during test.
2018-02-22 08:01:08 -05:00
Jeffrey Walton
2816efe188
Clear GCC -Wstrict-overflow warning
This is a false positive when "T=int" or "T=long". "value" is reduced by division so it converges to 0. It is never less than 0.
2018-01-20 19:37:58 -05:00
Jeffrey Walton
befd04312d
Remove unneeded Doxygen directive 2018-01-19 14:31:20 -05:00
Jeffrey Walton
aa7f6c47d1
Update documentation 2018-01-13 07:14:21 -05:00
Jeffrey Walton
a9d6604ee9
Update documentation 2018-01-12 09:04:12 -05:00
Jeffrey Walton
751252b2d9
Update documentation 2018-01-12 08:54:07 -05:00
Kirit Sælensminde
59b94d2bbf C++17 compatible lambda expressions to replace bind2nd (#559)
* Conditionally use a lambda rather than the older `bind2nd` style.

* Duplicate the if statements.

* Centralise the conditional compilation to an implementation of find_if_not.

* Refactoring of name and code placement after review.

* Use `FindIfNot` where appropriate.

* Remove whitespace.
2018-01-12 08:38:56 -05:00
Jeffrey Walton
195ac2c7c9
Refactor rijndael-simd.cpp and simon.simd.cpp to use adv-simd.h 2017-12-10 11:09:50 -05:00
Jeffrey Walton
61ec50dabe
Change Doxygen comment style from //! to ///
Also see https://groups.google.com/forum/#!topic/cryptopp-users/A7-Xt5Knlzw
2017-11-29 10:54:33 -05:00
Jeffrey Walton
dcd27e8a1f
Update documentation 2017-11-24 18:58:31 -05:00
Jeffrey Walton
3b80ead695
Add rotlConstant and rotrConstant
The template functions take the rotate amount as a template parameter, which will allow the constexpr to propagate into the rotate expression. It should avoid some of the compile problems we were seeing under Clang and C++11
2017-11-24 17:37:55 -05:00
Jeffrey Walton
69c8a4f9c6
Prefix IS_LITTLE_ENDIAN and IS_BIG_ENDIAN with CRYPTOPP 2017-11-10 14:15:30 -05:00
Jeffrey Walton
24a19b7a18
Cleanup use of BMI intrinsics under GCC and compatibles 2017-10-09 21:14:21 -04:00
Jeffrey Walton
69fd4a040d
Update documentation 2017-09-27 06:24:58 -04:00
Jeffrey Walton
3525fd48da
Remove MOVBE intrinsics
GCC never defines __MOVBE__
2017-09-01 20:38:32 -04:00
Jeffrey Walton
1267c75369
Fix constexpr issues under GCC 4.1.2 found on CentOS 5 2017-08-17 18:35:06 -04:00
Jeffrey Walton
2c9a3039e8
Update documentation
This cleanup was performed using Clang and -Wdocumentation -Wno-documentation-deprecated-sync
2017-07-27 19:15:21 -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
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
006ca5f860
Updated documentation 2017-03-11 01:42:06 -05:00
Jeffrey Walton
5efb019d8b
Add C++ nullptr support (Issue 383) 2017-03-01 06:10:06 -05:00
Jeffrey Walton
26e2e12b6a
Fix typo 2017-02-16 20:57:31 -05:00
Jeffrey Walton
5bbdcaf243
Fix compile under MFC project 2017-02-16 20:55:02 -05:00
Jeffrey Walton
81b1a18063
Change file preamble to include "originally written by Wei Dai"
We have made a fair number of changes, and we don't want WD to receive credit for issues he was not part of
2017-01-27 07:05:45 -05:00
Jeffrey Walton
d4c247a1fd
Add MOVBE support
MOVBE is a modest gain over BSWAP. Though its guarded by CRYPTOPP_MOVBE_AVAILABLE, we cannot detect availability with a preprocessor macro. That is, GCC does not provide __MOVBE__ or similar. It has to be enabled manually
2017-01-24 04:26:00 -05:00
Jeffrey Walton
1d391c190d
Make NumericLimitsMin and NumericLimitsMax available to MSVC (Issue 364) 2017-01-15 19:36:36 -05:00
Jeffrey Walton
b274f06202
Fix RoundUpToMultipleOf for Apple Clang 6.0 (Issue 364)
Also see Issue 360 and http://stackoverflow.com/q/41666815
2017-01-15 19:14:42 -05:00
Jeffrey Walton
781e63ba7c
Fix RoundUpToMultipleOf (Issue 360)
Thanks to Boldizsár Lipka
2017-01-10 22:05:53 -05:00
klemens
5a5c633073 spelling fixes 2016-12-27 18:34:57 +01:00
Jeffrey Walton
a274a64058
Fix compile under Visual Studio .Net (Issue 342) 2016-12-03 18:44:48 -05:00
Jeffrey Walton
ba75834ae9
Removed VC++ 5.0 and 6.0 workarounds (Issue 342) 2016-12-03 05:05:56 -05:00