aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_lcl.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix BN_hex2bn/BN_dec2bn NULL ptr/heap corruptionMatt Caswell2016-02-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the BN_hex2bn function the number of hex digits is calculated using an int value |i|. Later |bn_expand| is called with a value of |i * 4|. For large values of |i| this can result in |bn_expand| not allocating any memory because |i * 4| is negative. This leaves ret->d as NULL leading to a subsequent NULL ptr deref. For very large values of |i|, the calculation |i * 4| could be a positive value smaller than |i|. In this case memory is allocated to ret->d, but it is insufficiently sized leading to heap corruption. A similar issue exists in BN_dec2bn. This could have security consequences if BN_hex2bn/BN_dec2bn is ever called by user applications with very large untrusted hex/dec data. This is anticipated to be a rare occurrence. All OpenSSL internal usage of this function uses data that is not expected to be untrusted, e.g. config file data or application command line arguments. If user developed applications generate config file data based on untrusted data then it is possible that this could also lead to security consequences. This is also anticipated to be a rare. Issue reported by Guido Vranken. CVE-2016-0797 Reviewed-by: Andy Polyakov <appro@openssl.org>
* RT4339: Fix handling of <internal/bn_conf.h>David Woodhouse2016-02-231-1/+11
| | | | | | | | | | | | | | | | | | | | The entire contents of <internal/bn_conf.h> are unwanted in the UEFI build because we have to do it differently there. To support building for both 32-bit and 64-bit platforms without re-running the OpenSSL Configure script, the EDK2 environment defines THIRTY_TWO_BIT or SIXTY_FOUR_BIT for itself according to the target platform. The current setup is broken, though. It checks for OPENSSL_SYS_UEFI but before it's actually defined, since opensslconf.h hasn't yet been included. Let's fix that by including opensslconf.h. And also let's move the bn_conf.h doesn't even need to *exist* in the UEFI build environment. This is also GH PR736. Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
* Move more BN internals to bn_lcl.hRich Salz2016-01-301-0/+88
| | | | | | | | 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>
* Remove /* foo.c */ commentsRich Salz2016-01-261-1/+0
| | | | | | | | | | | | 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>
* Move & split opensslconf.h.inRich Salz2016-01-251-0/+1
| | | | | | | | Move opensslconf.h.in to include/openssl. Split off DES,BN,RC4 stuff into separate header file templates in crypto/include/internal/*_conf.h.in Reviewed-by: Richard Levitte <levitte@openssl.org>
* Remove BN_initRich Salz2015-11-301-1/+1
| | | | | | Rename it to be an internal function bn_init. Reviewed-by: Tim Hudson <tjh@openssl.org>
* Replace "SSLeay" in API with OpenSSLRich Salz2015-10-301-13/+1
| | | | | | | All instances of SSLeay (any combination of case) were replaced with the case-equivalent OpenSSL. Reviewed-by: Richard Levitte <levitte@openssl.org>
* bn/bn_lcl.h: fix MIPS-specific gcc version check.Andy Polyakov2015-05-261-1/+1
| | | | | | RT#3859 Reviewed-by: Tim Hudson <tjh@openssl.org>
* memset, memcpy, sizeof consistency fixesRich Salz2015-05-051-3/+3
| | | | | | | | Just as with the OPENSSL_malloc calls, consistently use sizeof(*ptr) for memset and memcpy. Remove needless casts for those functions. For memset, replace alternative forms of zero with 0. Reviewed-by: Richard Levitte <levitte@openssl.org>
* RAND_bytes updatesMatt Caswell2015-03-251-1/+1
| | | | | | | Ensure RAND_bytes return value is checked correctly, and that we no longer use RAND_pseudo_bytes. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Run util/openssl-format-source -v -c .Matt Caswell2015-01-221-447/+442
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* mark all block comments that need format preserving so thatTim Hudson2014-12-301-2/+3
| | | | | | | indent will not alter them when reformatting comments Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
* Fix unused variable warningEmilia Kasper2014-12-151-1/+3
| | | | | | | The temporary variable causes unused variable warnings in opt mode with clang, because the subsequent assert is compiled out. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Move bn internal functions into bn_int.h and bn_lcl.hMatt Caswell2014-12-081-0/+97
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Make bn opaqueMatt Caswell2014-12-081-0/+54
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Prepare for bn opaquify. Implement internal helper functions.Matt Caswell2014-12-081-1/+1
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>
* Try skipping over the adding and just picking a new random number.Felix Laurie von Massenbach2014-06-011-2/+2
| | | | | | | | Generates a number coprime to 2, 3, 5, 7, 11. Speed: Trial div (add) : trial div (retry) : coprime 1 : 0.42 : 0.84
* Generate safe primes not divisible by 3, 5 or 7.Felix Laurie von Massenbach2014-06-011-1/+1
| | | | ~2% speed improvement on trial division.
* Add a method to generate a prime that is guaranteed not to be divisible by 3 ↵Felix Laurie von Massenbach2014-06-011-0/+2
| | | | | | or 5. Possibly some reduction in bias, but no speed gains.
* Remove static from probable_prime_dh.Felix Laurie von Massenbach2014-06-011-0/+3
|
* Initial aarch64 bits.Andy Polyakov2013-10-131-0/+9
|
* bn_lcl.h: gcc removed support for "h" constraint, which broke inlineAndy Polyakov2012-09-011-2/+9
| | | | assembler.
* crypto/bn/*.h: move PTR_SIZE_INT to private header.Andy Polyakov2012-07-021-0/+18
|
* Internal version of BN_mod_inverse allowing checking of no-inverse withoutDr. Stephen Henson2011-01-261-0/+3
| | | | need to inspect error queue.
* bn_lcl.h: add MIPS III-specific BN_UMULT_LOHI as alternative to portingAndy Polyakov2010-01-171-3/+16
| | | | | | crypto/bn/asm/mips3.s from IRIX. Performance improvement is not as impressive as with complete assembler, but still... it's almost 2.5x [on R5000].
* Revert the size_t modifications from HEAD that had led to moreGeoff Thorpe2008-11-121-17/+14
| | | | | | knock-on work than expected - they've been extracted into a patch series that can be completed elsewhere, or in a different branch, before merging back to HEAD.
* Fix warnings about mismatched prototypes, undefined size_t and value computedDr. Stephen Henson2008-11-021-2/+3
| | | | not used.
* size_tification.Ben Laurie2008-11-011-13/+15
|
* Fix SHA512 and optimize BN for mingw64.Andy Polyakov2008-11-011-1/+2
|
* Move declaration for optional bn_mul_mont to bn_lcl.h in order to hideAndy Polyakov2005-11-061-0/+1
| | | | it from mkdef.pl.
* 3-4 times better RSA/DSA performance on WIN64A target. Well, on AMD64 CPU,Andy Polyakov2005-08-041-0/+36
| | | | EMT64T will hardly exhibit better performance...
* Implement fixed-window exponentiation to mitigate hyper-threadingBodo Möller2005-05-161-0/+39
| | | | | | | | | | | | timing attacks. BN_FLG_EXP_CONSTTIME requests this algorithm, and this done by default for RSA/DSA/DH private key computations unless RSA_FLAG_NO_EXP_CONSTTIME/DSA_FLAG_NO_EXP_CONSTTIME/ DH_FLAG_NO_EXP_CONSTTIME is set. Submitted by: Matthew D Wood Reviewed by: Bodo Moeller
* Minimise the amount of code dependent on BN_DEBUG_RAND. In particular,Geoff Thorpe2004-03-091-1/+4
| | | | | | | | redefine bn_clear_top2max() to be a NOP in the non-debugging case, and remove some unnecessary usages in bn_nist.c. Submitted by: Nils Larsch Reviewed by: Geoff Thorpe, Ulf Möller
* The bn_set_max() macro is only "used" by the bn_set_[low|high]() macrosGeoff Thorpe2003-12-011-32/+0
| | | | | | | | | | | | | which, in turn, are used nowhere at all. This is a good thing because bn_set_max() would currently generate code that wouldn't compile (BIGNUM has no 'max' element). The only apparent use for bn_set_[low|high] would be for implementing windowing algorithms, and all of openssl's seem to use bn_***_words() helpers instead (including the BN_div() that Nils fixed recently, which had been using independently-coded versions of what these unused macros are intended for). I'm therefore consigning these macros to cvs oblivion in the name of readability.
* Put the first stage of my bignum debugging adventures into CVS. This codeGeoff Thorpe2003-11-041-8/+0
| | | | | | is itself experimental, and in addition may cause execution to break on existing openssl "bugs" that previously were harmless or at least invisible.
* BN_CTX is opaque and the static initialiser BN_CTX_init() is not usedGeoff Thorpe2003-10-291-14/+0
| | | | | | | | | | | | except internally to the allocator BN_CTX_new(), as such this deprecates the use of BN_CTX_init() in the API. Moreover, the structure definition of BN_CTX is taken out of bn_lcl.h and moved into bn_ctx.c itself. NDEBUG should probably only be "forced" in the top-level configuration, but until it is I will avoid removing it from bn_ctx.c which might surprise people with massive slow-downs in their keygens. So I've left it in bn_ctx.c but tidied up the preprocessor logic a touch and made it more tolerant of debugging efforts.
* Fix for "shift count too large" when compiling for hpux-parisc2 andAndy Polyakov2002-12-201-1/+1
| | | | | irix-mips. The bug was introduced with accelerated support for x86_64. My fault! Fixed now.
* x86_64 performance patch.Andy Polyakov2002-12-141-1/+16
|
* avoid warnings ('index' shadows global declaration)Bodo Möller2002-10-291-2/+2
| | | | Submitted by: Nils Larsch
* clean up new code for NIST primesBodo Möller2002-10-281-0/+10
| | | | create new lock CRYPTO_LOCK_BN to avoid race condition
* add missing declarationBodo Möller2002-03-251-0/+2
| | | | Submitted by: Nils Larsch
* More EC stuff, including EC_POINTs_mul() for simultaneous scalarBodo Möller2001-03-101-1/+1
| | | | multiplication of an arbitrary number of points.
* Hide BN_CTX structure details.Bodo Möller2001-03-081-0/+14
| | | | Incease the number of BIGNUMs in a BN_CTX.
* Make all configuration macros available for application by makingRichard Levitte2001-02-191-2/+2
| | | | | | | | | | | | sure they are available in opensslconf.h, by giving them names starting with "OPENSSL_" to avoid conflicts with other packages and by making sure e_os2.h will cover all platform-specific cases together with opensslconf.h. I've checked fairly well that nothing breaks with this (apart from external software that will adapt if they have used something like NO_KRB5), but I can't guarantee it completely, so a review of this change would be a good thing.
* bn_part_sub_word prototype.Ulf Möller2000-12-081-0/+2
|
* Remove the last bn_wexpand()s that made us break constness. OfRichard Levitte2000-12-041-2/+3
| | | | | | | | | course, that means we need to handle the cases where the two arrays to bn_mul_recursive() and bn_mul_part_recursive() differ in size. I haven't yet changed the comments that describe bn_mul_recursive() and bn_mul_part_recursive(). I want this to be tested by more people before I consider this change final. Please test away!
* Fix bn_cmp_part_words() and move it to bn_lib.c.Ulf Möller2000-12-021-0/+2
|
* Remove a declaration for a function that does not exist.Richard Levitte2000-11-181-1/+0
|
* More constification of the BN library.Richard Levitte2000-11-161-5/+6
|
* max -> dmax in bn_check_top.Ben Laurie2000-08-221-1/+1
|