aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn
Commit message (Collapse)AuthorAgeFilesLines
...
* Explain *cough*-dowsEmilia Kasper2016-03-153-3/+3
| | | | Reviewed-by: Andy Polyakov <appro@openssl.org>
* build.info/Makefile.in: Itanium fixups.Andy Polyakov2016-03-141-1/+1
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Add $(LIB_CFLAGS) for any build.info generator that uses $(CFLAGS)Richard Levitte2016-03-131-6/+6
| | | | | | | The reason to do so is that some of the generators detect PIC flags like -fPIC and -KPIC, and those are normally delivered in LD_CFLAGS. Reviewed-by: Rich Salz <rsalz@openssl.org>
* crypto/*/build.info: SPARC-specific fixups.Andy Polyakov2016-03-111-0/+3
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix some assembler generating scripts for better unificationRichard Levitte2016-03-116-8/+8
| | | | | | | | | | | Some of these scripts would recognise an output parameter if it looks like a file path. That works both in both the classic and new build schemes. Some fo these scripts would only recognise it if it's a basename (i.e. no directory component). Those need to be corrected, as the output parameter in the new build scheme is more likely to contain a directory component than not. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Add include directory options for assembler files that include from crypto/Richard Levitte2016-03-101-0/+6
| | | | | | Closes RT#4406 Reviewed-by: Rich Salz <rsalz@openssl.org>
* Make sure the effect of "pic" / "no-pic" is used with assembler compilationsRichard Levitte2016-03-091-1/+1
| | | | | | | | | | | | | | Before the 'Introduce the "pic" / "no-pic" config option' commit, the shared_cflag value for the chosen config would be part of the make variable CFLAG, which got replicated into CFLAGS and ASFLAGS. Since said commit, the shared_cflag value has become a make variable of its own, SHARED_CFLAG (which is left empty in a "no-pic" build). However, ASFLAGS was forgotten. That's what's corrected with this change. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Convert RSA blinding to new multi-threading APIAlessandro Ghedini2016-03-081-17/+32
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* SPARCv9 assembly pack: unify build rules and argument handling.Andy Polyakov2016-03-085-35/+31
| | | | | | | | | | Make all scripts produce .S, make interpretation of $(CFLAGS) pre-processor's responsibility, start accepting $(PERLASM_SCHEME). [$(PERLASM_SCHEME) is redundant in this case, because there are no deviataions between Solaris and Linux assemblers. This is purely to unify .pl->.S handling across all targets.] Reviewed-by: Richard Levitte <levitte@openssl.org>
* Convert CRYPTO_LOCK_{DH,DSA,RSA} to new multi-threading APIAlessandro Ghedini2016-03-081-5/+5
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* Unified - adapt the generation of bignum assembler to use GENERATERichard Levitte2016-03-0715-91/+115
| | | | | | | | | This gets rid of the BEGINRAW..ENDRAW sections in crypto/bn/build.info. This also moves the assembler generating perl scripts to take the output file name as last command line argument, where necessary. Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/asm/x86[_64]-mont*.pl: complement alloca with page-walking.Andy Polyakov2016-03-073-2/+116
| | | | | | | | | | | Some OSes, *cough*-dows, insist on stack being "wired" to physical memory in strictly sequential manner, i.e. if stack allocation spans two pages, then reference to farmost one can be punishable by SEGV. But page walking can do good even on other OSes, because it guarantees that villain thread hits the guard page before it can make damage to innocent one... Reviewed-by: Rich Salz <rsalz@openssl.org>
* Consistently use arm_arch.h constants in armcap assembly code.David Benjamin2016-03-021-1/+1
| | | | | | | | Most of the assembly uses constants from arm_arch.h, but a few references to ARMV7_NEON don't. Consistently use the macros everywhere. Signed-off-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/asm/x86_64-mont5.pl: unify gather procedure in hardly used pathAndy Polyakov2016-03-012-199/+278
| | | | | | | | | and reorganize/harmonize post-conditions. Additional hardening following on from CVE-2016-0702 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* crypto/bn/x86_64-mont5.pl: constant-time gather procedure.Andy Polyakov2016-03-013-558/+678
| | | | | | | | | | | | At the same time remove miniscule bias in final subtraction. Performance penalty varies from platform to platform, and even with key length. For rsa2048 sign it was observed to be 4% for Sandy Bridge and 7% on Broadwell. CVE-2016-0702 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/asm/rsaz-avx2.pl: constant-time gather procedure.Andy Polyakov2016-03-012-89/+152
| | | | | | | | | Performance penalty is 2%. CVE-2016-0702 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/asm/rsax-x86_64.pl: constant-time gather procedure.Andy Polyakov2016-03-011-84/+291
| | | | | | | | | Performance penalty is 2% on Linux and 5% on Windows. CVE-2016-0702 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* bn/bn_exp.c: constant-time MOD_EXP_CTIME_COPY_FROM_PREBUF.Andy Polyakov2016-03-011-18/+57
| | | | | | | | | | Performance penalty varies from platform to platform, and even key length. For rsa2048 sign it was observed to reach almost 10%. CVE-2016-0702 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix BN_hex2bn/BN_dec2bn NULL ptr/heap corruptionMatt Caswell2016-02-292-4/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* GH678: Add a few more zallocFdaSilvaYY2016-02-221-1/+1
| | | | | | | Remove some duplicated NULL/zero init. Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
* Always build library object files with shared library cflagsRichard Levitte2016-02-201-1/+1
| | | | | | | | | | | | | | | | This takes us away from the idea that we know exactly how our static libraries are going to get used. Instead, we make them available to build shareable things with, be it other shared libraries or DSOs. On the other hand, we also have greater control of when the shared library cflags. They will never be used with object files meant got binaries, such as apps/openssl or test/test*. With unified, we take this a bit further and prepare for having to deal with extra cflags specifically to be used with DSOs (dynamic engines), libraries and binaries (applications). Reviewed-by: Rich Salz <rsalz@openssl.org>
* Remove all special make depend flags, as well as OPENSSL_DOING_MAKEDEPENDRichard Levitte2016-02-181-1/+1
| | | | | | | | | | All those flags existed because we had all the dependencies versioned in the repository, and wanted to have it be consistent, no matter what the local configuration was. Now that the dependencies are gone from the versioned Makefile.ins, it makes much more sense to use the exact same flags as when compiling the object files. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Remove outdated DEBUG flags.Rich Salz2016-02-181-8/+0
| | | | | | | | | | | | | | | | | Add -DBIO_DEBUG to --strict-warnings. Remove comments about outdated debugging ifdef guards. Remove md_rand ifdef guarding an assert; it doesn't seem used. Remove the conf guards in conf_api since we use OPENSSL_assert, not assert. For pkcs12 stuff put OPENSSL_ in front of the macro name. Merge TLS_DEBUG into SSL_DEBUG. Various things just turned on/off asserts, mainly for checking non-NULL arguments, which is now removed: camellia, bn_ctx, crypto/modes. Remove some old debug code, that basically just printed things to stderr: DEBUG_PRINT_UNKNOWN_CIPHERSUITES, DEBUG_ZLIB, OPENSSL_RI_DEBUG, RL_DEBUG, RSA_DEBUG, SCRYPT_DEBUG. Remove OPENSSL_SSL_DEBUG_BROKEN_PROTOCOL. Reviewed-by: Richard Levitte <levitte@openssl.org>
* In the unified scheme, there is no $(TOP), use $(SRCDIR) insteadRichard Levitte2016-02-181-2/+2
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Pass $(CC) to perlasm scripts via the environmentRichard Levitte2016-02-131-27/+27
| | | | | | | | It seems that on some platforms, the perlasm scripts call the C compiler for certain checks. These scripts need the environment variable CC to have the C compiler command. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Missing header include.Rich Salz2016-02-111-0/+1
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Add inclusion directory crypto/include for BN compilationsRichard Levitte2016-02-111-0/+2
| | | | | | | Some files in crypto/bn depend on internal/bn_conf.h, and so does test/bntest. Therefore, we add another inclusion directory. Reviewed-by: Rich Salz <rsalz@openssl.org>
* unified build scheme: add a "unified" template for Unix MakefileRichard Levitte2016-02-101-0/+90
| | | | | | This also adds all the raw sections needed for some files. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Use NON_EMPTY_TRANSLATION_UNIT, consistently.Rich Salz2016-02-092-14/+11
| | | | | | This also closes RT 4123 Reviewed-by: Richard Levitte <levitte@openssl.org>
* bn/Makefile.in: remove obsolete rules.Andy Polyakov2016-02-081-14/+1
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* GH601: Various spelling fixes.FdaSilvaYY2016-02-059-10/+10
| | | | | Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
* New BN functions.Dr. Stephen Henson2016-02-021-4/+90
| | | | | | | | | | Add new function BN_bn2binpad() which checks the length of the output buffer and pads the result with zeroes if necessary. New functions BN_bn2lebinpad() and BN_lebin2bn() which use little endian format. Reviewed-by: Rich Salz <rsalz@openssl.org>
* unified build scheme: add build.info filesRichard Levitte2016-02-011-0/+8
| | | | | | | | | Now that we have the foundation for the "unified" build scheme in place, we add build.info files. They have been generated from the Makefiles in the same directories. Things that are platform specific will appear in later commits. Reviewed-by: Andy Polyakov <appro@openssl.org>
* unified build scheme: a first introductionRichard Levitte2016-02-011-0/+4
| | | | | | | | | | | | | | | | | | | | | | The "unified" build scheme revolves around small information files, build.info, which each describe their own bit of everything that needs to be built, using a mini-language described in Configurations/README. The information in build.info file contain references to source files and final result. Object files are not mentioned at all, they are simply from source files. Because of this, all the *_obj items in Configurations/*.conf are renamed to *_asm_src and the files listed in the values are change from object files to their corresponding source files. For the sake of the other build schemes, Configure generates corresponding *_obj entries in %target. Furthermore, the "unified" build scheme supports having a build directory tree separate from the source directry tree. All paths in a build.info file is assumed to be relative to its location, either within the source tree or within the build tree. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Move more BN internals to bn_lcl.hRich Salz2016-01-303-9/+89
| | | | | | | | 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>
* Templatize util/domdRich Salz2016-01-291-2/+1
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Always DPURIFYEmilia Kasper2016-01-291-11/+2
| | | | | | | | The use of the uninitialized buffer in the RNG has no real security benefits and is only a nuisance when using memory sanitizers. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
* Restore NUMPRIMES as a numeric literalViktor Dukhovni2016-01-283-4/+6
| | | | | | | This fixes clang compilation problem with size_t NUMPRIMES and int loop counters. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Remove EIGHT_BIT and SIXTEEN_BITRich Salz2016-01-273-60/+26
| | | | | | Also cleaned up bn_prime.pl to current coding style. Reviewed-by: Andy Polyakov <appro@openssl.org>
* Remove /* foo.c */ commentsRich Salz2016-01-2630-30/+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>
* Consolidate "make update"Rich Salz2016-01-201-1/+1
| | | | | | Rename 'update' to 'generate'. Rather than recurse, just explicitly call the three generate targets directly. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Remove some old makefile targetsRich Salz2016-01-171-12/+0
| | | | | | | | Remove lint, tags, dclean, tests. This is prep for a new makedepend scheme. This is temporary pending unified makefile, and might help it. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Move Makefiles to Makefile.inRich Salz2016-01-122-419/+174
| | | | | | | | | | Create Makefile's from Makefile.in Rename Makefile.org to Makefile.in Rename Makefiles to Makefile.in Address review feedback from Viktor and Richard Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
* Update comment as bn_dup_expand is goneViktor Dukhovni2016-01-081-1/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Backwards-compatibility subject to OPENSSL_API_COMPATViktor Dukhovni2016-01-073-5/+8
| | | | | | | | | Provide backwards-compatiblity for functions, macros and include files if OPENSSL_API_COMPAT is either not defined or defined less than the version number of the release in which the feature was deprecated. Reviewed-by: Richard Levitte <levitte@openssl.org>
* bn/asm/bn-c64xplus.asm: update commentary.Andy Polyakov2015-12-221-2/+3
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix URLs mangled by reformatMatt Caswell2015-12-191-1/+1
| | | | | | | Some URLs in the source code ended up getting mangled by indent. This fixes it. Based on a patch supplied by Arnaud Lacombe <al@aerilon.ca> Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix a ** 0 mod 1 = 0 for real this time.Emilia Kasper2015-12-141-8/+31
| | | | | | | | | | | Commit 2b0180c37fa6ffc48ee40caa831ca398b828e680 attempted to do this but only hit one of many BN_mod_exp codepaths. Fix remaining variants and add a test for each method. Thanks to Hanno Boeck for reporting this issue. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Dr. Stephen Henson <steve@openssl.org>