summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2016-11-15Check that SCT timestamps are not in the futureRob Percival
Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1554)
2016-11-15Simplify PKCS#12 PBE algorithm.Dr. Stephen Henson
Simplify PKCS#12 PBE algorithm by working out Ij + B + 1 directly instead of using BIGNUMs. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-15Add a warning stipulating how things should be coded in ossl_init_baseRichard Levitte
Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1922)
2016-11-15Stop init loopsRichard Levitte
Under certain circumstances, the libcrypto init code would loop, causing a deadlock. This would typically happen if something in ossl_init_base() caused an OpenSSL error, and the error stack routines would recurse into the init code before the flag that ossl_init_base() had been run was checked. This change makes sure ossl_init_base isn't run once more of the base is initiated. Thanks to Dmitry Kostjuchenko for the idea. Fixes Github issue #1899 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1922)
2016-11-14dsa/dsa_gen: add error message for seed_len < 0Sebastian Andrzej Siewior
prio openssl 1.1.0 seed_len < q was accepted and the seed argument was then ignored. Now DSA_generate_parameters_ex() returns an error in such a case but no error string. Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1657)
2016-11-14Revert "Fixed deadlock in CRYPTO_THREAD_run_once for Windows"Matt Caswell
This reverts commit 349d1cfddcfa33d352240582a3803f2eba39d9a0. The proposed fix is incorrect. It marks the "run_once" code as having finished before it has. The intended semantics of run_once is that no threads should proceed until the code has run exactly once. With this change the "second" thread will think the run_once code has already been run and will continue, even though it is still in progress. This could result in a crash or other incorrect behaviour. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-13Fixed deadlock in CRYPTO_THREAD_run_once for WindowsDK
Fixed deadlock in CRYPTO_THREAD_run_once() if call to init() is causing a recursive call to CRYPTO_THREAD_run_once() again that is causing a hot deadloop inside do { } while (result == ONCE_ININIT); section. CLA: trivial Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1913)
2016-11-12Cast to an unsigned type before negatingKurt Roeckx
llvm's ubsan reported: runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself Found using libfuzzer Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1908
2016-11-11sha/asm/sha512-armv8.pl: add NEON version of SHA256.Andy Polyakov
This provides up to 30% better performance on some of recent processors. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-11sha/keccak1600.c: add some optimized implementations.Andy Polyakov
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-11chacha/asm/chacha-x86.pl: improve [backward] portability.Andy Polyakov
In order to minimize dependency on assembler version a number of post-SSE2 instructions are encoded manually. But in order to simplify the procedure only register operands are considered. Non-register operands are passed down to assembler. Module in question uses pshufb with memory operands, and old [GNU] assembler can't handle it. Fortunately in this case it's possible skip just the problematic segment without skipping SSSE3 support altogether. Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-11PPC assembler pack: add some PPC970/G5 performance data.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-11Fix the effect of no-dso in crypto/init.cRichard Levitte
When configured no-dso, there are no DSO_{whatever} macros defined. Therefore, before checking those, you have to check if OPENSSL_NO_DSO is defined. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1902)
2016-11-10Revert "Move algorithm specific ppccap code from crypto/ppccap.c"Richard Levitte
Now that we can link specifically with static libraries, the immediate need to split ppccap.c (and eventually other *cap.c files) is no more. This reverts commit e3fb4d3d52e188b83ccb8506aa2f16cb686f4d6c. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-10Don't set choice selector on parse failure.Dr. Stephen Henson
Don't set choice selector on parse failure: this can pass unexpected values to the choice callback. Instead free up partial structure directly. CVE-2016-7053 Thanks to Tyler Nighswander of ForAllSecure for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-10chacha20/poly1305: make sure to clear the buffer at correct positionRichard Levitte
The offset to the memory to clear was incorrect, causing a heap buffer overflow. CVE-2016-7054 Thanks to Robert Święcki for reporting this Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-10aes/asm/aesp8-ppc.pl: improve [backward] portability.Andy Polyakov
Some of stone-age assembler can't cope with r0 in address. It's actually sensible thing to do, because r0 is shunted to 0 in address arithmetic and by refusing r0 assembler effectively makes you understand that. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-10bn/asm/x86_64-mont.pl: fix for CVE-2016-7055 (Low severity).Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-09Following the changes to HKDF to accept a mode, add some tests for thisMatt Caswell
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-09Update HKDF to support separte Extract and Expand stepsMatt Caswell
At the moment you can only do an HKDF Extract and Expand in one go. For TLS1.3 we need to be able to do an Extract first, and the subsequently do a number of Expand steps on the same PRK. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-09Simplify and clean X509_VERIFY_PARAM new/free code.FdaSilvaYY
Split x509_verify_param_zero code to the right place Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-11-09Move algorithm specific ppccap code from crypto/ppccap.cRichard Levitte
Having that code in one central object file turned out to cause trouble when building test/modes_internal_test. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1883)
2016-11-08Missing BN_RECP_CTX field init.FdaSilvaYY
BN_RECP_CTX_new direclty use bn_init to avoid twice memset calls Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1879)
2016-11-08Zero stack variable with DSA nonceRich Salz
Thanks to Falko Strenzke for bringing this to our attention. Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1882)
2016-11-08Fix zlib BIO_METHOD for latest BIO_METHOD structure changesMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-11-07Allow null in X509_CRL_METHOD_freeFdaSilvaYY
and fix documentation. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1634)
2016-11-07Implement RSASSA-PKCS1-v1_5 as specified.David Benjamin
RFC 3447, section 8.2.2, steps 3 and 4 states that verifiers must encode the DigestInfo struct and then compare the result against the public key operation result. This implies that one and only one encoding is legal. OpenSSL instead parses with crypto/asn1, then checks that the encoding round-trips, and allows some variations for the parameter. Sufficient laxness in this area can allow signature forgeries, as described in https://www.imperialviolet.org/2014/09/26/pkcs1.html Although there aren't known attacks against OpenSSL's current scheme, this change makes OpenSSL implement the algorithm as specified. This avoids the uncertainty and, more importantly, helps grow a healthy ecosystem. Laxness beyond the spec, particularly in implementations which enjoy wide use, risks harm to the ecosystem for all. A signature producer which only tests against OpenSSL may not notice bugs and accidentally become widely deployed. Thus implementations have a responsibility to honor the specification as tightly as is practical. In some cases, the damage is permanent and the spec deviation and security risk becomes a tax all implementors must forever pay, but not here. Both BoringSSL and Go successfully implemented and deployed RSASSA-PKCS1-v1_5 as specified since their respective beginnings, so this change should be compatible enough to pin down in future OpenSSL releases. See also https://tools.ietf.org/html/draft-thomson-postel-was-wrong-00 As a bonus, by not having to deal with sign/verify differences, this version is also somewhat clearer. It also more consistently enforces digest lengths in the verify_recover codepath. The NID_md5_sha1 codepath wasn't quite doing this right. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1474
2016-11-04Fix style issues in HMAC_size()Matt Caswell
Based on review feedback. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-04Ensure HMAC_size() handles errors correctlyMatt Caswell
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-11-03Clean away remaining 'selftest' codeRichard Levitte
All of these don't compile cleanly any more, probably haven't for quite some time Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-03Convert mdc2 test print to internal testRichard Levitte
Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-03Convert x509 selftests to internal testRichard Levitte
Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-03Convert modes selftests (cts128 and gcm128) to internal testRichard Levitte
Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-03Convert asn1 selftests (a_strnid and ameth_lib) into internal testRichard Levitte
Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-03Convert poly1305 selftest into internal testRichard Levitte
Reviewed-by: Emilia Käsper <emilia@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1789)
2016-11-02Implement GET_MODULE_HANDLE_EX_FLAG_PIN for windowsMatt Caswell
Rather than leaking a reference, just call GetModuleHandleEx and pin the module on Windows. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-02Link using -znodeleteMatt Caswell
Instead of deliberately leaking a reference to ourselves, use nodelete which does this more neatly. Only for Linux at the moment. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-02Ensure that libcrypto and libssl do not unload until the process exitsMatt Caswell
Because we use atexit() to cleanup after ourselves, this will cause a problem if we have been dynamically loaded and then unloaded again: the atexit() handler may no longer be there. Most modern atexit() implementations can handle this, however there are still difficulties if libssl gets unloaded before libcrypto, because of the atexit() callback that libcrypto makes to libssl. The most robust solution seems to be to ensure that libcrypto and libssl never unload. This is done by simply deliberately leaking a dlopen() reference to them. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-02Add a DSO_dsobyaddr() functionMatt Caswell
This works the same way as DSO_pathbyaddr() but instead returns a ptr to the DSO that contains the provided symbol. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-11-02Partial revert of 3d8b2ec42 to add back DSO_pathbyaddrMatt Caswell
Commit 3d8b2ec42 removed various unused functions. However now we need to use one of them! This commit resurrects DSO_pathbyaddr(). We're not going to resurrect the Windows version though because what we need to achieve can be done a different way on Windows. Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-10-31sha/keccak1600.c: add couple of soft asserts.Andy Polyakov
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-29Try to unify BIO read/write parameter namesBenjamin Kaduk
After the recent reworking, not everything matched up, and some comments didn't catch up to the outl-->dlen and inl-->dlen renames that happened during the development of the recent patches. Try to make parameter names consistent across header, implementation, and manual pages. Also remove some trailing whitespace that was inadvertently introduced. Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1798)
2016-10-28Fix stdio build following BIO size_t workMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Fix more shadowed variable warningsMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Fix some feedback issues for BIO size_t-ifyMatt Caswell
Rename some parameters; add some error codes; fix a comment; etc Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Add some sanity checks for BIO_read* and BIO_getsMatt Caswell
Make sure the return value isn't bigger than the buffer len Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28More parameter naming of BIO_read*/BIO_write* related functionsMatt Caswell
Based on feedback received. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Tweaks based on review feedback of BIO size_t workMatt Caswell
Rename some parameters. Also change handling of buffer sizes >INT_MAX in length. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Ensure that BIO_read_ex() and BIO_write_ex() only return 0 or 1Matt Caswell
They should return 0 for a failure (retryable or not), and 1 for a success. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-10-28Read up to INT_MAX when calling legacy BIO_read() implementationsMatt Caswell
In converting a new style BIO_read() call into an old one, read as much data as we can (INT_MAX), if the size of the buffer is >INT_MAX. Reviewed-by: Richard Levitte <levitte@openssl.org>