summaryrefslogtreecommitdiffstats
path: root/crypto/x509
AgeCommit message (Collapse)Author
2016-01-04Fix X509_STORE_CTX_cleanup()Viktor Dukhovni
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2015-10-23Remove useless codeAlessandro Ghedini
RT#4081 Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (cherry picked from commit 070c23325af4526c9a8532a60d63522c58d5554b)
2015-10-09Avoid SHA1 weaknessRich Salz
In X509_cmp, if cert digest is equal, look at DER of the signed part. This is what master and 1.0.2 already do. Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
2015-09-15RT4044: Remove .cvsignore files.Rich Salz
Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 3be39dc1e3378d79531e385a72051c4dc5c6b34d)
2015-07-07Fix alt chains bugMatt Caswell
This is a follow up to the alternate chains certificate forgery issue (CVE-2015-1793). That issue is exacerbated in 1.0.1 by a related bug which means that we *always* check for an alternative chain, even if we have already found a chain. The code is supposed to stop as soon as it has found one (and does do in master and 1.0.2). Reviewed-by: Stephen Henson <steve@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-07Add test for CVE-2015-1793Matt Caswell
This adds a test for CVE-2015-1793. This adds a new test file verify_extra_test.c, which could form the basis for additional verification tests. Reviewed-by: Stephen Henson <steve@openssl.org> Conflicts: test/Makefile
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-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-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-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-04-11X509_VERIFY_PARAM_free: Check param for NULLKurt Roeckx
Reviewed-by: Viktor Dukhovni <openssl-users@dukhovni.org> (cherry picked from commit f49baeff50d0be9c8d86aed6fb4a08841aa3da41)
2015-03-02Check public key is not NULL.Dr. Stephen Henson
CVE-2015-0288 PR#3708 Reviewed-by: Matt Caswell <matt@openssl.org> (cherry picked from commit 28a00bcd8e318da18031b2ac8778c64147cd54f9)
2015-01-22Re-align some comments after running the reformat script.OpenSSL_1_0_1-post-reformatMatt Caswell
This should be a one off operation (subsequent invokation of the script should not move them) This commit is for the 1.0.1 changes Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Run util/openssl-format-source -v -c .Matt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Move more comments that confuse indentMatt Caswell
Conflicts: crypto/dsa/dsa.h demos/engines/ibmca/hw_ibmca.c ssl/ssl_locl.h Conflicts: crypto/bn/rsaz_exp.c crypto/evp/e_aes_cbc_hmac_sha1.c crypto/evp/e_aes_cbc_hmac_sha256.c ssl/ssl_locl.h Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22indent has problems with comments that are on the right hand side of a line.Matt Caswell
Sometimes it fails to format them very well, and sometimes it corrupts them! This commit moves some particularly problematic ones. Conflicts: crypto/bn/bn.h crypto/ec/ec_lcl.h crypto/rsa/rsa.h demos/engines/ibmca/hw_ibmca.c ssl/ssl.h ssl/ssl3.h Conflicts: crypto/ec/ec_lcl.h ssl/tls1.h Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Fix indent issue with functions using STACK_OFMatt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22Further comment changes for reformatMatt Caswell
Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-22mark all block comments that need format preserving so thatTim Hudson
indent will not alter them when reformatting comments (cherry picked from commit 1d97c8435171a7af575f73c526d79e1ef0ee5960) Conflicts: crypto/bn/bn_lcl.h crypto/bn/bn_prime.c crypto/engine/eng_all.c crypto/rc4/rc4_utl.c crypto/sha/sha.h ssl/kssl.c ssl/t1_lib.c Conflicts: crypto/rc4/rc4_enc.c crypto/x509v3/v3_scts.c crypto/x509v3/v3nametest.c ssl/d1_both.c ssl/s3_srvr.c ssl/ssl.h ssl/ssl_locl.h ssl/ssltest.c ssl/t1_lib.c Reviewed-by: Tim Hudson <tjh@openssl.org>
2015-01-05Constify ASN1_TYPE_cmp add X509_ALGOR_cmp.Dr. Stephen Henson
Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 4c52816d35681c0533c25fdd3abb4b7c6962302d)
2015-01-05Fix various certificate fingerprint issues.Dr. Stephen Henson
By using non-DER or invalid encodings outside the signed portion of a certificate the fingerprint can be changed without breaking the signature. Although no details of the signed portion of the certificate can be changed this can cause problems with some applications: e.g. those using the certificate fingerprint for blacklists. 1. Reject signatures with non zero unused bits. If the BIT STRING containing the signature has non zero unused bits reject the signature. All current signature algorithms require zero unused bits. 2. Check certificate algorithm consistency. Check the AlgorithmIdentifier inside TBS matches the one in the certificate signature. NB: this will result in signature failure errors for some broken certificates. 3. Check DSA/ECDSA signatures use DER. Reencode DSA/ECDSA signatures and compare with the original received signature. Return an error if there is a mismatch. This will reject various cases including garbage after signature (thanks to Antti Karjalainen and Tuomo Untinen from the Codenomicon CROSS program for discovering this case) and use of BER or invalid ASN.1 INTEGERs (negative or with leading zeroes). CVE-2014-8275 Reviewed-by: Emilia Käsper <emilia@openssl.org> (cherry picked from commit 684400ce192dac51df3d3e92b61830a6ef90be3e)
2014-12-12Fix use of NULL memory pointer in X509_VERIFY_PARAM_new in the event of aMatt Caswell
malloc failure. Reviewed-by: Kurt Roeckx <kurt@openssl.org>
2014-02-24x509/by_dir.c: fix run-away pointer (and potential SEGV)Andy Polyakov
when adding duplicates in add_cert_dir. PR: 3261 Reported by: Marian Done (cherry picked from commit 758954e0d8232d370ed72b7f86640e40443e1778)
2014-01-09Fix bug in X509_V_FLAG_IGNORE_CRITICAL CRL handling.Dr. Stephen Henson
(cherry picked from commit 8f4077ca69076cebaca51b7b666db1ed49e46b9e)
2014-01-06make updateDr. Stephen Henson
2013-12-08make updateDr. Stephen Henson
2013-08-06Fix verify loop with CRL checking.Dr. Stephen Henson
PR #3090 Reported by: Franck Youssef <fry@open.ch> If no new reason codes are obtained after checking a CRL exit with an error to avoid repeatedly checking the same CRL. This will only happen if verify errors such as invalid CRL scope are overridden in a callback. (cherry picked from commit 4b26645c1a71cf9ce489e4f79fc836760b670ffe)
2013-05-03Reencode with X509_CRL_ctx_sign too.Dr. Stephen Henson
(cherry picked from commit 96940f4f2d0300c033379a87db0ff19e598c6264)
2013-05-02Reencode certificates in X509_sign_ctx.Dr. Stephen Henson
Reencode certificates in X509_sign_ctx as well as X509_sign. This was causing a problem in the x509 application when it modified an existing certificate. (cherry picked from commit c6d8adb8a45186617e0a8e2c09469bd164b92b31)
2012-12-06Fix two bugs which affect delta CRL handling:Dr. Stephen Henson
Use -1 to check all extensions in CRLs. Always set flag for freshest CRL.
2012-06-08Reduce version skew.Ben Laurie
2012-04-16Minor compatibility fixes [from HEAD].Andy Polyakov
PR: 2790 Submitted by: Alexei Khlebnikov
2011-10-09Backport PSS signature support from HEAD.Dr. Stephen Henson
2011-10-09Backport of password based CMS support from HEAD.Dr. Stephen Henson
2011-10-06? crypto/aes/aes-armv4.SDr. Stephen Henson
? crypto/aes/aesni-sha1-x86_64.s ? crypto/aes/aesni-x86_64.s ? crypto/aes/foo.pl ? crypto/aes/vpaes-x86_64.s ? crypto/bn/.bn_lib.c.swp ? crypto/bn/armv4-gf2m.S ? crypto/bn/diffs ? crypto/bn/modexp512-x86_64.s ? crypto/bn/x86_64-gf2m.s ? crypto/bn/x86_64-mont5.s ? crypto/ec/bc.txt ? crypto/ec/diffs ? crypto/modes/a.out ? crypto/modes/diffs ? crypto/modes/ghash-armv4.S ? crypto/modes/ghash-x86_64.s ? crypto/modes/op.h ? crypto/modes/tst.c ? crypto/modes/x.h ? crypto/objects/.obj_xref.txt.swp ? crypto/rand/diffs ? crypto/sha/sha-512 ? crypto/sha/sha1-armv4-large.S ? crypto/sha/sha256-armv4.S ? crypto/sha/sha512-armv4.S Index: crypto/objects/obj_xref.c =================================================================== RCS file: /v/openssl/cvs/openssl/crypto/objects/obj_xref.c,v retrieving revision 1.9 diff -u -r1.9 obj_xref.c --- crypto/objects/obj_xref.c 5 Nov 2008 18:38:58 -0000 1.9 +++ crypto/objects/obj_xref.c 6 Oct 2011 20:30:21 -0000 @@ -110,8 +110,10 @@ #endif if (rv == NULL) return 0; - *pdig_nid = rv->hash_id; - *ppkey_nid = rv->pkey_id; + if (pdig_nid) + *pdig_nid = rv->hash_id; + if (ppkey_nid) + *ppkey_nid = rv->pkey_id; return 1; } @@ -144,7 +146,8 @@ #endif if (rv == NULL) return 0; - *psignid = (*rv)->sign_id; + if (psignid) + *psignid = (*rv)->sign_id; return 1; } Index: crypto/x509/x509type.c =================================================================== RCS file: /v/openssl/cvs/openssl/crypto/x509/x509type.c,v retrieving revision 1.10 diff -u -r1.10 x509type.c --- crypto/x509/x509type.c 26 Oct 2007 12:06:33 -0000 1.10 +++ crypto/x509/x509type.c 6 Oct 2011 20:36:04 -0000 @@ -100,20 +100,26 @@ break; } - i=X509_get_signature_type(x); - switch (i) + i=OBJ_obj2nid(x->sig_alg->algorithm); + if (i && OBJ_find_sigid_algs(i, NULL, &i)) { - case EVP_PKEY_RSA: - ret|=EVP_PKS_RSA; - break; - case EVP_PKEY_DSA: - ret|=EVP_PKS_DSA; - break; - case EVP_PKEY_EC: - ret|=EVP_PKS_EC; - break; - default: - break; + + switch (i) + { + case NID_rsaEncryption: + case NID_rsa: + ret|=EVP_PKS_RSA; + break; + case NID_dsa: + case NID_dsa_2: + ret|=EVP_PKS_DSA; + break; + case NID_X9_62_id_ecPublicKey: + ret|=EVP_PKS_EC; + break; + default: + break; + } } if (EVP_PKEY_size(pk) <= 1024/8)/* /8 because it's 1024 bits we look
2011-09-23PR: 2606Dr. Stephen Henson
Submitted by: Christoph Viethen <cv@kawo2.rwth-aachen.de> Reviewed by: steve Handle timezones correctly in UTCTime.
2011-09-06Initialise X509_STORE_CTX properly so CRLs with nextUpdate date in the pastDr. Stephen Henson
produce an error (CVE-2011-3207)
2011-06-22allow MD5 use for computing old format hash linksDr. Stephen Henson
2011-06-09Fix warnings.Ben Laurie
2011-06-03Backport libcrypto audit: check return values of EVP functions insteadDr. Stephen Henson
of assuming they will always suceed.
2011-06-03New function X509_ALGOR_set_md() to set X509_ALGOR ↵Dr. Stephen Henson
(DigestAlgorithmIdentifier) from a digest algorithm (backport from HEAD).
2010-11-02Submitted by: Jonathan Dixon <joth@chromium.org>Dr. Stephen Henson
Reviewed by: steve If store is NULL set flags correctly.
2010-10-03Add call to ENGINE_register_all_complete() to ENGINE_load_builtin_engines(),Dr. Stephen Henson
this means that some implementations will be used automatically, e.g. aesni, we do this for cryptodev anyway. Setup cpuid in ENGINE_load_builtin_engines() too as some ENGINEs use it.
2010-02-19Fix X509_STORE lockingBodo Möller
2010-01-22Tolerate PKCS#8 DSA format with negative private key.Dr. Stephen Henson
2010-01-12PR: 2136Dr. Stephen Henson
Submitted by: Willy Weisz <weisz@vcpc.univie.ac.at> Add options to output hash using older algorithm compatible with OpenSSL versions before 1.0.0