summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2015-05-23Fix the update target and remove duplicate file updatesRichard Levitte
We had updates of certain header files in both Makefile.org and the Makefile in the directory the header file lived in. This is error prone and also sometimes generates slightly different results (usually just a comment that differs) depending on which way the update was done. This removes the file update targets from the top level Makefile, adds an update: target in all Makefiles and has it depend on the depend: or local_depend: targets, whichever is appropriate, so we don't get a double run through the whole file tree. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 0f539dc1a2f45580435c39dada44dd276e79cb88) Conflicts: Makefile.org apps/Makefile test/Makefile
2015-05-22Fix off-by-one in BN_randMatt Caswell
If BN_rand is called with |bits| set to 1 and |top| set to 1 then a 1 byte buffer overflow can occur. There are no such instances within the OpenSSL at the moment. Thanks to Mateusz Kocielski (LogicalTrust), Marek Kroemeke, Filip Palian for discovering and reporting this issue. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2015-05-22Reject negative shifts for BN_rshift and BN_lshiftMatt Caswell
The functions BN_rshift and BN_lshift shift their arguments to the right or left by a specified number of bits. Unpredicatable results (including crashes) can occur if a negative number is supplied for the shift value. Thanks to Mateusz Kocielski (LogicalTrust), Marek Kroemeke and Filip Palian for discovering and reporting this issue. Reviewed-by: Kurt Roeckx <kurt@openssl.org> (cherry picked from commit 7cc18d8158b5fc2676393d99b51c30c135502107) Conflicts: crypto/bn/bn.h crypto/bn/bn_err.c
2015-05-20Add flag to inhibit checking for alternate certificate chains. Setting this ↵Matt Caswell
behaviour will force behaviour as per previous versions of OpenSSL Reviewed-by: Dr. Stephen Henson <steve@openssl.org> Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
2015-05-20In certain situations the server provided certificate chain may no longer be ↵Matt Caswell
valid. However the issuer of the leaf, or some intermediate cert is in fact in the trust store. When building a trust chain if the first attempt fails, then try to see if alternate chains could be constructed that are trusted. RT3637 RT3621 Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
2015-05-20Correctly check for export size limitKurt Roeckx
40 bit ciphers are limited to 512 bit RSA, 56 bit ciphers to 1024 bit. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit ac38115c1a4fb61c66c2a8cd2a9800751828d328)
2015-05-13Add NULL checks from masterRich Salz
The big "don't check for NULL" cleanup requires backporting some of the lowest-level functions to actually do nothing if NULL is given. This will make it easier to backport fixes to release branches, where master assumes those lower-level functions are "safe" This commit addresses those tickets: 3798 3799 3801. Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit f34b095fab1569d093b639bfcc9a77d6020148ff)
2015-05-13Call of memcmp with null pointers in obj_cmp()Hanno Böck
The function obj_cmp() (file crypto/objects/obj_dat.c) can in some situations call memcmp() with a null pointer and a zero length. This is invalid behaviour. When compiling openssl with undefined behaviour sanitizer (add -fsanitize=undefined to compile flags) this can be seen. One example that triggers this behaviour is the pkcs7 command (but there are others, e.g. I've seen it with the timestamp function): apps/openssl pkcs7 -in test/testp7.pem What happens is that obj_cmp takes objects of the type ASN1_OBJECT and passes their ->data pointer to memcmp. Zero-sized ASN1_OBJECT structures can have a null pointer as data. RT#3816 Signed-off-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 2b8dc08b74fc3c6d4c2fc855cc23bac691d985be)
2015-05-11Add missing NULL check in X509V3_parse_list()Kurt Cancemi
Matt's note: I added a call to X509V3err to Kurt's original patch. RT#3840 Signed-off-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 344c271eb339fc2982e9a3584a94e51112d84584)
2015-05-02RT3820: Don't call GetDesktopWindow()Gilles Khouzam
Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit bed2edf1cb73f1fe2c11029acc694086bc14443e)
2015-04-30Fix buffer overrun in RSA signingMatt Caswell
The problem occurs in EVP_PKEY_sign() when using RSA with X931 padding. It is only triggered if the RSA key size is smaller than the digest length. So with SHA512 you can trigger the overflow with anything less than an RSA 512 bit key. I managed to trigger a 62 byte overflow when using a 16 bit RSA key. This wasn't sufficient to cause a crash, although your mileage may vary. In practice RSA keys of this length are never used and X931 padding is very rare. Even if someone did use an excessively short RSA key, the chances of them combining that with a longer digest and X931 padding is very small. For these reasons I do not believe there is a security implication to this. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 34166d41892643a36ad2d1f53cc0025e2edc2a39)
2015-04-30Add sanity check to print_bin functionMatt Caswell
Add a sanity check to the print_bin function to ensure that the |off| argument is positive. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 3deeeeb61b0c5b9b5f0993a67b7967d2f85186da)
2015-04-30Clarify logic in BIO_*printf functionsMatt Caswell
The static function dynamically allocates an output buffer if the output grows larger than the static buffer that is normally used. The original logic implied that |currlen| could be greater than |maxlen| which is incorrect (and if so would cause a buffer overrun). Also the original logic would call OPENSSL_malloc to create a dynamic buffer equal to the size of the static buffer, and then immediately call OPENSSL_realloc to make it bigger, rather than just creating a buffer than was big enough in the first place. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 9d9e37744cd5119f9921315864d1cd28717173cd)
2015-04-30Sanity check EVP_EncodeUpdate buffer lenMatt Caswell
There was already a sanity check to ensure the passed buffer length is not zero. Extend this to ensure that it also not negative. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit b86d7dca69f5c80abd60896c8ed3039fc56210cc)
2015-04-30Sanity check EVP_CTRL_AEAD_TLS_AADMatt Caswell
The various implementations of EVP_CTRL_AEAD_TLS_AAD expect a buffer of at least 13 bytes long. Add sanity checks to ensure that the length is at least that. Also add a new constant (EVP_AEAD_TLS1_AAD_LEN) to evp.h to represent this length. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit c8269881093324b881b81472be037055571f73f3) Conflicts: ssl/record/ssl3_record.c Conflicts: apps/speed.c crypto/evp/e_aes_cbc_hmac_sha256.c crypto/evp/evp.h
2015-04-30Sanity check DES_enc_write buffer lengthMatt Caswell
Add a sanity check to DES_enc_write to ensure the buffer length provided is not negative. Thanks to Kevin Wojtysiak (Int3 Solutions) and Paramjot Oberoi (Int3 Solutions) for reporting this issue. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 873fb39f20b6763daba226b74e83fb194924c7bf)
2015-04-22Fix CRYPTO_strdupLoganaden Velvindron
The function CRYPTO_strdup (aka OPENSSL_strdup) fails to check the return value from CRYPTO_malloc to see if it is NULL before attempting to use it. This patch adds a NULL check. RT3786 Signed-off-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 37b0cf936744d9edb99b5dd82cae78a7eac6ad60) Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 20d21389c8b6f5b754573ffb6a4dc4f3986f2ca4)
2015-04-18Fix encoding bug in i2c_ASN1_INTEGERDr. Stephen Henson
Fix bug where i2c_ASN1_INTEGER mishandles zero if it is marked as negative. Thanks to Huzaifa Sidhpurwala <huzaifas@redhat.com> and Hanno Böck <hanno@hboeck.de> for reporting this issue. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit a0eed48d37a4b7beea0c966caf09ad46f4a92a44)
2015-04-16Code style: space after 'if'Viktor Dukhovni
Reviewed-by: Matt Caswell <gitlab@openssl.org>
2015-04-16Please Clang's sanitizer, addendum.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-04-16Limit depth of nested sequences when generating ASN.1Dr. Stephen Henson
Reported by Hanno Böck <hanno@hboeck.de> PR#3800 Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit c4137b5e828d8fab0b244defb79257619dad8fc7)
2015-04-16Reject empty generation strings.Dr. Stephen Henson
Reported by Hanno Böck <hanno@hboeck.de> Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 111b60bea01d234b5873488c19ff2b9c5d4d58e9)
2015-04-11do_dirname: Don't change gen on failuresKurt Roeckx
It would set gen->d.dirn to a freed pointer in case X509V3_NAME_from_section failed. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 8ec5c5dd361343d9017eff8547b19e86e4944ebc)
2015-04-11X509_VERIFY_PARAM_free: Check param for NULLKurt Roeckx
Reviewed-by: Viktor Dukhovni <openssl-users@dukhovni.org> (cherry picked from commit f49baeff50d0be9c8d86aed6fb4a08841aa3da41)
2015-04-10Don't set *pval to NULL in ASN1_item_ex_new.Dr. Stephen Henson
While *pval is usually a pointer in rare circumstances it can be a long value. One some platforms (e.g. WIN64) where sizeof(long) < sizeof(ASN1_VALUE *) this will write past the field. *pval is initialised correctly in the rest of ASN1_item_ex_new so setting it to NULL is unecessary anyway. Thanks to Julien Kauffmann for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit f617b4969a9261b9d7d381670aefbe2cf766a2cb) Conflicts: crypto/asn1/tasn_new.c
2015-03-31Ensure EC private keys retain leading zerosDouglas E Engert
RFC5915 requires the use of the I2OSP primitive as defined in RFC3447 for storing an EC Private Key. This converts the private key into an OCTETSTRING and retains any leading zeros. This commit ensures that those leading zeros are present if required. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 30cd4ff294252c4b6a4b69cbef6a5b4117705d22) Conflicts: crypto/ec/ec_asn1.c
2015-03-25Fix uninitialized variable warningEmilia Kasper
While a true positive, it's almost harmless because EVP_DecryptInit_ex would have to fail and that doesn't happen under normal operation. Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-25Fix HMAC to pass invalid key len testMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-25Add HMAC test for invalid key lenMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-25Ensure that both the MD and key have been initialised before attempting toMatt Caswell
create an HMAC Inspired by BoringSSL commit 2fe7f2d0d9a6fcc75b4e594eeec306cc55acd594 Reviewed-by: Richard Levitte <levitte@openssl.org> Conflicts: crypto/hmac/hmac.c
2015-03-25Add more HMAC testsMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-25Fix RAND_(pseudo_)?_bytes returnsMatt Caswell
Ensure all calls to RAND_bytes and RAND_pseudo_bytes have their return value checked correctly Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 8f8e4e4f5253085ab673bb74094c3e492c56af44) Conflicts: crypto/evp/e_des3.c
2015-03-24Make OCSP response verification more flexible.Dr. Stephen Henson
If a set of certificates is supplied to OCSP_basic_verify use those in addition to any present in the OCSP response as untrusted CAs when verifying a certificate chain. PR#3668 Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 4ca5efc2874e094d6382b30416824eda6dde52fe)
2015-03-24Fix malloc define typoMike Frysinger
Fix compilation failure when SCTP is compiled due to incorrect define. Reported-by: Conrad Kostecki <ck+gentoobugzilla@bl4ckb0x.de> URL: https://bugs.gentoo.org/543828 RT#3758 Signed-off-by: Matt Caswell <matt@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> (cherry picked from commit 7c82e339a677f8546e1456c7a8f6788598a9de43)
2015-03-19Prepare for 1.0.1n-devMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19Prepare for 1.0.1m releaseOpenSSL_1_0_1mMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19make updateMatt Caswell
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19Fix a failure to NULL a pointer freed on error.Matt Caswell
Reported by the LibreSSL project as a follow on to CVE-2015-0209 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-19PKCS#7: avoid NULL pointer dereferences with missing contentEmilia Kasper
In PKCS#7, the ASN.1 content component is optional. This typically applies to inner content (detached signatures), however we must also handle unexpected missing outer content correctly. This patch only addresses functions reachable from parsing, decryption and verification, and functions otherwise associated with reading potentially untrusted data. Correcting all low-level API calls requires further work. CVE-2015-0289 Thanks to Michal Zalewski (Google) for reporting this issue. Reviewed-by: Steve Henson <steve@openssl.org>
2015-03-19Fix ASN1_TYPE_cmpDr. Stephen Henson
Fix segmentation violation when ASN1_TYPE_cmp is passed a boolean type. This can be triggered during certificate verification so could be a DoS attack against a client or a server enabling client authentication. CVE-2015-0286 Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-03-18Free up ADB and CHOICE if already initialised.Dr. Stephen Henson
CVE-2015-0287 Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
2015-03-17Remove dead code from cryptoMatt Caswell
Some miscellaneous removal of dead code from lib crypto. Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit b7573c597c1932ef709b2455ffab47348b5c54e5)
2015-03-17Fix memset call in stack.cMatt Caswell
The function sk_zero is supposed to zero the elements held within a stack. It uses memset to do this. However it calculates the size of each element as being sizeof(char **) instead of sizeof(char *). This probably doesn't make much practical difference in most cases, but isn't a portable assumption. Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 7132ac830fa08d9a936e011d7c541b0c52115b33)
2015-03-14Avoid reading an unused byte after the bufferAndy Polyakov
Other curves don't have this problem. Reviewed-by: Kurt Roeckx <kurt@roeckx.be> Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 9fbbdd73c58c29dc46cc314f7165e45e6d43fd60)
2015-03-13Fix undefined behaviour in shifts.Emilia Kasper
Td4 and Te4 are arrays of u8. A u8 << int promotes the u8 to an int first then shifts. If the mathematical result of a shift (as modelled by lhs * 2^{rhs}) is not representable in an integer, behaviour is undefined. In other words, you can't shift into the sign bit of a signed integer. Fix this by casting to u32 whenever we're shifting left by 24. (For consistency, cast other shifts, too.) Caught by -fsanitize=shift Submitted by Nick Lewycky (Google) Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 8b37e5c14f0eddb10c7f91ef91004622d90ef361)
2015-03-12ASN.1 print fix.Dr. Stephen Henson
When printing out an ASN.1 structure if the type is an item template don't fall thru and attempt to interpret as a primitive type. Reviewed-by: Andy Polyakov <appro@openssl.org> (cherry picked from commit 5dc1247a7494f50c88ce7492518bbe0ce6f124fa)
2015-03-12Fix missing return checks in v3_cpols.cMatt Caswell
Fixed assorted missing return value checks in c3_cpols.c Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit c5f2b5336ab72e40ab91e2ca85639f51fa3178c6)
2015-03-12Fix dsa_pub_encodeMatt Caswell
The return value from ASN1_STRING_new() was not being checked which could lead to a NULL deref in the event of a malloc failure. Also fixed a mem leak in the error path. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 0c7ca4033dcf5398334d4b78a7dfb941c8167a40)
2015-03-12Fix dh_pub_encodeMatt Caswell
The return value from ASN1_STRING_new() was not being checked which could lead to a NULL deref in the event of a malloc failure. Also fixed a mem leak in the error path. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 6aa8dab2bbfd5ad3cfc0d07fe5d7243635d5b2a2) Conflicts: crypto/dh/dh_ameth.c
2015-03-12Fix asn1_item_print_ctxMatt Caswell
The call to asn1_do_adb can return NULL on error, so we should check the return value before attempting to use it. Reviewed-by: Rich Salz <rsalz@openssl.org> (cherry picked from commit 34a7ed0c39aa3ab67eea1e106577525eaf0d7a00)