summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/arch (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Mark the inputs to bn_mul_comba{4,8}() as const.jsing6 days1-3/+3
| | | | | | | This makes it consistent with bn_sqr_comba{4,8}() and simplifies an upcoming change. ok tb@
* Provide an optimised bn_subw() for amd64.jsing2024-03-261-3/+22
| | | | bn_subw() will be used more widely in an upcoming change.
* Replace uses of endbr64 with _CET_ENDBR from cet.htb2024-02-2411-11/+11
| | | | | | | | | cet.h is needed for other platforms to emit the relevant .gnu.properties sections that are necessary for them to enable IBT. It also avoids issues with older toolchains on macOS that explode on encountering endbr64. based on a diff by kettenis ok beck kettenis
* Mark read/write registers as non-overlapping for bn_qwmulw_{addqw_,}addw()jsing2023-07-241-3/+3
| | | | | | This does not cause an issue currently, however if called differently to their current usage, it can lead to an input being overwritten and incorrect results being generated.
* Provide optimised bn_subw() for riscv64.jsing2023-07-091-1/+18
|
* Provide optimised bn_addw() for riscv64.jsing2023-07-091-1/+18
|
* Provide optimised bn_mulw() for riscv64.jsing2023-07-071-7/+11
| | | | | This provides a 1.5-2x performance gain for BN multiplication, with a similar improvement being seen for RSA operations.
* Rewrite and simplify bn_sqr()/bn_sqr_normal().jsing2023-06-241-3/+3
| | | | | | | | | Rework bn_sqr()/bn_sqr_normal() so that it is less convoluted and more readable. Instead of recomputing values that the caller has already computed, pass it as an argument. Avoid branching and remove duplication of variables. Consistently use a_len and r_len naming for lengths. ok tb@
* Provide optimised bn_subw() and bn_subw_subw() for arm.jsing2023-06-241-1/+50
|
* Provide optimised bn_clzw() for aarch64.jsing2023-06-211-1/+15
|
* Optimise bn_mul2_mulw_addtw() for aarch64.jsing2023-06-171-1/+28
| | | | | This provides significant performance gains for bn_sqr_comba4() and bn_sqr_comba8().
* Optimise quad word primitives on aarch64.jsing2023-06-121-1/+136
| | | | This provides a performance gain across most BN operations.
* Provide optimised bn_mulw_{addw,addw_addw,addtw}() for aarch64.jsing2023-05-281-1/+68
| | | | | This results in bn_mul_comba4() and bn_mul_comba8() requiring ~30% less instructions than they did previously.
* Provide optimised bn_addw_addw()/bn_subw_subw() for aarch64.jsing2023-05-281-1/+43
|
* Add endbr64 where needed by inspection. Passes regresson tests.deraadt2023-04-2511-0/+11
| | | | ok jsing, and kind of tb an earlier version
* Tweak indent and use named registers.jsing2023-04-171-13/+13
| | | | No functional change.
* Use separate lines instead of semicolons.bcook2023-02-251-4/+10
| | | | | | macOS aarch64 assembly dialect treats ; as comment instead of a newline ok tb@, jsing@
* Rework bn_add()/bn_sub() to operate on word arrays.jsing2023-02-221-7/+10
| | | | | | | | Rather than working on BIGNUMs, change bn_add()/bn_sub() to operate on word arrays that potentially differ in length. This matches the behaviour of s2n-bignum's bignum_add() and bignum_sub(). ok tb@
* Provide optimised versions of bn_addw() and bn_subw() for aarch64.jsing2023-02-171-1/+35
|
* Enable s2n-bignum word_clz() on amd64.jsing2023-02-162-2/+12
| | | | | | | | | The BN_num_bits_word() function is a hot path, being called more than 80 million times during a libcrypto regress run. The word_clz() implementation uses five instructions to do the same as the generic code that uses more than 60 instructions. Discussed with tb@
* Change include from _internal_s2n_bignum.h to s2n_bignum_internal.h.jsing2023-02-161-1/+1
|
* Include the ISC license from s2n-bignum's LICENSE file.jsing2023-02-161-1/+12
|
* Bring in word_clz.S from s2n-bignum for amd64.jsing2023-02-161-0/+48
|
* Rename bn_umul_hilo() to bn_mulw().jsing2023-02-166-42/+42
| | | | | | | | | This keeps the naming consistent with the other bignum primitives that have been recently introduced. Also, use 1/0 intead of h/l (e.g. a1 instead of ah), as this keeps consistency with other primitives and allows for naming that works with double word, triple word and quadruple word inputs/outputs. Discussed with tb@
* Remove bn_sqr_words() on amd64.jsing2023-02-042-11/+2
| | | | | | | s2n-bignum's bignum_sqr() is not the same as bn_sqr_words() (which only computes a partial result, unlike the former). This went unnoticed since bn_sqr() is called directly on amd64, hence bn_sqr_words() is currently unused.
* Fix output constraints for bn_umul_hilo().jsing2023-02-044-8/+8
| | | | | | | | When bn_umul_hilo() is implemented using an instruction pair, mark the first output with a constraint that prevents the output from overlapping with the inputs ("&"). Otherwise the first instruction can overwrite the inputs, which then results in the second instruction producing incorrect value.
* Refactor BN_uadd() and BN_usub().jsing2023-02-022-2/+22
| | | | | | | | | | | | | | | | | | Unlike bn_add_words()/bn_sub_words(), the s2n-bignum bignum_add() and bignum_sub() functions correctly handle inputs with differing word lengths. This means that they can be called directly, without needing to fix up any remaining words manually. Split BN_uadd() in two - the default bn_add() implementation calls bn_add_words(), before handling the carry for any remaining words. Likewise split BN_usub() in two - the default bn_sub() implementation calls bn_sub_words(), before handling the borrow for any remaining words. On amd64, provide an implementation of bn_add() that calls s2n-bignum's bignum_add() directly, similarly with an implementation of bn_sub() that calls s2n-bignum's bignum_sub() directly. ok tb@
* Provide inline assembly bn_umul_hilo() for alpha/powerpc64/riscv64.jsing2023-01-313-3/+67
| | | | | | These should work, but are currently untested and disabled. ok tb@
* Provide inline assembly versions of bn_umul_hilo() for aarch64/amd64/i386.jsing2023-01-313-3/+67
| | | | ok tb@
* Remove sparc related files from libcrypto.jsing2023-01-311-39/+0
| | | | | | | | The sparc platform got retired a while back, however some parts remained hiding in libcrypto. Mop these up (along with the bn_arch.h that I introduced). Spotted by and ok tb@
* Use s2n-bignum assembly implementations for libcrypto bignum on amd64.jsing2023-01-291-1/+79
| | | | | | | This switches the core bignum assembly implementations from x86_64-gcc.c to s2n-bignum for amd64. ok miod@ tb@
* Provide bn_div_rem_words() and make use of it.jsing2023-01-282-2/+52
| | | | | | | | | | | | | | | | Provide a function that divides a double word (h:l) by d, returning the quotient q and the remainder r, such that q * d + r is equal to the numerator. Call this from the three places that currently implement this themselves. This is implemented with some slight indirection, which allows for per architecture implementations, replacing the define/macro tangle, which messes with variables that are not passed to it. Also remove a duplicate of bn_div_words() for the BN_ULLONG && BN_DIV2W case - this is already handled. ok tb@
* Change include from _internal_s2n_bignum.h to s2n_bignum_internal.h.jsing2023-01-239-9/+9
|
* Include the ISC license from s2n-bignum's LICENSE file.jsing2023-01-239-9/+108
|
* Bring in various s2n-bignum functions for amd64.jsing2023-01-239-0/+1458
| | | | | | | | This brings in bignum_add(), bignum_cmadd(), bignum_cmul(), bignum_mul() and bignum_sub(), along with bignum_{mul,sqr}_4_8_alt() and bignum_{mul,sqr}_8_16_alt(). Discussed with tb@
* Move bn_mul_add_words() and bn_mul_words() from bn_asm.c to bn_mul.c.jsing2023-01-235-5/+15
| | | | | | These are wrapped with #ifndef HAVE_BN_ADD_MUL_WORDS/HAVE_BN_MUL_WORDS, which are defined for architectures that provide their own assembly versions.
* Move bn_sqr_words from bn_asm.c to bn_sqr.c.jsing2023-01-235-5/+10
| | | | | This is wrapped with #ifndef HAVE_BN_SQR_WORDS, which is then defined for architectures that provide their own assembly versions.
* Move bn_div_words from bn_asm.c to bn_div.c.jsing2023-01-235-5/+14
| | | | | This is wrapped with #ifndef HAVE_BN_DIV_WORDS, which are defined for architectures that provide their own assembly versions.
* Move bn_add_words() and bn_sub_words from bn_asm.c to bn_add.c.jsing2023-01-235-5/+25
| | | | | These are wrapped with #ifndef HAVE_BN_ADD_WORDS/HAVE_BN_SUB_WORDS, which are defined for architectures that provide their own assembly versions.
* Enable bn_sqr() on amd64.jsing2023-01-211-1/+2
| | | | ok tb@
* Provide an implementation of bn_sqr() that calls s2n-bignum's bignum_sqr().jsing2023-01-211-0/+32
| | | | ok tb@
* Fix include.jsing2023-01-211-1/+1
|
* Include the ISC license from s2n-bignum's LICENSE file.jsing2023-01-211-1/+12
|
* Bring in s2n-bignum's bignum_sqr() for amd64.jsing2023-01-211-0/+185
| | | | ok tb@
* Move bn_{mul,sqr}_comba{4,8}() from bn_asm.c to bn_mul.c/bn_sqr.c.jsing2023-01-205-5/+35
| | | | | | | Wrap these in HAVE_BN_{MUL,SQR}_COMBA{4,8} defines. Add these defines to bn_arch.h where the architecture currently provides its own version. ok tb@
* Replace BN_DIV3W with HAVE_BN_DIV_3_WORDS (in bn_arch.h).jsing2023-01-201-1/+3
| | | | ok tb@
* Provide a per machine bn_arch.h.jsing2023-01-2014-0/+336
This will provide a location for machine specific defines, prototypes and inline functions. ok tb@