summaryrefslogtreecommitdiffstats
path: root/crypto
AgeCommit message (Collapse)Author
2015-08-05RT3990: Fix #include path.Anton Blanchard
Signed-off-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-08-03Fix warning when compiling with no-ec2mMatt Caswell
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>
2015-07-31Only define PAGE_SIZE if not already defined.Ben Laurie
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-07-31Clear BN-mont values when free'ing it.Loganaden Velvindron
From a CloudFlare patch. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2015-07-29RT3774: double-free in DSAMartin Vejnar
Reviewed-by: Matt Caswell <matt@openssl.org>
2015-07-23rsaz_exp.h: align license with the rest of the contributionEmilia Kasper
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-07-22Some cleanups for crypto/bnRich Salz
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>
2015-07-20Rewrite crypto/ex_dataRich Salz
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>
2015-07-16Remove obsolete key formats.Rich Salz
Remove support for RSA_NET and Netscape key format (-keyform n). Also removed documentation of SGC. Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
2015-07-14Conversion to UTF-8 where neededRichard Levitte
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>
2015-07-07Extend -show_chain option to verify to show more infoMatt Caswell
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>
2015-07-07Reject calls to X509_verify_cert that have not been reinitialisedMatt Caswell
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>
2015-07-07Fix alternate chains certificate forgery issueMatt Caswell
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>
2015-07-06Relax CCM tag check.Dr. Stephen Henson
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>
2015-06-28Check dgram_sctp_write() return value.Kurt Roeckx
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-28Check BIO_dgram_sctp_wait_for_dry() return value for errorKurt Roeckx
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-25Don't output bogus errors in PKCS12_parseDr. Stephen Henson
PR#3923 Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-06-23Fix windows buildRich Salz
Move #include's inside the #ifdef. Reviewed-by: Matt Caswell <matt@openssl.org>
2015-06-23More secure storage of key material.Rich Salz
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>
2015-06-23Add $! to errors, use script basename.Rich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-06-23make updateRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-23Rearrange rsazRichard Levitte
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>
2015-06-21RT3917: add cleanup on an error pathRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-06-21Cleanup mttest.c : because we no longer use stdio here, don't include itRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Add -ldl to the build of mttest.cRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Cleanup mttest.c : use BIO_free only, no preceding hacksRichard Levitte
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>
2015-06-21Cleanup mttest.c : do not try to output reference counts when threads are doneRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Cleanup mttest.c : better error reporting when certs are migginsRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Cleanup mttest.c : make ssl_method a pointer to constRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Cleanup mttest.c : modernise outputRichard Levitte
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>
2015-06-21Cleanup mttest.c : modernise the threads setupRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-21Cleanup mttest.c : remove MS_CALLBACKRichard Levitte
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-16Make preprocessor error into real preprocessor errorRichard Levitte
Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2015-06-13Encode b == NULL or blen == 0 as zero.Dr. Stephen Henson
PR#3904 Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-12Fix ABI break with HMACMatt Caswell
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>
2015-06-11bn/bn_gf2m.c: avoid infinite loop wich malformed ECParamters.Andy Polyakov
CVE-2015-1788 Reviewed-by: Matt Caswell <matt@openssl.org>
2015-06-11PKCS#7: Fix NULL dereference with missing EncryptedContent.Emilia Kasper
CVE-2015-1790 Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-11Fix length checks in X509_cmp_time to avoid out-of-bounds reads.Emilia Kasper
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>
2015-06-11e_aes_cbc_hmac_sha*.c: address linker warning about OPENSSL_ia32cap_P size ↵Andy Polyakov
mismatch. Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-06-10gcm.c: address linker warning about OPENSSL_ia32cap_P size mismatch.Andy Polyakov
Reviewed-by: Rich Salz <rsalz@openssl.org>
2015-06-10Fix leak in HMAC error pathMatt Caswell
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>
2015-06-10EC_POINT_is_on_curve does not return a booleanMatt Caswell
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>
2015-06-10Change BIO_number_read and BIO_number_written() to be 64 bitMatt Caswell
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>
2015-06-10Fix memory leaks in BIO_dup_chain()Matt Caswell
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>
2015-06-10Replace memset with OPENSSL_clear_free()Matt Caswell
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>
2015-06-09Fix -DZLIB build for opaque COMP typesRich Salz
Reviewed-by: Richard Levitte <levitte@openssl.org>
2015-06-09No fprintf in the txt_db componentRich Salz
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>
2015-06-09Properly check certificate in case of export ciphers.Kurt Roeckx
Reviewed-by: Matt Caswell <matt@openssl.org> MR #588
2015-06-08return correct NID for undefined objectDr. Stephen Henson
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-06-08Use CRYPTO_memcmp when comparing authenticatorsEmilia Kasper
Pointed out by Victor Vasiliev (vasilvv@mit.edu) via Adam Langley (Google). Reviewed-by: Rich Salz <rsalz@openssl.org>