aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
Commit message (Collapse)AuthorAgeFilesLines
* RT3999: Remove sub-component version stringsRich Salz2015-08-1033-64/+0
| | | | | | Especially since after the #ifdef cleanups this is not useful. Reviewed-by: Matt Caswell <matt@openssl.org>
* RT3990: Fix #include path.Anton Blanchard2015-08-051-1/+1
| | | | | Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
* Fix warning when compiling with no-ec2mMatt Caswell2015-08-031-4/+8
| | | | | | | EC_KEY_set_public_key_affine_coordinates was using some variables that only apply if OPENSSL_NO_EC2M is not defined. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
* Only define PAGE_SIZE if not already defined.Ben Laurie2015-07-311-1/+3
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Clear BN-mont values when free'ing it.Loganaden Velvindron2015-07-311-3/+3
| | | | | | From a CloudFlare patch. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
* RT3774: double-free in DSAMartin Vejnar2015-07-291-0/+1
| | | | Reviewed-by: Matt Caswell <matt@openssl.org>
* rsaz_exp.h: align license with the rest of the contributionEmilia Kasper2015-07-231-28/+40
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Some cleanups for crypto/bnRich Salz2015-07-223-19/+20
| | | | | | | | | Create bn_free_d utility routine and use it. Fix RT3950 Also a missing cleanse, from Loganaden Velvindron (loganaden@gmail.com), who noticed it in a Cloudflare patch. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Rewrite crypto/ex_dataRich Salz2015-07-203-390/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Removed ability to set ex_data impl at runtime. This removed these three functions: const CRYPTO_EX_DATA_IMPL *CRYPTO_get_ex_data_implementation(void); int CRYPTO_set_ex_data_implementation(const CRYPTO_EX_DATA_IMPL *i); int CRYPTO_ex_data_new_class(void); It is no longer possible to change the ex_data implementation at runtime. (Luckily those functions were never documented :) Also removed the ability to add new exdata "classes." We don't believe this received much (if any) use, since you can't add it to OpenSSL objects, and there are probably better (native) methods for developers to add their own extensible data, if they really need that. Replaced the internal hash table (of per-"class" stacks) with a simple indexed array. Reserved an index for "app" application. Each API used to take the lock twice; now it only locks once. Use local stack storage for function pointers, rather than malloc, if possible (i.e., number of ex_data items is under a dozen). Make CRYPTO_EX_DATA_FUNCS opaque/internal. Also fixes RT3710; index zero is reserved. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Remove obsolete key formats.Rich Salz2015-07-165-321/+3
| | | | | | | | Remove support for RSA_NET and Netscape key format (-keyform n). Also removed documentation of SGC. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
* Conversion to UTF-8 where neededRichard Levitte2015-07-1425-88/+88
| | | | | | | | This leaves behind files with names ending with '.iso-8859-1'. These should be safe to remove. If something went wrong when re-encoding, there will be some files with names ending with '.utf8' left behind. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Extend -show_chain option to verify to show more infoMatt Caswell2015-07-071-0/+5
| | | | | | | | The -show_chain flag to the verify command line app shows information about the chain that has been built. This commit adds the text "untrusted" against those certificates that have been used from the untrusted list. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Reject calls to X509_verify_cert that have not been reinitialisedMatt Caswell2015-07-071-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function X509_verify_cert checks the value of |ctx->chain| at the beginning, and if it is NULL then it initialises it, along with the value of ctx->untrusted. The normal way to use X509_verify_cert() is to first call X509_STORE_CTX_init(); then set up various parameters etc; then call X509_verify_cert(); then check the results; and finally call X509_STORE_CTX_cleanup(). The initial call to X509_STORE_CTX_init() sets |ctx->chain| to NULL. The only place in the OpenSSL codebase where |ctx->chain| is set to anything other than a non NULL value is in X509_verify_cert itself. Therefore the only ways that |ctx->chain| could be non NULL on entry to X509_verify_cert is if one of the following occurs: 1) An application calls X509_verify_cert() twice without re-initialising in between. 2) An application reaches inside the X509_STORE_CTX structure and changes the value of |ctx->chain| directly. With regards to the second of these, we should discount this - it should not be supported to allow this. With regards to the first of these, the documentation is not exactly crystal clear, but the implication is that you must call X509_STORE_CTX_init() before each call to X509_verify_cert(). If you fail to do this then, at best, the results would be undefined. Calling X509_verify_cert() with |ctx->chain| set to a non NULL value is likely to have unexpected results, and could be dangerous. This commit changes the behaviour of X509_verify_cert() so that it causes an error if |ctx->chain| is anything other than NULL (because this indicates that we have not been initialised properly). It also clarifies the associated documentation. This is a follow up commit to CVE-2015-1793. Reviewed-by: Stephen Henson <steve@openssl.org>
* Fix alternate chains certificate forgery issueMatt Caswell2015-07-071-1/+1
| | | | | | | | | | | | | | | | | | | During certificate verfification, OpenSSL will attempt to find an alternative certificate chain if the first attempt to build such a chain fails. An error in the implementation of this logic can mean that an attacker could cause certain checks on untrusted certificates to be bypassed, such as the CA flag, enabling them to use a valid leaf certificate to act as a CA and "issue" an invalid certificate. This occurs where at least one cert is added to the first chain from the trust store, but that chain still ends up being untrusted. In that case ctx->last_untrusted is decremented in error. Patch provided by the BoringSSL project. CVE-2015-1793 Reviewed-by: Stephen Henson <steve@openssl.org>
* Relax CCM tag check.Dr. Stephen Henson2015-07-061-1/+1
| | | | | | | In CCM mode don't require a tag before initialising decrypt: this allows the tag length to be set without requiring the tag. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Check dgram_sctp_write() return value.Kurt Roeckx2015-06-281-1/+13
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Check BIO_dgram_sctp_wait_for_dry() return value for errorKurt Roeckx2015-06-281-10/+29
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Don't output bogus errors in PKCS12_parseDr. Stephen Henson2015-06-251-0/+2
| | | | | | PR#3923 Reviewed-by: Tim Hudson <tjh@openssl.org>
* Fix windows buildRich Salz2015-06-231-4/+4
| | | | | | Move #include's inside the #ifdef. Reviewed-by: Matt Caswell <matt@openssl.org>
* More secure storage of key material.Rich Salz2015-06-2316-66/+792
| | | | | | | | | Add secure heap for storage of private keys (when possible). Add BIO_s_secmem(), CBIGNUM, etc. Add BIO_CTX_secure_new so all BIGNUM's in the context are secure. Contributed by Akamai Technologies under the Corporate CLA. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Add $! to errors, use script basename.Rich Salz2015-06-231-5/+4
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* make updateRichard Levitte2015-06-231-1/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Rearrange rsazRichard Levitte2015-06-233-8/+21
| | | | | | | | | | A small rearrangement so the inclusion of rsaz_exp.h would be unconditional, but what that header defines becomes conditional. This solves the weirdness where rsaz_exp.h gets in and out of the dependency list for bn_exp.c, depending on the present architecture. Reviewed-by: Rich Salz <rsalz@openssl.org>
* RT3917: add cleanup on an error pathRich Salz2015-06-211-1/+2
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* Cleanup mttest.c : because we no longer use stdio here, don't include itRichard Levitte2015-06-211-1/+0
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Add -ldl to the build of mttest.cRichard Levitte2015-06-211-2/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : use BIO_free only, no preceding hacksRichard Levitte2015-06-211-0/+2
| | | | | | | Since [sc]_ssl->[rw]bio aren't available, do not try to fiddle with them. Surely, a BIO_free on the "main" BIOs should be enough Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : do not try to output reference counts when threads are doneRichard Levitte2015-06-211-0/+16
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : better error reporting when certs are migginsRichard Levitte2015-06-211-0/+3
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : make ssl_method a pointer to constRichard Levitte2015-06-211-1/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : modernise outputRichard Levitte2015-06-211-96/+91
| | | | | | | | | | Construct bio_err and bio_stdout from file handles instead of FILE pointers, since the latter might not be implemented (when OPENSSL_NO_STDIO is defined). Convert all output to use BIO_printf. Change lh_foo to lh_SSL_SESSION_foo. Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : modernise the threads setupRichard Levitte2015-06-211-50/+41
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Cleanup mttest.c : remove MS_CALLBACKRichard Levitte2015-06-211-2/+2
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Make preprocessor error into real preprocessor errorRichard Levitte2015-06-161-1/+1
| | | | Reviewed-by: Kurt Roeckx <kurt@openssl.org>
* Encode b == NULL or blen == 0 as zero.Dr. Stephen Henson2015-06-131-2/+2
| | | | | | PR#3904 Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix ABI break with HMACMatt Caswell2015-06-121-12/+8
| | | | | | | | | Recent HMAC changes broke ABI compatibility due to a new field in HMAC_CTX. This backs that change out, and does it a different way. Thanks to Timo Teras for the concept. Reviewed-by: Richard Levitte <levitte@openssl.org>
* bn/bn_gf2m.c: avoid infinite loop wich malformed ECParamters.Andy Polyakov2015-06-111-5/+10
| | | | | | CVE-2015-1788 Reviewed-by: Matt Caswell <matt@openssl.org>
* PKCS#7: Fix NULL dereference with missing EncryptedContent.Emilia Kasper2015-06-111-1/+15
| | | | | | CVE-2015-1790 Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix length checks in X509_cmp_time to avoid out-of-bounds reads.Emilia Kasper2015-06-111-10/+47
| | | | | | | | | | Also tighten X509_cmp_time to reject more than three fractional seconds in the time; and to reject trailing garbage after the offset. CVE-2015-1789 Reviewed-by: Viktor Dukhovni <viktor@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org>
* e_aes_cbc_hmac_sha*.c: address linker warning about OPENSSL_ia32cap_P size ↵Andy Polyakov2015-06-112-2/+2
| | | | | | mismatch. Reviewed-by: Tim Hudson <tjh@openssl.org>
* gcm.c: address linker warning about OPENSSL_ia32cap_P size mismatch.Andy Polyakov2015-06-101-1/+1
| | | | Reviewed-by: Rich Salz <rsalz@openssl.org>
* Fix leak in HMAC error pathMatt Caswell2015-06-101-0/+1
| | | | | | | | | In the event of an error in the HMAC function, leaks can occur because the HMAC_CTX does not get cleaned up. Thanks to the BoringSSL project for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org>
* EC_POINT_is_on_curve does not return a booleanMatt Caswell2015-06-105-4/+11
| | | | | | | | | | | The function EC_POINT_is_on_curve does not return a boolean value. It returns 1 if the point is on the curve, 0 if it is not, and -1 on error. Many usages within OpenSSL were incorrectly using this function and therefore not correctly handling error conditions. With thanks to the Open Crypto Audit Project for reporting this issue. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
* Change BIO_number_read and BIO_number_written() to be 64 bitMatt Caswell2015-06-101-5/+5
| | | | | | | | | | | | The return type of BIO_number_read() and BIO_number_written() as well as the corresponding num_read and num_write members in the BIO structure has been changed from unsigned long to uint64_t. On platforms where an unsigned long is 32 bits (e.g. Windows) these counters could overflow if >4Gb is transferred. With thanks to the Open Crypto Audit Project for reporting this issue. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Fix memory leaks in BIO_dup_chain()Matt Caswell2015-06-101-2/+5
| | | | | | | | | | | This fixes a memory leak that can occur whilst duplicating a BIO chain if the call to CRYPTO_dup_ex_data() fails. It also fixes a second memory leak where if a failure occurs after successfully creating the first BIO in the chain, then the beginning of the new chain was not freed. With thanks to the Open Crypto Audit Project for reporting this issue. Reviewed-by: Stephen Henson <steve@openssl.org>
* Replace memset with OPENSSL_clear_free()Matt Caswell2015-06-101-2/+1
| | | | | | | | | | BUF_MEM_free() attempts to cleanse memory using memset immediately prior to a free. This is at risk of being optimised away by the compiler, so replace with a call to OPENSSL_clear_free() instead. With thanks to the Open Crypto Audit Project for reporting this issue. Reviewed-by: Stephen Henson <steve@openssl.org>
* Fix -DZLIB build for opaque COMP typesRich Salz2015-06-092-42/+10
| | | | Reviewed-by: Richard Levitte <levitte@openssl.org>
* No fprintf in the txt_db componentRich Salz2015-06-093-206/+1
| | | | | | | Also removed a source file that isn't built, and moved another one to test for eventual fixing. Reviewed-by: Richard Levitte <levitte@openssl.org>
* Properly check certificate in case of export ciphers.Kurt Roeckx2015-06-092-0/+10
| | | | | Reviewed-by: Matt Caswell <matt@openssl.org> MR #588
* return correct NID for undefined objectDr. Stephen Henson2015-06-081-0/+3
| | | | Reviewed-by: Tim Hudson <tjh@openssl.org>