summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_div.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use err_local.h rather than err.h in most placestb2025-05-101-2/+2
| | | | ok jsing
* Hide symbols in bn.hbeck2024-04-101-1/+2
| | | | | | | Mark them LCRYPTO_UNUSED appropriately and remove the LIBRESSL_INTERNAL guards around them ok tb@
* Convert BN_copy() with explicit comparison against NULL to bn_copy()tb2023-03-271-2/+2
| | | | ok jsing
* Rename bn_umul_hilo() to bn_mulw().jsing2023-02-161-2/+2
| | | | | | | | | 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@
* Fix a -0 corner case in BN_div_internal()jsing2023-02-141-3/+5
| | | | | | | | | | If the numerator is negative, the numerator and divisor are the same length (in words) and the absolute value of the divisor > the absolute value of the numerator, the "no_branch" case produces -0 since negative has already been set. Call BN_set_negative() at the end of the function to avoid this. ok tb@
* Avoid negative zero.jsing2023-02-131-4/+3
| | | | | | | | | | | | | | | | Whenever setting negative to one (or when it could potentially be one), always use BN_set_negative() since it checks for a zero valued bignum and will not permit negative to be set in this case. Since BN_is_zero() currently relies on top == 0, call BN_set_negative() after top has been set (or bn_correct_top() has been called). This fixes a long standing issue where -0 and +0 have been permitted, however multiple code paths (such as BN_cmp()) fail to treat these as equivalent. Prompted by Guido Vranken who is adding negative zero fuzzing to oss-fuzz. ok tb@
* Simplify bn_div_3_words().jsing2023-01-311-49/+15
| | | | | | | Make use of bn_umul_hilo() and remove the tangle of preprocessor directives that implement different code paths depending on what defines exist. ok tb@
* Fix previous.jsing2023-01-281-4/+9
|
* Provide bn_div_rem_words() and make use of it.jsing2023-01-281-59/+26
| | | | | | | | | | | | | | | | 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@
* Move bn_div_words from bn_asm.c to bn_div.c.jsing2023-01-231-1/+83
| | | | | This is wrapped with #ifndef HAVE_BN_DIV_WORDS, which are defined for architectures that provide their own assembly versions.
* Replace BN_DIV3W with HAVE_BN_DIV_3_WORDS (in bn_arch.h).jsing2023-01-201-3/+4
| | | | ok tb@
* Bring in a description of bn_words_3_div().jsing2023-01-181-1/+9
| | | | | | This comes from OpenSSL commit 3da2e9c4ee45989a426ff513dc6c6250d1e460de. ok tb@
* Start cleaning up BN_div_internal().jsing2023-01-181-158/+195
| | | | | | | | | | Always provide a bn_div_3_words() function, rather than having deeply nested compiler conditionals. Use readable variable names, clean up formatting and use a single exit path. Tested on various platforms by miod@ ok tb@
* spelling fixes; from paul tagliamontejmc2022-12-261-2/+2
| | | | | | | i removed the arithmetics -> arithmetic changes, as i felt they were not clearly correct ok tb
* Make internal header file names consistenttb2022-11-261-2/+2
| | | | | | | | | | | | | | | | Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names used for internal headers. Move all these headers we inherited from OpenSSL to *_local.h, reserving the name *_internal.h for our own code. Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h. constant_time_locl.h is moved to constant_time.h since it's special. Adjust all .c files in libcrypto, libssl and regress. The diff is mechanical with the exception of tls13_quic.c, where #include <ssl_locl.h> was fixed manually. discussed with jsing, no objection bcook
* Remove BIGNUM consistency macros.jsing2022-11-261-15/+2
| | | | | | | | | | | | Compiling with BN_DEBUG (and if you want to take it further, BN_DEBUG_RAND) supposedly adds consistency checks to the BN code. These are rarely if ever used and introduce a bunch of clutter in the code. Furthermore, there are hacks in place to undo things that the debugging code does. Remove all of this mess and instead rely on always enabled checks, more readable code and proper regress coverage to ensure correct behaviour. "Good riddance." tb@
* Change bn_expand()/bn_wexpand() to indicate failure/success via 0/1.jsing2022-11-241-3/+3
| | | | | | | | | Currently bn_expand()/bn_wexpand() return a BIGNUM *, however none of the callers use this (and many already treat it as a true/false value). Change these functions to return 0 on failure and 1 on success, revising callers that test against NULL in the process. ok tb@
* Send the function codes from the error functions to the bit bucket,beck2017-01-291-3/+3
| | | | | | as was done earlier in libssl. Thanks inoguchi@ for noticing libssl had more reacharounds into this. ok jsing@ inoguchi@
* Split out BN_div and BN_mod into ct and nonct versions for Internal use.beck2017-01-211-7/+29
| | | | ok jsing@
* BN_CTX_get() can fail - consistently check its return value.jsing2015-02-091-2/+2
| | | | | | | | | | | | | | | There are currently cases where the return from each call is checked, the return from only the last call is checked and cases where it is not checked at all (including code in bn, ec and engine). Checking the last return value is valid as once the function fails it will continue to return NULL. However, in order to be consistent check each call with the same idiom. This makes it easy to verify. Note there are still a handful of cases that do not follow the idiom - these will be handled separately. ok beck@ doug@
* Only import cryptlib.h in the four source files that actually need it.jsing2014-07-111-3/+4
| | | | | | | | Remove the openssl public includes from cryptlib.h and add a small number of includes into the source files that actually need them. While here, also sort/group/tidy the includes. ok beck@ miod@
* Explicitly include <openssl/opensslconf.h> in every file that referencesjsing2014-07-101-1/+4
| | | | | | | | | an OPENSSL_NO_* define. This avoids relying on something else pulling it in for us, plus it fixes several cases where the #ifndef OPENSSL_NO_XYZ is never going to do anything, since OPENSSL_NO_XYZ will never defined, due to the fact that opensslconf.h has not been included. This also includes some miscellaneous sorting/tidying of headers.
* When building a BN on the stack in BN_div(), make sure to initialize all itsmiod2014-06-271-1/+2
| | | | | | fields (i.e. the flags field) before using it. This is currently harmless, but might not be if we end up invoking other BN functions checking for constant-time processing requirement in the future.
* tags as requested by miod and teduderaadt2014-06-121-1/+1
|
* Emergency knfectomie requested by tedu@.jsing2014-05-081-129/+134
|
* Try to clean the maze of <openssl/bn.h> defines regarding the BN internals.miod2014-04-241-69/+2
| | | | | | | | | | | | | | | | | | | | | | | The intent of this change is to only keep support for two kind of architectures: - those with 32-bit int and long, and 64-bit long long, where ``long * long -> long long'' multiplication routines are available. - those with 64-bit int and long, and no 128-bit long long type. This gets rid of the SIXTY_FOUR_BIT_LONG, SIXTY_FOUR_BIT (not the same!), THIRTY_TWO_BIT, SIXTEEN_BIT and EIGHT_BIT defines. After this change, the types and defines are as follows: arch: 64bit 32bit rationale BN_LLONG undefined defined defined if l * l -> ll BN_ULLONG undefined u long long result of BN_LONG * BN_LONG BN_ULONG u long u int native register size BN_LONG long int the same, signed BN_BITS 128 64 size of 2*BN_ULONG in bits BN_BYTES 8 4 size of 2*BN_ULONG in bytes BN_BITS2 64 32 BN_BITS / 2 Tested on various 32-bit and 64-bit OpenBSD systems of various endianness.
* Unifdef -UPEDANTIC. ok beck@ tedu@miod2014-04-231-1/+1
|
* Nuke BN_DEBUG_LEVITTEmiod2014-04-171-10/+0
|
* Merge conflicts; remove MacOS, Netware, OS/2, VMS and Windows build machinery.miod2014-04-131-0/+2
|
* resolve conflictsdjm2012-10-131-238/+34
|
* resolve conflicts, fix local changesdjm2010-10-011-3/+10
|
* cherrypick patch from OpenSSL 0.9.8m:djm2010-03-041-1/+1
| | | | | *) Always check bn_wexpend() return values for failure. (CVE-2009-3245) [Martin Olsson, Neel Mehta]
* update to openssl-0.9.8i; tested by several, especially krw@djm2009-01-051-2/+13
|
* resolve conflictsdjm2008-09-061-27/+272
|
* merge 0.9.7b with local changes; crank majors for libssl/libcryptomarkus2003-05-121-1/+27
|
* Merge OpenSSL 0.9.7-stable-20020605,beck2002-06-071-4/+4
| | | | correctly autogenerate obj_mac.h
* OpenSSL 0.9.7 stable 2002 05 08 mergebeck2002-05-151-43/+23
|
* openssl-engine-0.9.6a mergebeck2001-06-221-3/+4
|
* openssl-engine-0.9.6 mergebeck2000-12-151-1/+1
|
* OpenSSL 0.9.5 mergebeck2000-03-191-92/+114
| | | | | | *warning* this bumps shared lib minors for libssl and libcrypto from 2.1 to 2.2 if you are using the ssl26 packages for ssh and other things to work you will need to get new ones (see ~beck/libsslsnap/<arch>) on cvs or ~beck/src-patent.tar.gz on cvs
* OpenSSL 0.9.4 mergebeck1999-09-291-54/+126
|
* Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD buildryker1998-10-051-0/+286
functionality for shared libs. Note that routines such as sslv2_init and friends that use RSA will not work due to lack of RSA in this library. Needs documentation and help from ports for easy upgrade to full functionality where legally possible.