aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/mp
Commit message (Collapse)AuthorAgeFilesLines
* Add combined conditional add-or-subtractJack Lloyd2018-06-143-5/+41
|
* Remove CT annotations from Montgomery reductionJack Lloyd2018-06-141-8/+0
| | | | | The poisons don't stack so the unpoison hid conditional jumps we want to find.
* Make Karatsuba multiply completely const timeJack Lloyd2018-06-143-19/+45
|
* Unroll bigint_monty_redc for various sizesJack Lloyd2018-06-114-24/+2691
| | | | Speedup of 10 to 30% depending on algo
* Add message to BOTAN_ARG_CHECK and use it more widelyJack Lloyd2018-05-131-2/+1
|
* Add 24-word wide Comba multiply/squareJack Lloyd2018-05-083-1/+1101
| | | | | | Improves performance on "odd" sized DH/RSA (eg 1536, 3072, 6144) where otherwise the Karatsuba operation bottoms out with 24-word operands which ended up in the basecase multiply.
* Add vars to split the two Karatsuba sub-workspacesJack Lloyd2018-04-161-14/+20
|
* Simplify Karatsuba codeJack Lloyd2018-04-153-39/+43
| | | | And set us up for eventually having this be completely const time.
* Convert comba script to Python3Jack Lloyd2018-04-081-1/+1
|
* Split up asm constructs to avoid miscompilationJack Lloyd2018-04-051-30/+49
| | | | | | | The constraints were invalid as they missed the clobber of a/d registers. This caused miscompilation when using GCC -fno-plt option. GH #1524
* Fix some Doxygen errorsJack Lloyd2018-03-281-0/+1
|
* Add basecase_sqr functionJack Lloyd2018-03-161-3/+29
| | | | | | Just a simple adaption of the n^2 multiply algorithm, so no performance impact. However makes the difference between squaring and multiply easier to see when profiling.
* Improve memory handling for PointGFpJack Lloyd2018-03-142-1/+3
|
* Add some helper functions for checking for Comba sizesJack Lloyd2018-03-101-15/+27
|
* Simplify indexing in this loopJack Lloyd2018-03-041-5/+5
|
* Fix header includesJack Lloyd2018-03-022-2/+3
|
* Implement product-scanning Montgomery reductionJack Lloyd2018-03-022-30/+88
| | | | | Results in 10-20% improvement for DH and RSA, 5% for ECC curves that use Montgomery form.
* Tiny but useful optimization in bigint_monty_redcJack Lloyd2018-03-011-1/+1
| | | | Increases perf of larger DH by 5-8%
* Loosen restrictions on using bigint_comba_sqr9Jack Lloyd2018-03-011-1/+1
|
* Move declaration of word to types.hJack Lloyd2018-03-014-39/+6
|
* Remove MP_WORD_BITS constantJack Lloyd2018-03-012-17/+12
| | | | Use the BOTAN_MP_WORD_BITS consistently
* Remove BigInt using functions from mp layerJack Lloyd2018-03-014-57/+0
|
* Avoid ternary op during carry handlingJack Lloyd2018-03-011-1/+1
| | | | Makes it less likely compiler will use add-with-carry op
* Initialize z arrays within bigint_cnd_{sub,add}Jack Lloyd2018-03-011-6/+6
| | | | | | | | MSan requires compile time information about memory writes, so the inline asm writing to z is not seen. So OSS-Fuzz thinks the value is being used uninitialized. OSS-Fuzz 6626
* Unroll bigint_cnd_{add,sub}Jack Lloyd2018-02-281-8/+28
|
* Check z_size before doing Karatsuba mul/sqrJack Lloyd2018-02-251-2/+2
| | | | | | | Since the Karatsuba functions assume z_size >= 2*N The size chooser functions should handle this already by not returning a value that is too large, but good to be sure.
* Add a size check for basecase mulJack Lloyd2018-02-251-8/+11
|
* Pass workspace size to various bigint_ functionsJack Lloyd2018-02-253-23/+32
| | | | | | These functions made assumptions about the workspace size available, which if incorrect would cause memory corruption. Since the length is always available at the caller, just provide it and avoid problems.
* Improve speed of prime generation especially safe primesJack Lloyd2018-01-161-0/+4
| | | | | | | | | | | | | | | | First, correct a bug in the sieve code. It would break early if a value did not match up with the sieve. However in that case, the sieve values would be out of sync with the value of p, and would be returning effectively random results. This caused prime generation to be slower than it should be, both because the sieve was incorrectly rejecting values that were not multiples of any small prime and was allowing values that were multiples of small primes to move on to the Miller-Rabin test. In the sieve, also sieve so that 2*q+1 is also not a multiple of the small primes. This speeds up safe prime generation. GH #1411
* Forward declare BigInt in mp_core.hJack Lloyd2017-10-062-1/+3
| | | | Only needed in one source file here.
* Remove redundant parensJack Lloyd2017-10-031-1/+1
| | | | Sonar
* Use a side channel silent table look up in the Montgomery exponentiationJack Lloyd2017-09-253-33/+45
|
* Further build/test fixes for restricted configurationsJack Lloyd2017-09-241-0/+4
|
* Change header guard format to BOTAN_FOO_H_Jack Lloyd2017-09-204-8/+8
| | | | | | ISO C++ reserves names with double underscores in them Closes #512
* Use dword for bigint_divop if availableJack Lloyd2017-09-201-0/+5
| | | | | | Results in FPE being about 5x faster See #494
* Add API stability annotations.Jack Lloyd2017-09-191-4/+4
| | | | | Defined in build.h, all equal to BOTAN_DLL so ties into existing system for exporting symbols.
* Remove "Dirty hack" for multiple defines in lex_me_harder()Simon Warta2017-04-021-1/+3
|
* BOTAN_TARGET_COMPILER_IS -> BOTAN_BUILD_COMPILER_ISDaniel Neus2017-03-151-1/+1
|
* Remove nested anon namespaceJack Lloyd2016-12-231-4/+0
|
* Convert to using standard uintN_t integer typesJack Lloyd2016-12-185-12/+12
| | | | | | Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
* Fix exponentiation bug, related fixesJack Lloyd2016-12-141-19/+24
| | | | | | | | | | | | | | | GH #754 exposed a bug in the non-Montgomery exponentiation case. It turned out then when the fixed window was picked to any value > 1, the result would be incorrect due to an off by one. This is the one line fix in powm_fw.cpp Also fix a bug in bigint_mul which caused incorrect results, because the output BigInt was not being zeroed out before use. This is only exposed in rare cases, found (somewhat indirectly) in OSS-Fuzz #287. Add more modular exponentiation tests, which would have caught these issues earlier.
* Remove <source> block from info.txt filesJack Lloyd2016-12-081-7/+0
| | | | | | Kind of a vestigial thing from an earlier iteration of the module design, and never useful to specify anymore since taking all the cpp files is what you want exactly 100% of the time.
* Merge GH #567/GH #457 TLS refactoring and Callbacks interfaceJack Lloyd2016-08-313-53/+43
|\
| * Reduction of code complexity in MP & ECC classes.Matthias Gierlings2016-06-193-53/+43
| | | | | | | | | | | | - reduced number of parameters in various methods - introduced structures and renamed variables to improve code readability.
* | Merge asm into single mp_madd.h and mp_asmi.h filesJack Lloyd2016-07-2116-1545/+1084
|/ | | | | | | Avoids some cut and paste, also removes the need for special logic in configure.py for handling mp module specially. Merge SIMD classes into a single type SIMD_4x32
* For odd moduli use a input-independent modular inverse algorithm.Jack Lloyd2016-02-202-20/+20
| | | | Also adds a (not const time) implementation of almost Montgomery reduction.
* Add constant time conditional swap, add, sub for bigint wordsJack Lloyd2016-02-172-1/+102
| | | | | | | | | Not optimized and relies on asm support for const time word_add/word_sub instructions. Fix a bug introduced in 46e9a89 - unpoison needs to call the valgrind API with the pointer rather than the reference. Caused values not to be unpoisoned.
* Fix heap overflow in ECC point multiplicationJack Lloyd2016-02-011-0/+5
| | | | | | | | | | | | | | If affine coordinates larger than the prime modulus were given, a later multiplication could overflow the size of an allocated output buffer, which was sized based on the size of the prime. This will cause an overflow into either the system heap or if the mlock/mmap pool allocator is in use, then into the adjacent key material stored in the pool. Reported by Alex Gaynor who found it with AFL Also fix a one word overwrite in P-521 reduction. Found with AFL
* Prettify mp_comba a bitJack Lloyd2016-01-011-44/+44
| | | | | | Aligning the calls makes it easier to read the index travel Add a date to the generated output file
* Remove mp_mulop.cppJack Lloyd2015-12-256-93/+42
| | | | | | It had two functions, both only called from one place (mp_karat.cpp). Both multiple and square ops were O(n**2), so drop square and just call mul in mp_karat.cpp for either case