summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2016-02-29Fix BN_hex2bn/BN_dec2bn NULL ptr/heap corruptionMatt Caswell
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>
2016-02-29remove unused variablesDr. Stephen Henson
Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-29Clarify ASYNC_WAIT_CTX_clear_fd() docsMatt Caswell
Clarify that the "cleanup" routing does not get called if you invoke ASYNC_WAIT_CTX_clear_fd() directly. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-29Refactor the async wait fd logicMatt Caswell
Implementation experience has shown that the original plan for async wait fds was too simplistic. Originally the async logic created a pipe internally and user/engine code could then get access to it via API calls. It is more flexible if the engine is able to create its own fd and provide it to the async code. Another issue is that there can be a lot of churn in the fd value within the context of (say) a single SSL connection leading to continually adding and removing fds from (say) epoll. It is better if we can provide some stability of the fd value across a whole SSL connection. This is problematic because an engine has no concept of an SSL connection. This commit refactors things to introduce an ASYNC_WAIT_CTX which acts as a proxy for an SSL connection down at the engine layer. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-28Remove unused code.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Change BORINGSSL defines to OPENSSLDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Initial adaptations for Curve25519 code.Dr. Stephen Henson
Fix "mixed declarations and code" warnings. Use OpenSSL headers. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Place under OpenSSL license.Emilia Kasper
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Stephen Henson <steve@openssl.org>
2016-02-28Add X25519 code from BoringSSL.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28TLS support for X25519Dr. Stephen Henson
Add X25519 to TLS supported curve list. Reject attempts to configure keys which cannot be used for signing. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Add X25519 curve to listDr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Add no signing flag.Dr. Stephen Henson
Add a flag to EC_METHOD for curves which do not support signing. New function EC_KEY_can_sign() returns 1 is key can be used for signing. Return an explicit error is an attempt is made to sign with no signing curves. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Add new EC_METHOD for X25519.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Add group_order_bits to EC_METHOD.Dr. Stephen Henson
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Add custom_data field for EC_POINT, EC_KEY.Dr. Stephen Henson
In some cases the EC_POINT and EC_KEY BIGNUM components are suboptimal or inappropriate. Add an "custom_data" field which curves can populate with a custom structure to suit their needs. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Extract compression form in EC_KEY_oct2key().Dr. Stephen Henson
Extract compression form in EC_KEY_oct2key() instead of manually in the ASN.1 code. For custom curves do not assume the initial octet is the compression form: it isn't for X25519 et al. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Extended EC_METHOD customisation support.Dr. Stephen Henson
Add support for optional overrides of various private key operations in EC_METHOD. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28EC_METHOD customisation operations.Dr. Stephen Henson
Extend EC_METHOD to permit additional customisation of private key and ECDH operations. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28Rename OIDs.Dr. Stephen Henson
Use standard X25519 and X448 names for OIDs. Delete EdDSA OIDs: for now they wont be used and EdDSA may use a different format. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2016-02-28GH715: Missed some null-check-removals. follow commits 412bafdcf5, and ↵FdaSilvaYY
7c96dbcdab Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-28GH715: Missed some null-check-removals.Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-27modes/asm/ghash-x86_64.pl: refine GNU assembler version detection.Andy Polyakov
Even though AVX support was added in GAS 2.19 vpclmulqdq was apparently added in 2.20. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-27chacha/asm/chacha-*.pl: fix typos in tail processing.Andy Polyakov
RT#4323 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-27GH753: More spelling fixFdaSilvaYY
Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-26Fix for potential deferencing of null pointer in o2i_SCT_signatureRob Percival
Reviewed-by: Ben Laurie <ben@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26Public API for Certificate TransparencyRob Percival
Reviewed-by: Ben Laurie <ben@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26Revert "EC_KEY_priv2buf (): check parameter sanity"Rich Salz
This reverts commit acae59bb29ddc769743ab4a8ae373b5ff2f42b57. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2016-02-26Fix master compile errorMatt Caswell
Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26GH680: Reuse strnlen() in strndup()Dmitry-Me
Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-02-26EC_KEY_priv2buf (): check parameter sanityJ Mohan Rao Arisankala
In EC_KEY_priv2buf(), check for pbuf sanity. If invoked with NULL, gracefully returns the key length. Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-02-26check with NULLJ Mohan Rao Arisankala
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26explicit check for NULLJ Mohan Rao Arisankala
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26Check method before access and release ctx in error pathsJ Mohan Rao Arisankala
- In error paths, EVP_MD_CTX allocated by the callee is not released. - Checking method before accessing Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-26RT4335: Fix UEFI build of OBJ_NAME_new_index()David Woodhouse
We are using strcmp() as the cmp_func, where in the EDK2 environment strcmp actually ends up being the external AsciiStrCmp() function — an EFI library function defined with the Microsoft ABI. This means that we can't just assign function pointers to it, since in GCC-hosted builds the ABI of any function *not* explicitly marked EFIAPI is the native SysV ABI. Arguably this stupidity ought to be resolved on the UEFI side, but in the general case that would mean that we need to provide ABI-compatible wrappers for *all* the "standard" functions, just in case they're used like this. And in fact we already have a workaround here for DEC C. So instead of playing games with casting function pointers, it's nicer just to use a simple function to wrap the strcmp() call. That cleans up the DEC C workaround, *and* it works around the UEFI bogosity at the same time. Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2016-02-26Implement new multi-threading APIAlessandro Ghedini
Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
2016-02-25Fix memory issues in BIO_*printf functionsMatt Caswell
The internal |fmtstr| function used in processing a "%s" format string in the BIO_*printf functions could overflow while calculating the length of a string and cause an OOB read when printing very long strings. Additionally the internal |doapr_outch| function can attempt to write to an OOB memory location (at an offset from the NULL pointer) in the event of a memory allocation failure. In 1.0.2 and below this could be caused where the size of a buffer to be allocated is greater than INT_MAX. E.g. this could be in processing a very long "%s" format string. Memory leaks can also occur. These issues will only occur on certain platforms where sizeof(size_t) > sizeof(int). E.g. many 64 bit systems. The first issue may mask the second issue dependent on compiler behaviour. These problems could enable attacks where large amounts of untrusted data is passed to the BIO_*printf functions. If applications use these functions in this way then they could be vulnerable. OpenSSL itself uses these functions when printing out human-readable dumps of ASN.1 data. Therefore applications that print this data could be vulnerable if the data is from untrusted sources. OpenSSL command line applications could also be vulnerable where they print out ASN.1 data, or if untrusted data is passed as command line arguments. Libssl is not considered directly vulnerable. Additionally certificates etc received via remote connections via libssl are also unlikely to be able to trigger these issues because of message size limits enforced within libssl. CVE-2016-0799 Issue reported by Guido Vranken. Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-02-25GH715: ENGINE_finish can take NULLRich Salz
Simplifies calling code. Also fixed up any !ptr tests that were nearby, turning them into NULL tests. Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-25Fix unified build after CT reorgRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-25Add more CT utility routines to be used as part of larger patch.Adam Eijdenberg
Reviewed-by: Ben Laurie <ben@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-25Build fix: remove cleanse_ctrRich Salz
Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-02-25RT4116: Change cleanse to just memsetRich Salz
See also the discussion in https://github.com/openssl/openssl/pull/455 Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-02-25CVE-2016-0798: avoid memory leak in SRPEmilia Kasper
The SRP user database lookup method SRP_VBASE_get_by_user had confusing memory management semantics; the returned pointer was sometimes newly allocated, and sometimes owned by the callee. The calling code has no way of distinguishing these two cases. Specifically, SRP servers that configure a secret seed to hide valid login information are vulnerable to a memory leak: an attacker connecting with an invalid username can cause a memory leak of around 300 bytes per connection. Servers that do not configure SRP, or configure SRP but do not configure a seed are not vulnerable. In Apache, the seed directive is known as SSLSRPUnknownUserSeed. To mitigate the memory leak, the seed handling in SRP_VBASE_get_by_user is now disabled even if the user has configured a seed. Applications are advised to migrate to SRP_VBASE_get1_by_user. However, note that OpenSSL makes no strong guarantees about the indistinguishability of valid and invalid logins. In particular, computations are currently not carried out in constant time. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-24GH480: Don't break statements with CPP stuff.Flavio Medeiros
This is also RT 4137 Signed-off-by: Rich Salz <rsalz@akamai.com> Reviewed-by: Andy Polyakov <appro@openssl.org>
2016-02-23ec/asm/ecp_nistz256-*.pl: get corner case logic right.Andy Polyakov
RT#4284 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-23ec/asm/ecp_nistz256-x86_64.pl: get corner case logic right.Andy Polyakov
RT#4284 Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-23poly1305/asm/poly1305-armv4.pl: replace ambiguous instruction.Andy Polyakov
Different assembler versions disagree on how to interpret #-1 as argument to vmov.i64, as 0xffffffffffffffff or 0x00000000ffffffff. So replace it with something they can't disagree on. Reviewed-by: Rich Salz <rsalz@openssl.org>
2016-02-23RT4339: Fix handling of <internal/bn_conf.h>David Woodhouse
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>
2016-02-23Add PKCS7_NO_DUAL_CONTENT flagRich Salz
Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
2016-02-22Remove unused parameters from internal functionsRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2016-02-22GH678: Add a few more zallocFdaSilvaYY
Remove some duplicated NULL/zero init. Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>