aboutsummaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Initialize System_Error::m_error_codeJack Lloyd2018-12-231-1/+2
| | | | Actual bug, flagged by Coverity
* Avoid double return of unique_ptrJack Lloyd2018-12-231-1/+3
| | | | Flagged by Coverity
* Add --no-store-vc-rev option for use in CI buildsJack Lloyd2018-12-231-0/+2
| | | | | | | This skips putting the git revision in the build.h header. This value changing every time means we effectively disable ccache's direct mode (which is faster than preprocessor mode) and also prevent any caching of the amalgamation file (since version.cpp expands the macro).
* Increase Travis ccache to 750MJack Lloyd2018-12-231-1/+1
| | | | Even 600M is not sufficient for the coverage build
* Rename OS::get_processor_timestamp to OS::get_cpu_cycle_counterJack Lloyd2018-12-235-14/+15
| | | | | Using phrase "timestamp" makes it sound like it has some relation to wall clock which it does not.
* Now Timer does not need to include an internal headerJack Lloyd2018-12-231-1/+0
|
* De-inline more of TimerJack Lloyd2018-12-232-41/+37
| | | | No reason for these to be inlined
* Make significant_words const time alsoJack Lloyd2018-12-234-40/+75
| | | | | | Only used in one place, where const time doesn't matter, but can't hurt. Remove low_bit, can be replaced by ctz.
* In Timer, grab CPU clock firstJack Lloyd2018-12-231-9/+9
| | | | | | Reading the system timestamp first causes every event to get a few hundred cycles tacked onto it. Only mattered when the thing being tested was very fast.
* Increase Travis ccache againJack Lloyd2018-12-231-1/+1
| | | | Still insufficient for debug builds
* Remove now incorrect commentJack Lloyd2018-12-221-5/+0
|
* Make high_bit and ctz actually const timeJack Lloyd2018-12-221-3/+3
|
* Promote ct_is_zero and expand_top_bit to bit_ops.hJack Lloyd2018-12-222-10/+21
|
* Make ctz and high_bit faster and const-time-ishJack Lloyd2018-12-223-48/+51
| | | | | | | They get compiled as const-time on x86-64 with GCC but I don't think this can be totally relied on. But it is anyway an improvement. And, faster, because we compute it recursively
* Increase Travis cache size [ci skip]Jack Lloyd2018-12-221-2/+2
| | | | | With compression disabled, the cache is too small for builds that use debug info, and causes 100% miss rate.
* Fix build with PGI [ci skip]Jack Lloyd2018-12-221-5/+7
| | | | I couldn't get anything to link with PGI, but at least it builds again.
* Merge GH #1794 Improve const time logic in PKCS1v15 and OAEP decodingJack Lloyd2018-12-219-92/+171
|\
| * Use consistent logic for OAEP and PKCS1v15 decodingJack Lloyd2018-12-219-92/+171
| | | | | | | | | | | | | | | | | | | | | | | | The decoding leaked some information about the delimiter index due to copying only exactly input_len - delim_idx bytes. I can't articulate a specific attack that would work here, but it is easy enough to fix this to run in const time instead, where all bytes are accessed regardless of the length of the padding. CT::copy_out is O(n^2) and thus terrible, but in practice it is only used with RSA decryption, and multiplication is also O(n^2) with the modulus size, so a few extra cycles here doesn't matter much.
* | Avoid including rotate.h in bswap.hJack Lloyd2018-12-2128-2/+30
| | | | | | | | | | | | | | It was only needed for one case which is easily hardcoded. Include rotate.h in all the source files that actually use rotr/rotl but implicitly picked it up via loadstor.h -> bswap.h -> rotate.h include chain.
* | Stop compressing Travis ccacheJack Lloyd2018-12-211-3/+1
|/ | | | Since CPU is main bottleneck to the build, this is likely not helping.
* Address a couple of Coverity false positivesJack Lloyd2018-12-194-7/+62
| | | | Add tests for is_power_of_2
* Avoid using unblinded Montgomery ladder during ECC key generationJack Lloyd2018-12-182-11/+32
| | | | | | | | | | | As doing so means that information about the high bits of the scalar can leak via timing since the loop bound depends on the length of the scalar. An attacker who has such information can perform a more efficient brute force attack (using Pollard's rho) than would be possible otherwise. Found by Ján Jančár (@J08nY) using ECTester (https://github.com/crocs-muni/ECTester) CVE-2018-20187
* Test how long it takes to precompute base point multiplesJack Lloyd2018-12-162-1/+21
|
* In PointGFp addition, prevent all_zeros from being shortcircuitedJack Lloyd2018-12-141-4/+7
| | | | | | This doesn't matter much but it causes confusing valgrind output when const-time checking since it distinguishes between the two possible conditional returns.
* Unroll const_time_lookup by 2Jack Lloyd2018-12-141-6/+10
| | | | | We know the lookup table is some power of 2, unrolling a bit allows more IPC
* Simplify the const time lookup in ECC scalar mulJack Lloyd2018-12-141-12/+9
| | | | | Code is easier to understand and it may let the CPU interleave the loads and logical ops better. Slightly faster on my machine.
* Use a 3-bit comb for ECC base point multiplyJack Lloyd2018-12-132-19/+36
| | | | Improves ECDSA signing by 15%
* Some cleanups in x25519Jack Lloyd2018-12-101-53/+43
|
* Fix more MSVC warningsJack Lloyd2018-12-104-8/+9
|
* Merge GH #1769 Support TLS signature padding strings in PKCS11 mappingJack Lloyd2018-12-101-0/+10
|\
| * Remove EMSA1 encodings from p11 sign mechanisms mapHannes Rantzsch2018-12-101-5/+0
| |
| * Extend the SignMechanisms map for Signature_Scheme padding stringsHannes Rantzsch2018-12-041-0/+15
| | | | | | | | | | | | This addresses #730. The tls_sign_message callback was unable to handle emsa strings produced as padding strings for TLS::Signature_Scheme, due to inconsistent naming (mostly between EMSA3 and EMSA_PKCS1).
* | Fix some MSVC warningsJack Lloyd2018-12-1012-26/+35
| |
* | Work around a problem when built with OpenSSLJack Lloyd2018-12-103-7/+10
| | | | | | | | | | | | | | It appears OpenSSL has a different interpretation from us of how the message representative is formed for P-521 when given a hash to sign that is larger than the group order; signatures generated by us do not verify with OpenSSL and vice versa.
* | Support recovering ECDSA public key from message/signature pairJack Lloyd2018-12-106-2/+232
| | | | | | | | | | | | See http://www.secg.org/sec1-v2.pdf section 4.1.6 Closes #664
* | Fix pylint3 warning [ci skip]Jack Lloyd2018-12-101-1/+1
| |
* | Make ASan happyJack Lloyd2018-12-091-1/+1
| |
* | Add base58 encoding/decodingJack Lloyd2018-12-096-0/+454
| |
* | Merge GH #1782 Add an i386 build/test to CIJack Lloyd2018-12-093-4/+14
|\ \
| * | Add an i386 CI target to check on 32-bit asmJack Lloyd2018-12-093-4/+14
| | |
* | | Remove Chi-square test on random_integerJack Lloyd2018-12-091-46/+0
|/ / | | | | | | | | I'm not sure this test is that useful, which is not itself a big problem, but it is also flaky and occasionally fails, which is no good.
* | Merge GH #1780 Use constant time algorithm for monty_inverseJack Lloyd2018-12-092-39/+23
|\ \
| * | Use a const time algorithm for monty_inverseJack Lloyd2018-12-092-39/+23
| | | | | | | | | | | | | | | Previous EEA leaked information about the low word of the prime, which is a problem for RSA.
* | | Fix typoJack Lloyd2018-12-091-1/+1
| | |
* | | Avoid doing a variable time division during Montgomery setupJack Lloyd2018-12-095-14/+25
|/ / | | | | | | | | | | Instead require the inputs be reduced already. For RSA-CRT use Barrett which is const time already. For SRP6 inputs were not reduced, use the Barrett hook available in DL_Group.
* | Move Miller-Rabin t param inside the blockJack Lloyd2018-12-091-2/+2
| | | | | | | | This var is not used if we use Baile-PSW instead
* | Few features added for BSD.David Carlier2018-12-093-1/+6
| | | | | | | | | | explicit_bzero/explicit_memset since quite a time. getentropy exists for FreeBSD, but only from 12.x.
* | Avoid repeated size checks when setting words in NIST reductionJack Lloyd2018-12-081-25/+33
| | | | | | | | This is a tiny thing but it saves over 100K cycles for P-384 ECDSA
* | Merge GH #1776 Clean ups in MDx_HashFunctionJack Lloyd2018-12-082-33/+49
|\ \
| * | Require MDx_HashFunction block size to be a power of 2Jack Lloyd2018-12-082-14/+25
| | | | | | | | | | | | | | | | | | Allows replacing div/mod by a variable with a shift/mask. Allows storing just the bit count, which saves a few bytes.