aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
Commit message (Collapse)AuthorAgeFilesLines
* Further optimizations, and split out GHASH reduction codeJack Lloyd2017-10-183-87/+57
|
* GCM and CTR optimizationsJack Lloyd2017-10-1811-372/+624
| | | | | | | | | | | In CTR, special case for counter widths of special interest. In GHASH, uses a 4x reduction technique suggested by Intel. Split out GHASH to its own source file and header. With these changes GCM is over twice as fast on Skylake and about 50% faster on Westmere.
* Correct usage of std::aligned_storageJack Lloyd2017-10-151-6/+6
| | | | This ended up allocating 256 KiB!
* Additional final annotationsJack Lloyd2017-10-1519-27/+26
|
* GMAC optimizationJack Lloyd2017-10-152-21/+32
| | | | | Avoid copying inputs needlessly, on Skylake doubles performance (from 1 GB/s -> 2 GB/s)
* Merge GH #1257 Use std::aligned_storage for AES T-tableJack Lloyd2017-10-151-32/+56
|\
| * Use overaligned storage for AES T-TableJack Lloyd2017-10-141-32/+56
| | | | | | | | | | This improves performance by ~ .5 cycle/byte. Also it ensures that our cache reading countermeasure works as expected.
* | Merge GH #1255 Use a single T-table in AESJack Lloyd2017-10-151-127/+78
|\|
| * Reduce AES to using a single T-tableJack Lloyd2017-10-131-127/+78
| | | | | | | | | | | | | | | | | | Should have significantly better cache characteristics, though it would be nice to verify this. It reduces performance somewhat but less than I expected, at least on Skylake. I need to check this across more platforms to make sure t won't hurt too badly.
* | De-inline bodies of exception classesJack Lloyd2017-10-153-67/+133
|/ | | | | | | | | This leads to a rather shocking decrease in binary sizes, especially the static library (~1.5 MB reduction). Saves 60KB in the shared lib. Since throwing or catching an exception is relatively expensive these not being inlined is not a problem in that sense. It had simply not occured to me that it would take up so much extra space in the binary.
* Optimizations for SM4Jack Lloyd2017-10-131-35/+94
| | | | | | | | | Using a larger table helps quite a bit. Using 4 tables (ala AES T-tables) didn't seem to help much at all, it's only slightly faster than a single table with rotations. Continue to use the 8 bit table in the first and last rounds as a countermeasure against cache attacks.
* Accept SHA-1, SHA1, or SHA-160 equallyJack Lloyd2017-10-133-3/+3
| | | | | | Fixes #1235 [ci skip]
* Further GCM optimizationsJack Lloyd2017-10-131-17/+27
| | | | Went from 27 to 20 cycles per byte on Skylake (with clmul disabled)
* Merge GH #1253 GCM optimizationsJack Lloyd2017-10-138-174/+242
|\
| * Optimize GCMJack Lloyd2017-10-138-174/+242
| | | | | | | | | | | | | | | | | | | | By allowing multiple blocks for clmul, slight speedup there though still far behind optimum. Precompute a table of multiples of H, 3-4x faster on systems without clmul (and still no secret indexes). Refactor GMAC to not derive from GHASH
* | Merge GH #1254 Add missing includeJack Lloyd2017-10-131-0/+1
|\ \
| * | Add limits.h header for INT_MAXAlon Bar-Lev2017-10-131-0/+1
| |/ | | | | | | | | Gentoo-Bug: https://bugs.gentoo.org/633468 Signed-off-by: Alon Bar-Lev <[email protected]>
* / Use memcpy trick in 3-arg xor_buf alsoJack Lloyd2017-10-131-23/+17
|/
* OCB optimizationsJack Lloyd2017-10-132-58/+90
| | | | | | With fast AES-NI, gets down to about 2 cycles per byte which is pretty good compared to the ~5.5 cpb of 2.3, still a long way off the best stiched impls which run at ~0.6 cpb.
* Somewhat faster xor_bufJack Lloyd2017-10-121-18/+15
| | | | Avoids the cast alignment problems of yesteryear
* Remove needless mutableJack Lloyd2017-10-121-2/+2
| | | | [ci skip]
* Swapped encrypt and decrypt in BlockCipher _xex functionsJack Lloyd2017-10-121-2/+2
| | | | | Missed by everything but the OCB wide tests because most ciphers have fixed width and get the override.
* Interleave SM3 message expansionJack Lloyd2017-10-121-141/+142
| | | | Reduces stack usage and a bit faster
* Use SIMD for in ThreefishJack Lloyd2017-10-121-2/+2
| | | | GCC 7 can actually vectorize this for AVX2
* OCB optimizationsJack Lloyd2017-10-127-124/+163
| | | | From ~5 cbp to ~2.5 cbp on Skylake
* Merge GH #1247 Improve bit rotation functionsJack Lloyd2017-10-1235-644/+724
|\
| * Ugh, the GCC/Clang trick triggers C4146 under MSVCJack Lloyd2017-10-121-8/+25
| | | | | | | | | | | | And rotate.h is a visible header. Blerg. Inline asm it is.
| * Add compile-time rotation functionsJack Lloyd2017-10-1235-660/+701
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem with asm rol/ror is the compiler can't schedule effectively. But we only need asm in the case when the rotation is variable, so distinguish the two cases. If a compile time constant, then static_assert that the rotation is in the correct range and do the straightforward expression knowing the compiler will probably do the right thing. Otherwise do a tricky expression that both GCC and Clang happen to have recognize. Avoid the reduction case; instead require that the rotation be in range (this reverts 2b37c13dcf). Remove the asm rotations (making this branch illnamed), because now both Clang and GCC will create a roll without any extra help. Remove the reduction/mask by the word size for the variable case. The compiler can't optimize that it out well, but it's easy to ensure it is valid in the callers, especially now that the variable input cases are easy to grep for.
| * Use rol/ror x86 instructions on GCC/ClangJack Lloyd2017-10-111-2/+24
| | | | | | | | | | | | | | Neither is very good at recognizing rotate sequences. For cases where the rotation value is a constant they do fine, but for variable rotations they do horribly. Using inline asm here improved performance of both CAST-128 and CAST-256 by ~20% on my system with both GCC and Clang.
* | Avoid std::count to skip a signed overflow warningJack Lloyd2017-10-122-3/+13
| | | | | | | | | | | | Couldn't figure out a way to silence this otherwise. Deprecate replace_char, erase_chars, replace_chars
* | Merge GH #1245 Restructure Barrier/Semaphore to avoid signed overflow warningsJack Lloyd2017-10-122-11/+9
|\ \ | |/ |/|
| * #1220 - fixed fixes of integer overflowHubert Bugaj2017-10-102-7/+3
| |
| * #1220 - fixed signed overflow warningsHubert Bugaj2017-10-092-10/+12
| |
* | Merge GH #1248 Unroll SM3 compression loopJack Lloyd2017-10-111-56/+94
|\ \
| * | Unroll SM3 compression functionJack Lloyd2017-10-101-56/+94
| | |
* | | Helpful commentJack Lloyd2017-10-111-1/+2
| | |
* | | Remove SSE2 bswap_4Jack Lloyd2017-10-111-24/+0
| | | | | | | | | | | | | | | It was disabled anyway (bad macro check) and with recent GCC turned out to be slower than just using bswap.
* | | Optimize CFB modeJack Lloyd2017-10-112-39/+97
| | | | | | | | | | | | Still slower but notably faster at least with AES-NI
* | | Add missing headerJack Lloyd2017-10-111-0/+1
| | | | | | | | | | | | Error under filesystem-free builds
* | | Simplify ffi call overheadJack Lloyd2017-10-115-45/+22
| | | | | | | | | | | | Notable reductions in code size, stack size and function call overhead.
* | | getenv is in standard C++Jack Lloyd2017-10-091-1/+1
| | |
* | | Include cstdlib to make os_utils compile with clang.Alexander Bluhm2017-10-091-0/+2
| |/ |/|
* | Add comments explaining why its ok to rely on deprecated features here.Jack Lloyd2017-10-092-0/+8
| | | | | | | | [ci skip]
* | Add a special Compat_Callbacks constructor to silence deprecation warnings.Jack Lloyd2017-10-093-7/+24
| | | | | | | | | | | | That way we avoid the warning internally even in amalgamation mode. GH #1243
* | Forward declare BigInt in mp_core.hJack Lloyd2017-10-062-1/+3
| | | | | | | | Only needed in one source file here.
* | Remove needless variableJack Lloyd2017-10-061-2/+0
| |
* | Address some bool/int conversion warnings from SonarJack Lloyd2017-10-064-5/+12
| | | | | | | | Nothing major but probably good to clean these up.
* | Address various GCC warningsJack Lloyd2017-10-068-24/+26
| | | | | | | | | | Things like -Wconversion and -Wuseless-cast that are noisy and not on by default.
* | Correct the SHA-3 PKCSv1.5 IDsJack Lloyd2017-10-052-5/+13
| | | | | | | | | | | | | | Thanks to @noloader for pointing me at draft-jivsov-openpgp-sha3-01 which has the correct values. Adds a test so this can't happen again.
* | Mark some functions of MDx_HashFunction finalJack Lloyd2017-10-051-3/+3
| | | | | | | | | | The class itself can't be final but we can final the overrides from HashFunction, which helps the compiler devirtualize.