summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509 (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Turn asserts in ASIdentifierChoice_canonize() into error checkstb2021-12-241-3/+5
| | | | | | | | | The first assert ensures that a stack that was just sorted in a stronger sense is sorted in a weak sense and the second assert ensures that the result of the canonization procedure is canonical. All callers check for error, so these asserts don't do anything useful. ok jsing
* Remove assert from extract_min_max() (again)tb2021-12-241-3/+1
| | | | | | All callers ensure that aor != NULL, so this isn't necessary. ok jsing
* Revert previous. The commit contained more than intended.tb2021-12-241-25/+14
|
* Turn asserts in ASIdentifierChoice_canonize() into error checkstb2021-12-241-12/+25
| | | | | | | | | The first assert ensure that a stack that was just sorted in a stronger sense is sorted in a weak sense and the second assert ensures that the result of the canonization procedure is canonical. All callers check for error, so these asserts don't do anything useful. ok jsing
* Remove assert from extract_min_max()tb2021-12-241-3/+1
| | | | | | All callers ensure that aor != NULL, so this isn't necessary. ok jsing
* Fix indent of a comment.tb2021-12-241-2/+2
|
* Remove asserts from addr_validate_path_internal()tb2021-12-241-9/+19
| | | | | | | | | | This is reachable from x509_verify(), but all asserts are previously checked in the caller. Turn them into error checks and make sure the error is set on the X509_STORE_CTX if present. Change some stack == NULL || sk_num(stack) == 0 checks into sk_num(stack) <= 0 which is equivalent but simpler. ok jsing
* Turn assert in X509v3_addr_canonize() into an error check.tb2021-12-241-3/+5
| | | | | | | All internal callers check the return value and future external callers will be happy not to hit an assert from the library. ok jsing
* Fully check the second strtoul() call in v2i_IPAddrBlocks()tb2021-12-231-3/+34
| | | | | | | | | This can read a value in an arbitrary base from a string that is supposed to be followed by whitespace or a colon, so it cannot be switched to strtonum(). The current checks don't allow a read past the end, but let's use the standard idiom instead. ok jsing
* Fix an arbitrary out-of-bounds stack read in v2i_IPAddrBlocks()tb2021-12-231-3/+7
| | | | | | | | | | | | | | | | | | | | | | | Switch an insufficiently checked strtoul() to strtonum(). This can be used to trigger a read of a user-controlled size from the stack. $ openssl req -new -addext 'sbgp-ipAddrBlock = IPv4:192.0.2.0/12341234' Segmentation fault (core dumped) The bogus prefix length 12341234 is fed into X509v3_addr_add_prefix() and used to read (prefixlen + 7) / 8 bytes from the stack variable 'min[16]' that ends up as 'data' in the memmove in ASN1_STRING_set(). The full fix will add length checks to X509v3_addr_add_prefix() and make_addressPrefix() and will be dealt with later. The entire X509v3_{addr,asid}_* API will need a thorough review before it can be exposed. This code is only enabled in -current and can only be reached from openssl.cnf files that contain sbgp-ipAddrBlock or from the openssl(1) command line. ok jsing
* Reinstate the licenses that were replaced with a license stubtb2021-12-182-12/+108
| | | | in OpenSSL commit d2e9e320.
* Include evp_locl.h where it will be needed once most structs fromtb2021-12-123-3/+6
| | | | | | evp.h will be moved to evp_locl.h in an upcoming bump. ok inoguchi
* Convert {i2d,d2i}_{,EC_,DSA_,RSA_}PUBKEY{,_bio,_fp}() to templated ASN1jsing2021-12-031-97/+1
| | | | | | | These functions previously used the old ASN1_{d2i,i2d}_{bio,fp}() interfaces. ok inoguchi@ tb@
* Bugfix in X509_get_pubkey_parameters(3):schwarze2021-11-261-3/+5
| | | | | | | | | | If EVP_PKEY_copy_parameters(3) fails - among other reasons, this may happen when out of memory - the pkey argument and/or the chain argument will not contain all the desired parameters after returning. Consequently, report the failure to the caller rather than silently ignoring it. OK tb@
* Simplify the code in X509_get_pubkey_parameters(3)schwarze2021-11-261-8/+4
| | | | | | | | | | | | | | | by using X509_get0_pubkey(3) instead of X509_get_pubkey(3); no functional change. OK tb@ This is similar to the relevant part of the follwoing commit from the OpenSSL 1.1.1 branch, which is still under a free licence, but without the bug that commit introduced into this function in OpenSSL: commit c01ff880d47392b82cce2f93ac4a9bb8c68f8cc7 Author: Dr. Stephen Henson <steve@openssl.org> Date: Mon Dec 14 13:13:32 2015 +0000
* Add certificate transparency methods to the standard extensions.tb2021-11-241-1/+7
| | | | | | | | This way, CT extensions in certs will be parsed by the new CT code when they are encountered. This gets rid of a lot of gibberish when looking at a cert with 'openssl x509 -text -noout -in server.pem' ok beck jsing
* In some situations, the verifier would discard the error on an unvalidatedbeck2021-11-243-50/+91
| | | | | | certificte chain. This would happen when the verification callback was in use, instructing the verifier to continue unconditionally. This could lead to incorrect decisions being made in software.
* minor KNF improvement, changing only whitespace, no code change:schwarze2021-11-191-4/+4
| | | | | | say: return_type *function_name(args); not: return_type* function_name (args); OK tb@
* As long as X509_OBJECT_free_contents(3) is a public API function,schwarze2021-11-191-1/+3
| | | | | | | | | | | | | | | make sure it fully re-initializes the object rather than leaving behind a stale pointer and a stale type in the object. The old behaviour was dangerous because X509_OBJECT_get_type(3) would then return the stale type to the user and one of X509_OBJECT_get0_X509(3) or X509_OBJECT_get0_X509_CRL(3) would then return the stale pointer to the user, provoking a use-after-free bug in the application program. Having these functions return X509_LU_NONE and NULL is better because those are the documented return values for these functions when the object is empty. OK tb@
* Put curly brace on the correct line.jsing2021-11-141-2/+3
|
* Fix a bug in check_crl_time() that could result in incompleteschwarze2021-11-131-8/+8
| | | | | | | | | | | | | | | | | | | | | | | verification, accepting CRLs that ought to be rejected, if an unusual combination of verification flags was specified. If time verification was explicitly requested with X509_V_FLAG_USE_CHECK_TIME, it was skipped on CRLs if X509_V_FLAG_NO_CHECK_TIME was also set, even though the former is documented to override the latter both in the OpenSSL and in the LibreSSL X509_VERIFY_PARAM_set_flags(3) manual page. The same bug in x509_check_cert_time() was already fixed by beck@ in rev. 1.57 on 2017/01/20. This syncs the beginning of the function check_crl_time() with the OpenSSL 1.1.1 branch, which is still under a free license. OK beck@ This teaches that having too many flags and options is bad because they breed bugs, and even more so if they are poorly designed to override each other in surprising ways.
* Merge a few additional X509error(ERR_R_MALLOC_FAILURE) callsschwarze2021-11-101-39/+28
| | | | | | | | | | | | | | | | | | and various style improvements from the OpenSSL 1.1.1 branch, which is still under a free license. - No need to #include <openssl/lhash.h>. - BUF_MEM_free(3) and sk_pop_free(3) can handle NULL. - sk_value(3) can handle -1. - Test pointers with "== NULL" rather than with "!". - Use the safer "p = malloc(sizeof(*p))" idiom. - return is not a function. - Delete very wrong commented out code. Including parts of the these commits from the 2015 to 2018 time range: 25aaa98a b4faea50 90945fa3 f32b0abe 26a7d938 7fcdbd83 208056b2 5b37fef0 Requested by and OK tb@.
* If X509_load_cert_crl_file(3) does not find any certificatesschwarze2021-11-103-3/+7
| | | | | | | | | | | | | | | | | | and/or CRLs in the PEM input file (for example, if the file is empty), provide an error message in addition to returning 0. This merges another part of this OpenSSL commit, which is still under a free license: commit c0452248ea1a59a41023a4765ef7d9825e80a62b Author: Rich Salz <rsalz@openssl.org> Date: Thu Apr 20 15:33:42 2017 -0400 I did *not* add the similar message types X509_R_NO_CERTIFICATE_FOUND and X509_R_NO_CRL_FOUND because both code inspection and testing have shown that the code generating them is unreachable. OK tb@
* Sync some code style improvements from the OpenSSL 1.1.1 branch,schwarze2021-11-101-10/+9
| | | | | | | | | | | | | | which is still under a free license. No functional change. - No need to #include <openssl/lhash.h> here. - return is not a function. - Do not use the pointless macro BIO_s_file_internal(). - No need to check for NULL before X509_CRL_free(3). This includes parts of the following OpenSSL commits from the 2015 to 2017 timeframe: 222561fe, 9982cbbb, f32b0abe, 26a7d938 OK tb@
* Merge two bug fixes from the OpenSSL 1.1.1 branch, which is stillschwarze2021-11-101-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | under a free license: 1. If the three X509_load_*(3) functions are called with a NULL file argument, do not return 1 to the caller because the return value 1 means "i loaded one certificate or CRL into the store". 2. When calling PEM load functions, do not ask the user for a password in an interactive manner. This includes parts of the following commits: commit c0452248ea1a59a41023a4765ef7d9825e80a62b Author: Rich Salz <rsalz@openssl.org> Date: Thu Apr 20 15:33:42 2017 -0400 Message: [...] Remove NULL checks and allow a segv to occur. [...] commit db854bb14a7010712cfc02861731399b1b587474 Author: Bernd Edlinger <bernd.edlinger@hotmail.de> Date: Mon Aug 7 18:02:53 2017 +0200 Message: Avoid surpising password dialog in X509 file lookup. OK tb@
* In X509_STORE_CTX, rename the X509_STORE store rather than ctx.tb2021-11-073-15/+15
| | | | ok gnezdo jsing
* In X509_STORE_CTX rename the misnamed last_untrusted to num_untrustedtb2021-11-073-17/+17
| | | | ok jsing
* Start cleaning up X509_STORE_get1_issuer()tb2021-11-061-15/+37
| | | | | | | | | | | | | | Get rid of the last X509_OBJECT_free_contents() call by moving the object from the stack to the heap. I deliberately kept the obj variable to keep obj and pobj separate. Rename the out parameter from issuer to out_issuer to ensure that we only assign it when we have acquired a reference that we can return. Add a new X509 *issuer. In the first part of the function, acquire an extra reference before check_issuer/check_time. In the second part of the function, acquire a reference inside the lock to avoid a race. Deal with ret only in one place. ok jsing
* In X509_STORE_get1_issuer() do not call the verify callback fromtb2021-11-061-3/+3
| | | | | | x509_check_cert_time(). Matches a change made in OpenSSL 70dd3c65. ok jsing
* Refactor X509_STORE_get1_certs()tb2021-11-061-27/+30
| | | | | | | | Split the retrieval of the certs in the store's cache that match the desired subject into a separate function. This greatly simplifies locking, error handling and the flow of the function. with/ok jsing
* First pass of streamlining X509_STORE_get1_{certs,crls}()tb2021-11-051-66/+77
| | | | | | | | | | | | | | These functions are quite messy. On top of the tricky logic querying the cache, then refreshing the cache (unconditionally or not), then querying again, then extracting a list of certs/crls and bumping their refcounts, things are intermixed with locking and needlessly early allocations that then need to be cleaned up again. Use X509_STORE_CTX_get_obj_by_subject() to avoid using an object on the stack and defer allocation of the returned stack of certs to later. Flatten the logic a bit and prepare for further refactoring. ok jsing
* Trade an abort() neutered by a comment for a blank line elsewhere.tb2021-11-051-2/+2
|
* Clean up X509_STORE_add_{cert,crl}().tb2021-11-051-69/+41
| | | | | | | | | | | | | | | | | | | | Add a X509_STORE_add_object() function that adds an X509 object to the store and takes care of locking and cleaning up. This way we can set up an X509_OBJECT for both the cert and CRL case and hand over to the new function. There is one intentional change of behavior: if there is an attempt to add an object which is already present in the store, succeed instead of throwing an error. This makes sense and is also the OpenSSL behavior. As pointed out by jsing, this is a partial fix for the long standing GH issue #100 on libtls where connections would fail if the store contains duplicate certificates. Also: remove the internal X509_OBJECT_dec_ref_count(), which is no longer used. ok jsing
* Unify variable names in X509_STORE_{free,up_ref,add_lookup}().tb2021-11-051-29/+26
| | | | | | simplify the flow of X509_add_lookup(). ok jsing
* Rename the ret variable in X509_OBJECT_new() to obj..tb2021-11-051-5/+5
| | | | ok jsing
* Garbage collect the unused skip member of X509_LOOKUP andtb2021-11-052-5/+1
| | | | | | the unused cache member of X509_STORE. ok jsing
* Use calloc() to remove the need of silly zeroing of most members.tb2021-11-051-28/+18
| | | | | | | Check for allocation failures and if one happens push an error on the stack and clean up using X509_STORE_free(). ok jsing
* Streamline and shorten x509_object_cmp() a bit.tb2021-11-051-11/+6
| | | | ok jsing
* Drop a bunch of unnecesary parentheses and unify the order in whichtb2021-11-051-17/+13
| | | | | | callbacks are called. ok jsing
* Cleanup X509_LOOKUP_new()tb2021-11-051-12/+11
| | | | | | | Switch from malloc() to calloc() and drop a bunch of initializations to 0. Call the returned object lu instead of the generic ret. ok jsing
* Garbage collect xobj->data.{ptr,pkey}tb2021-11-052-8/+6
| | | | | | | | | Both these are essentially unused. Remove the last use of data.ptr by initializing and copying the X509_OBJECT using memset() and struct assignment in X509_STORE_CTX_get_subject_by_name() and add a missing error check for X509_OBJECT_up_ref_count() while there. ok beck
* Cache sha512 hash and parsed not_before and not_after with X509 cert.beck2021-11-047-128/+135
| | | | | | | | | | | Replace sha1 hash use with sha512 for certificate comparisons internal to the library. use the cached sha512 for the validator's verification cache. Reduces our recomputation of hashes, and heavy use of time1 time conversion functions noticed bu claudio@ in rpki client. ok jsing@ tb@
* Fix five bugs in X509_REQ_to_X509(3):schwarze2021-11-031-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | * memory leak in X509_set_subject_name(ret, X509_NAME_dup(xn)); * memory leak in X509_set_issuer_name(ret, X509_NAME_dup(xn)); * memory leak in X509_set_pubkey(ret, X509_REQ_get_pubkey(r)); * missing return value check of X509_REQ_get_pubkey(r); * missing return value check of X509_set_pubkey(...); Some of these bugs have survived for twenty-five years. I noticed the first two bugs while documenting the function, then found that a commit in the OpenSSL 1.1.1 branch, which is still under a free license, fixed all of them in 2016. In the function X509_REQ_to_X509(3), merge everything worth merging from OpenSSL 1.1.1, in particular the relevant parts of: * 222561fe Apr 30 17:33:59 2015 -0400 (err: label cleanup) * 0517538d Mar 17 00:15:48 2016 +0100 (the bugfix) * c5137473 Apr 3 23:37:32 2016 +0200 (code simplification) While here, delete some commented out code that is wrong in multiple ways and untouched since the SSLeay era. One code tweak for readability by tb@, and OK tb@.
* Some cleanup in X509_REQ_get_extensions(3), no functional change.schwarze2021-11-031-10/+6
| | | | | | | | | | | | | | In this function, merge everything that is worth merging from the OpenSSL 1.1.1 branch, which is still under a free license, mostly the relevant part of commit 9b0a4531 Mar 14 23:48:47 2015 +0000 to use X509_ATTRIBUTE_get0_type(3) rather than re-implementing it. While here, * use d2i_X509_EXTENSIONS(3) rather than ASN1_item_d2i(3); * test pointers explicitly against NULL, not with '!', as suggested by tb@; * drop some useless parentheses as suggested by tb@. OK tb@
* Fix two bugs in X509_REQ_add_extensions_nid(3)schwarze2021-11-031-32/+13
| | | | | | | | | | | | | | | | | | that i noticed while documneting the function: * missing return value check for ASN1_item_i2d(3) and * missing return value check for OBJ_nid2obj(3). In the function X509_REQ_add_extensions_nid(3), merge everything that is worth merging from the OpenSSL 1.1.1 branch, which is still under a free license; that's mostly parts of the commit 9b0a4531 Mar 14 23:48:47 2015 +0000 (containing the bugfix, even though the OpenSSL commit message did not mention the bugs) and some minor stylistic changes from 0f113f3e and 26a7d938. While here, use i2d_X509_EXTENSIONS(3) instead of the layer-violating call to ASN1_item_i2d(3), and include a few stylistic tweaks from tb@. OK tb@, and jsing@ agreed on the general direction.
* Move the now internal X.509-related structs into x509_lcl.h.tb2021-11-0135-404/+417
| | | | | | | | Garbage collect the now unused LIBRESSL_CRYPTO_INTERNAL and LIBRESSL_OPAQUE_X509. Include "x509_lcl.h" where needed and fix a couple of unnecessary reacharounds. ok jsing
* In X509_STORE_CTX_get_obj_from_subject() rename X509_OBJECT fromtb2021-11-011-6/+6
| | | | | | the generic 'ret' to obj' in X509. Requested by jsing
* Unifdef LIBRESSL_NEW_API. Now that the library is bumped, this istb2021-11-014-37/+4
| | | | | | no longer needed. ok jsing
* Hide struct internals under LIBRESSL_CRYPTO_INTERNAL so that othertb2021-10-312-17/+17
| | | | | | parts of LibreSSL can no longer reach into them. discussed with beck, jsing
* Remove the unused X509_OBJECTS struct.tb2021-10-311-8/+1
| | | | ok beck jsing