aboutsummaryrefslogtreecommitdiff
path: root/crypto/bn
AgeCommit message (Collapse)AuthorFilesLines
2016-10-24ppccap.c: engage new multipplication and squaring subroutines.Andy Polyakov1-3/+0
[And remove FPU mutiplication subroutine.] Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-24bn/asm/ppc-mont.pl: add optimized multiplication and squaring subroutines.Andy Polyakov1-1/+1645
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-24bn/asm/ppc-mont.pl: prepare for extension.Andy Polyakov1-19/+24
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-10-10Fix up bn_prime.pl formatting.David Benjamin2-260/+259
Align at 5 characters, not 4. There are 5-digit numbers in the output. Also avoid emitting an extra blank line and trailing whitespace. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-10-10Remove trailing whitespace from some files.David Benjamin15-192/+192
The prevailing style seems to not have trailing whitespace, but a few lines do. This is mostly in the perlasm files, but a few C files got them after the reformat. This is the result of: find . -name '*.pl' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' find . -name '*.c' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' find . -name '*.h' | xargs sed -E -i '' -e 's/( |'$'\t'')*$//' Then bn_prime.h was excluded since this is a generated file. Note mkerr.pl has some changes in a heredoc for some help output, but other lines there lack trailing whitespace too. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-09-13bn/bn_lcl.h: improve interoperability with clang and Android NDK.Andy Polyakov1-2/+2
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-09-06Misc BN fixesRich Salz3-15/+23
Never output -0; make "negative zero" an impossibility. Do better checking on BN_rand top/bottom requirements and #bits. Update doc. Ignoring trailing garbage in BN_asc2bn. Port this commit from boringSSL: https://boringssl.googlesource.com/boringssl/+/899b9b19a4cd3fe526aaf5047ab9234cdca19f7d%5E!/ Ensure |BN_div| never gives negative zero in the no_branch code. Have |bn_correct_top| fix |bn->neg| if the input is zero so that we don't have negative zeros lying around. Thanks to Brian Smith for noticing. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-09-02MIPS assembly pack: adapt it for MIPS[32|64]R6.Andy Polyakov3-424/+436
MIPS[32|64]R6 is binary and source incompatible with previous MIPS ISA specifications. Fortunately it's still possible to resolve differences in source code with standard pre-processor and switching to trap-free version of addition and subtraction instructions. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-31crypto/bn/*: x86[_64] division instruction doesn't handle constants, change ↵Andy Polyakov2-3/+3
constraint from 'g' to 'r'. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-08-29bn/asm/ppc.pl: harmonize .size directive in bn_mul_words.Andy Polyakov1-1/+1
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-08-24Remove useless assignmentMatt Caswell1-2/+1
The variable assignment c1 is never read before it is overwritten. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-08-23Fix math in BN_bn2dec comment.David Benjamin1-2/+2
The bound on log(2)/3 on the second line is incorrect and has an extra zero compared to the divisions in the third line. log(2)/3 = 0.10034... which is bounded by 0.101 and not 0.1001. The divisions actually correspond to 0.101 which is fine. The third line also dropped a factor of three. The actual code appears to be fine. Just the comments are wrong. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-23Check for malloc error in bn_x931p.cMatt Caswell1-0/+3
Ensure BN_CTX_get() has been successful Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-08-22bn/asm/x86[_64]-mont*.pl: implement slightly alternative page-walking.Andy Polyakov3-179/+274
Original strategy for page-walking was adjust stack pointer and then touch pages in order. This kind of asks for double-fault, because if touch fails, then signal will be delivered to frame above adjusted stack pointer. But touching pages prior adjusting stack pointer would upset valgrind. As compromise let's adjust stack pointer in pages, touching top of the stack. This still asks for double-fault, but at least prevents corruption of neighbour stack if allocation is to overstep the guard page. Also omit predict-non-taken hints as they reportedly trigger illegal instructions in some VM setups. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-08-22Fix overflow check in BN_bn2dec()Kazuki Yamaguchi1-3/+2
Fix an off by one error in the overflow check added by 07bed46f332fc ("Check for errors in BN_bn2dec()"). Reviewed-by: Stephen Henson <steve@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-08-16Check for errors in BN_bn2dec()Dr. Stephen Henson1-1/+7
If an oversize BIGNUM is presented to BN_bn2dec() it can cause BN_div_word() to fail and not reduce the value of 't' resulting in OOB writes to the bn_data buffer and eventually crashing. Fix by checking return value of BN_div_word() and checking writes don't overflow buffer. Thanks to Shi Lei for reporting this bug. CVE-2016-2182 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-08-14Never return -1 from BN_expJakub Zelenka1-4/+4
Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1455)
2016-08-10Change callers to use the new constants.Rich Salz4-12/+13
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1429)
2016-08-05spelling fixes, just comments and readme.klemens7-10/+10
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1413)
2016-08-02Fix some style issues...FdaSilvaYY1-2/+2
extra spacing and 80 cols Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1366)
2016-07-20Check for errors allocating the error strings.Kurt Roeckx1-1/+2
Reviewed-by: Richard Levitte <levitte@openssl.org> GH: #1330
2016-07-20Fix a few if(, for(, while( inside code.FdaSilvaYY1-15/+15
Fix some indentation at the same time Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1292)
2016-07-19RT4593: Add space after comma (doc nits)Rich Salz1-5/+5
Update find-doc-nits to find errors in SYNOPSIS (the most common place where they were missing). Reviewed-by: Matt Caswell <matt@openssl.org>
2016-07-01Simplify INCLUDE statements in build.info filesRichard Levitte1-2/+1
Now that INCLUDE considers both the source and build trees, no need for the rel2abs perl fragment hacks any more. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-30Convert memset calls to OPENSSL_cleanseMatt Caswell1-1/+1
Ensure things really do get cleared when we intend them to. Addresses an OCAP Audit issue. Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-06-29Whitespace cleanup in cryptoFdaSilvaYY4-5/+5
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-06-25Handle BN_mod_word failures.David Benjamin1-11/+30
As of 37258dadaa9e36db4b96a3aa54aa6c67136160cc and the corresponding upstream change, BN_mod_word may fail, like BN_div_word. Handle this properly. Thanks to Brian Smith for pointing this out. See BoringSSL's 44bedc348d9491e63c7ed1438db100a4b8a830be. Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1251
2016-06-25Fix BN_is_prime* calls.David Benjamin1-5/+12
This function returns a tri-state -1 on error. See BoringSSL's 53409ee3d7595ed37da472bc73b010cd2c8a5ffd. Signed-off-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1251
2016-06-18Useless header include of openssl/rand.hFdaSilvaYY2-2/+0
Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1168)
2016-06-13Add some missing return value checksMatt Caswell2-5/+8
Some misc return value checks Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-13bn/bn_add.c: favour counted loops over ifs and breaks.Andy Polyakov1-72/+38
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-06-11Avoid creating illegal pointersKurt Roeckx1-5/+7
Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1179
2016-06-09Clean up "generic" intro pod files.Rich Salz1-0/+247
Files like dh.pod, etc., mostly duplicated the API-specific pod files. Removed the duplicated content; that often mean the whole file could be removed. Some of the content about internals got moved into README files in the source tree. Some content (e.g., err.pod) got moved into other pod pages. Annotate generic pages, remove dup NAME Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-06-07Fix BN_mod_word bugMatt Caswell1-0/+22
On systems where we do not have BN_ULLONG (e.g. typically 64 bit systems) then BN_mod_word() can return incorrect results if the supplied modulus is too big. RT#4501 Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-06-02Fix test failures when using enable-ubsanMatt Caswell1-1/+1
Numerous test failures were occuring when Configured with enable-ubsan although they could all be traced back to one issue. Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-06-01Add final(?) set of copyrights.Rich Salz7-15/+42
Add copyright to missing assembler files. Add copyrights to missing test/* files. Add copyrights Various source and misc files. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-29x86_64 assembly pack: tolerate spaces in source directory name.Andy Polyakov5-5/+5
[as it is now quoting $output is not required, but done just in case] Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-27bn/bn_exp.c: explain 'volatile' in MOD_EXP_CTIME_COPY_FROM_PREBUF.Andy Polyakov1-0/+8
Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-05-27fix BN_hex2bn()/BN_dec2bn() memory leakhuangqinjin1-2/+2
Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-25build.info files: add quotes around any spec that may contain spacesRichard Levitte1-1/+1
RT#4492 Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-05-24Clean up RAND_bytes() callsTodd Short1-7/+2
When RAND_pseudo_bytes() was replaced with RAND_bytes(), this case was not reduced to a simple RAND_bytes() call. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1117)
2016-05-23Remove unused error/function codes.Rich Salz1-9/+1
Add script to find unused err/reason codes Remove unused reason codes. Remove entries for unused functions Reviewed-by: Matt Caswell <matt@openssl.org>
2016-05-23VMS: remove last VAX vestigesRichard Levitte2-6462/+0
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-05-22Avoid creating an illegal pointerKurt Roeckx1-2/+4
Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1106
2016-05-22Avoid creating an illegal pointerKurt Roeckx1-1/+5
Found by tis-interpreter Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1106
2016-05-21Add OpenSSL copyright to .pl filesRich Salz26-26/+208
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-17Manual fixes after copyright consolidationRich Salz3-53/+11
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-17Copyright consolidation 06/10Rich Salz36-2115/+225
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-16Use OPENSSL_hexchar2intRich Salz1-7/+2
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-05-16Fold threads.h into crypto.h making API publicViktor Dukhovni1-1/+0
Document thread-safe lock creation Reviewed-by: Richard Levitte <levitte@openssl.org>