summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_gcd.c
AgeCommit message (Collapse)Author
2019-10-23Update control logic for BN_gcdCesar Pereida Garcia
PR https://github.com/openssl/openssl/pull/10122 introduced changes to the BN_gcd function and the control logic inside it accessed `g->d[0]` irrespective of `g->top`. When BN_add is called, in case the result is zero, `BN_zero` is called. The latter behaves differently depending on the API compatibility level flag: normally `g->d[0]` is cleared but in `no-deprecated` builds only `g->top` is set to zero. This commit uses bitwise logic to ensure that `g` is treated as zero if `g->top` is zero, irrespective of `g->d[0]`. Co-authored-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10232)
2019-10-17Constant-time GCD function.Cesar Pereida Garcia
This commit replaces the current `BN_gcd` function with a constant-time GCD implementation. Reviewed-by: Paul Dale <paul.dale@oracle.com> Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10122)
2019-09-28Reorganize local header filesDr. Matthias St. Pierre
Apart from public and internal header files, there is a third type called local header files, which are located next to source files in the source directory. Currently, they have different suffixes like '*_lcl.h', '*_local.h', or '*_int.h' This commit changes the different suffixes to '*_local.h' uniformly. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/9333)
2018-12-06Following the license change, modify the boilerplates in crypto/bn/Richard Levitte
[skip ci] Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7777)
2018-05-29Update copyright yearMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6371)
2018-05-03Return an error from BN_mod_inverse if n is 1 (or -1)Matt Caswell
Calculating BN_mod_inverse where n is 1 (or -1) doesn't make sense. We should return an error in that case. Instead we were returning a valid result with value 0. Fixes #6004 Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6119)
2017-10-18Remove parentheses of return.KaoruToda
Since return is inconsistent, I removed unnecessary parentheses and unified them. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/4541)
2017-06-26Change to check last return value of BN_CTX_getPaul Yang
To make it consistent in the code base Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/3749)
2017-03-28Refomat a few comments on 80 colsFdaSilvaYY
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3066)
2016-06-29Whitespace cleanup in cryptoFdaSilvaYY
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1264)
2016-05-17Copyright consolidation 06/10Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-05GH601: Various spelling fixes.FdaSilvaYY
Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-01-30Move more BN internals to bn_lcl.hRich Salz
There was an unused macro in ssl_locl.h that used an internal type, so I removed it. Move bio_st from bio.h to ossl_type.h Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-01-26Remove /* foo.c */ commentsRich Salz
This was done by the following find . -name '*.[ch]' | /tmp/pl where /tmp/pl is the following three-line script: print unless $. == 1 && m@/\* .*\.[ch] \*/@; close ARGV if eof; # Close file to reset $. And then some hand-editing of other files. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2015-11-30Remove BN_initRich Salz
Rename it to be an internal function bn_init. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-11-26Tighten up BN_with_flags usage and avoid a reachable assertMatt Caswell
The function rsa_ossl_mod_exp uses the function BN_with_flags to create a temporary copy (local_r1) of a BIGNUM (r1) with modified flags. This temporary copy shares some state with the original r1. If the state of r1 gets updated then local_r1's state will be stale. This was occurring in the function so that when local_r1 was freed a call to bn_check_top was made which failed an assert due to the stale state. To resolve this we must free local_r1 immediately after we have finished using it and not wait until the end of the function. This problem prompted a review of all BN_with_flag usage within the codebase. All other usage appears to be correct, although often not obviously so. This commit refactors things to make it much clearer for these other uses. Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-10-07Set flags to 0 before calling BN_with_flags()Pascal Cuoq
BN_with_flags() will read the dest->flags to keep the BN_FLG_MALLOCED but overwrites everything else. Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org> MR #1231
2015-05-14Identify and move common internal libcrypto header filesRichard Levitte
There are header files in crypto/ that are used by a number of crypto/ submodules. Move those to crypto/include/internal and adapt the affected source code and Makefiles. The header files that got moved are: crypto/cryptolib.h crypto/md32_common.h Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-01-22Re-align some comments after running the reformat script.Matt Caswell
This should be a one off operation (subsequent invokation of the script should not move them) Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Run util/openssl-format-source -v -c .Matt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2014-12-30mark all block comments that need format preserving so thatTim Hudson
indent will not alter them when reformatting comments Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2014-12-08remove OPENSSL_FIPSAPIDr. Stephen Henson
Reviewed-by: Tim Hudson <tjh@openssl.org>
2011-02-03Transfer error redirection to fips.h, add OPENSSL_FIPSAPI to source filesDr. Stephen Henson
that use it.
2011-01-26Internal version of BN_mod_inverse allowing checking of no-inverse withoutDr. Stephen Henson
need to inspect error queue.
2007-06-11Privatize BN_*_no_branch.Andy Polyakov
2007-04-19fix error codesBodo Möller
2007-03-28make BN_FLG_CONSTTIME semantics more fool-proofBodo Möller
2007-03-28Change to mitigate branch prediction attacksBodo Möller
Submitted by: Matthew D Wood Reviewed by: Bodo Moeller
2005-08-28fix warnings when building openssl with the following compiler options:Nils Larsch
-Wmissing-prototypes -Wcomment -Wformat -Wimplicit -Wmain -Wmultichar -Wswitch -Wshadow -Wtrigraphs -Werror -Wchar-subscripts -Wstrict-prototypes -Wreturn-type -Wpointer-arith -W -Wunused -Wno-unused-parameter -Wuninitialized
2003-12-06Avoid segfault if ret==0.Ulf Möller
Submitted by: Nils Larsch
2003-11-04Put the first stage of my bignum debugging adventures into CVS. This codeGeoff Thorpe
is itself experimental, and in addition may cause execution to break on existing openssl "bugs" that previously were harmless or at least invisible.
2001-04-09Adjust BN_mod_inverse algorithm selection according to experiments onBodo Möller
Ultra-Sparcs (both 32-bit and 64-bit compilations)
2001-04-08commentBodo Möller
2001-04-08code documentationBodo Möller
2001-04-08binary algorithm for modular inversionBodo Möller
2000-11-30Corrections to the comments in BN_mod_inverse.Bodo Möller
2000-11-29add missing bracesBodo Möller
2000-11-29Make BN_mod_inverse a little fasterBodo Möller
2000-11-29Improve BN_mod_inverse performance.Bodo Möller
Get the BN_mod_exp_mont bugfix (for handling negative inputs) correct this time.
2000-11-27Fix BN_is_... macros.Bodo Möller
Fix BN_gcd. Analyze BN_mod_inverse. Add BN_kronecker. "make update".
2000-11-16More constification of the BN library.Richard Levitte
2000-11-06Constify the BIGNUM routines a bit more. The only trouble were theRichard Levitte
two functions that did expansion on in parameters (BN_mul() and BN_sqr()). The problem was solved by making bn_dup_expand() which is a mix of bn_expand2() and BN_dup().
2000-02-05New functions BN_CTX_start(), BN_CTX_get(), BN_CTX_end() to accessUlf Möller
temporary BIGNUMs. BN_CTX still uses a fixed number of BIGNUMs, but the BN_CTX implementation could now easily be changed.
1999-06-04Some constification and stacks that slipped through the cracks (how?).Ben Laurie
1999-04-26Remove NOPROTO definitions and error code comments.Ulf Möller
1999-04-19Change functions to ANSI C.Ulf Möller
1998-12-21Import of old SSLeay release: SSLeay 0.9.1b (unreleased)SSLeayRalf S. Engelschall
1998-12-21Import of old SSLeay release: SSLeay 0.9.0bRalf S. Engelschall
1998-12-21Import of old SSLeay release: SSLeay 0.8.1bRalf S. Engelschall