summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_recp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* bn_recp: reformat another ugly commenttb2025-02-041-5/+6
|
* Inline BN_reciprocal() in its only callertb2025-02-041-36/+10
| | | | | | | | | | | This is simpler, doesn't need an auxiliary function of dubious value, avouds an auxiliary variable and gets rid of a bunch of comments that are hard to make sense of. This doesn't bother to invalidate recp->shift since on error you should not be reusing the RECP_CTX without reinitializing it. ok jsing
* Start cleaning up BN_div_reciprocal() a bittb2025-02-041-24/+23
| | | | | | | | | The fast path where no division is performed can be dealt with without BN_CTX, so do that up front so there's no need to clean up before return. Error check BN_CTX_get() on each use asd simplify the logic for optional input parameters. KNF for an ugly comment. ok jsing
* bn_recp: Avoid complication for negative modulitb2025-01-221-1/+2
| | | | | | | Instead of doing a weird dance, set the sign on N in BN_RECP_CTX_create(). Since we're not exposing a general purpose calculator API, we can simplify. ok jsing
* Rename BN_div_recp() into BN_div_reciprocal()tb2025-01-221-4/+4
| | | | Requested by jsing
* Split BN_mod_sqr_reciprocal() out of BN_mod_mul_reciprocal()tb2025-01-221-18/+12
| | | | | | | | There's no need for BN_mod_mul_reciprocal() to have this complication. The caller knows when x == y, so place the burden on the caller. This simplifies both the caller side and the implementation in bn_recp.c. ok jsing
* BN_mod_mul_reciprocal: remove y == NULL complicationtb2025-01-221-14/+11
| | | | | | | No caller ever passes y == NULL, so remove the corresponding contortions and unindent the relevant bits. ok jsing
* Move BN_RECP_CTX to the heaptb2025-01-211-40/+34
| | | | | | | | | | | | | | This introduces a BN_RECP_CTX_create() function that allocates and populates the BN_RECP_CTX in a single call, without taking an unused BN_CTX argument. At the same time, make the N and Nr members BIGNUMs on the heap which are allocated by BN_RECP_CTX_create() and freed by BN_RECP_CTX_free() and remove the unnecessary flags argument. Garbage collect the now unused BN_RECP_CTX_{new,init,set}(). ok jsing
* Improve order of things in BN_RECP_CTX_set()tb2025-01-081-3/+4
| | | | + some whitespace cosmetics
* Remove parentheses in return statementstb2025-01-081-8/+8
|
* Add a space after commatb2025-01-081-3/+3
|
* Remove superfluous parenthesestb2025-01-081-13/+13
|
* BN_div_recp() can't be static since it is directly exercised by bn_test.ctb2025-01-061-2/+2
|
* Shuffle functions into a more sensible ordertb2025-01-061-37/+38
| | | | | | BN_reciprocal() is only called by BN_div_recp() which in turn is only called by BN_mod_mul_reciprocal(). So use this order and make the first two static.
* Replace the remaining BN_copy() with bn_copy()tb2023-03-271-3/+3
| | | | ok jsing
* Avoid negative zero.jsing2023-02-131-3/+4
| | | | | | | | | | | | | | | | 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@
* 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-5/+1
| | | | | | | | | | | | 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@
* Send the function codes from the error functions to the bit bucket,beck2017-01-291-2/+2
| | | | | | 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-2/+2
| | | | ok jsing@
* Add missing BN_CTX_end() calls.doug2015-04-291-2/+4
| | | | | | | | After calling BN_CTX_start(), there must be a BN_CTX_end() before returning. There were missing BN_CTX_end() calls in error paths. One diff chunk was simply removing redundant code related to this. ok deraadt@
* Fix indentation that incorrectly implies a different control flow.doug2015-03-211-4/+6
| | | | | | | | | | | | | The actual control flow is intentional while the indenting is incorrect. This is intended to be a cosmetic change. Verified that each of these was part of a KNF commit that wasn't intending to change behavior. Also, double checked against the history of changes in OpenSSL and BoringSSL. Addresses Coverity CIDs: 78842, 78859, 78863. ok tedu@
* Only import cryptlib.h in the four source files that actually need it.jsing2014-07-111-2/+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@
* tags as requested by miod and teduderaadt2014-06-121-1/+1
|
* malloc() result does not need a cast.deraadt2014-06-071-1/+1
| | | | ok miod
* Emergency knfectomie requested by tedu@.jsing2014-05-081-100/+123
|
* Change library to use intrinsic memory allocation functions instead ofbeck2014-04-171-2/+2
| | | | | | | | OPENSSL_foo wrappers. This changes: OPENSSL_malloc->malloc OPENSSL_free->free OPENSSL_relloc->realloc OPENSSL_freeFunc->free
* resolve conflictsdjm2008-09-061-9/+13
|
* OpenSSL 0.9.7 stable 2002 05 08 mergebeck2002-05-151-19/+29
|
* openssl-engine-0.9.6 mergebeck2000-12-151-2/+2
|
* OpenSSL 0.9.5 mergebeck2000-03-191-25/+18
| | | | | | *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-38/+140
|
* Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD buildryker1998-10-051-0/+125
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.