summaryrefslogtreecommitdiff
path: root/lib/libtls
AgeCommit message (Collapse)Author
12 daysThe subject of a certificate is not optionalTheo Buehler
A certificate must have a subject, so X509_get_subject_name() cannot return NULL on a correctly parsed certificate, even if the subject is empty (which is allowed). So if X509_get_subject_name() returns NULL, error instead of silently ignoring it in tls_check_common_name(). This is currently no issue. Where it matters, the match against the common name will fail later, so we fail closed anyway. ok jsing
2024-08-31major bump for libcrypto libssl and libtlsTheo Buehler
2024-08-12Give libtls the same bump as libsslTheo Buehler
2024-08-02libtls: fix legacy protocol parsingTheo Buehler
Redefining TLS_PROTOCOL_TLSv1_0 and TLS_PROTOCOL_TLSv1_1 to be the same as TLS_PROTOCOL_TLSv1_2 had undesired side effects, as witnessed in the accompanying regress tests. The protocol string all:tlsv1.0 would disable TLSv1.2 (so only enable TLSv1.3) and tlsv1.2:!tlsv1.1 would disable all protocols. It makes more sense to ignore any setting of TLSv1.0 and TLSv1.1, so if you request 'tlsv1.1' you get no protocol, but 'all:!tlsv1.1' will enable the two supported protocols TLSv1.3 and TLSv1.2. Restore the defines to their original values and adjust the parsing code to set/unset them. Issue reported by Kenjiro Nakayama Fixes https://github.com/libressl/openbsd/issues/151 with/ok jsing
2024-06-11sync includes in tls_signer.cOmar Polo
pthread -> mutex stdint -> uint8_t stdio.h -> asprintf stdlib.h -> calloc string.h -> memcpy ecdsa -> ECDSA_METHOD leftover, remove ec -> EC_KEY evp -> EVP_PKEY pem -> PEM_read_bio_X509 x509 -> X509 90% of the diff is from tb@, I only spotted the missing string.h :) ok tb@
2024-04-15crank libtls like libcrypto and libsslTheo Buehler
2024-04-08Remove spaces before tabsTheo Buehler
2024-03-28Use TLS_ERROR_INVALID_ARGUMENT for "too large" and "too small" errorsjoshua
ok beck tb
2024-03-28Use TLS_ERROR_OUT_OF_MEMORY error code for calloc errors in libtlsjoshua
ok jsing
2024-03-27Add TLS_ERROR_INVALID_ARGUMENT error code to libtlsjoshua
This is an initial pass, defining the error code and using it for "too long"/length-related errors. ok beck jsing
2024-03-26Add TLS_ERROR_INVALID_CONTEXT error code to libtlsjoshua
ok jsing@ beck@
2024-03-26Fix previous commit.Joel Sing
2024-03-26Add error code support to libtlsjoshua
This adds tls_config_error_code() and tls_error_code(), which will become public API at a later date. Additional error codes will be added in follow-up commits. ok jsing@ beck@
2024-03-26Use errno_value instead of num for readabilityjoshua
ok jsing@
2024-03-26Use errno_value instead of num for readabilityjoshua
ok beck@ jsing@
2024-03-24Convert libressl to use the BoringSSL style time conversionsBob Beck
This gets rid of our last uses of timegm and gmtime in the library and things that ship with it. It includes a bit of refactoring in ocsp_cl.c to remove some obvious ugly. ok tb@
2024-03-02crank libtls majorTheo Buehler
same bump as libcrypto and libssl
2023-11-22typo: mutiple -> multipleOmar Polo
from Ryan Kavanagh (rak [at] debian [dot] org), ok tb@
2023-11-13Remove last caller of ASN1_time_parse(3) in libtlsTheo Buehler
This one is slightly annoying since ASN1_TIME_to_tm(3) doesn't provide a direct check for a GeneralizedTime, so call ASN1_GENERALIZEDTIME_check() as well. This means LibreSSL parses the time twice. Shrug. ok beck
2023-11-13Remove ASN1_time_parse() dependency in tls_conninfo.cTheo Buehler
During r2k22 ported some of the missing OpenSSL ASN.1 time API. This is a step towards removing the dependency of libtls on ASN1_time_parse(). The latter grew a dependency on CBS/CBB, and thus the choice is to pull in all this code or to use a no longer maintained version of the API. Both options are unappealing. ok beck
2023-09-18remove tls_reset(3) from the NAME, SYNOPSIS, and HISTORY sectionsIngo Schwarze
because it is documented in the separate tls_client(3) manual page
2023-07-28bump libcrypto, libssl, libtls majorsTheo Buehler
2023-07-02Remove the ability to do tls 1.0 and 1.1 from libtls.Bob Beck
With this change any requests from configurations to request versions of tls before tls 1.2 will use tls 1.2. This prepares us to deprecate tls 1.0 and tls 1.1 support from libssl. ok tb@
2023-06-27Zap stray spaceTheo Buehler
2023-06-18Turns out EC_KEY_METHOD_new() has dup built in...Theo Buehler
... because RSA_meth_new() doesn't. So we can fortunately lose a few lines added in the previous commit. Three cheers for the masters of inconsistency. ok jsing
2023-06-18tls_signer: reinstate the default EC_KEY methodsTheo Buehler
Previously, we would set the ECDSA_METHOD on the EC_KEY, which, by way of lovely indirection in our three crypto/ec* directories ended up having no effect on the default methods. Now that we set a new EC_KEY_METHOD, we need to make sure we still have the other handlers that we might need. Like so many things that were made opaque in the 1.1 re"design", the accessors were written without actual application code in mind. In particular, EC_KEY_METHOD lacks a dup(). This means we get to fetch the default methods with getters and then set them again on the new method. This is particularly awesome because once someone adds a new method to the opaque struct, all applications will have to adapt and do a get/set dance. So far this is very reminiscent of PostgreSQL with BIO_meth_* https://github.com/postgres/postgres/blob/a14e75eb0b6a73821e0d66c0d407372ec8376105/src/interfaces/libpq/fe-secure-openssl.c#L1921-L1928 Only it's worse here because someone wanted to be smart and save a few public functions, so we have to use getters that get several functions at once. Which in turn means we need to have function pointers with the precise signatures which are part of the struct that was made opaque. We will add a EC_KEY_METHOD_dup() in the next bump, but for now this is the best fix we can have. Whenever you think you've seen the worst turds in this code base, you find another one that could serve as an exemplar. ok jsing op
2023-06-18Switch tls_ecdsa_do_sign() to EC_KEY_get_ex_data()Theo Buehler
Since libtls now sets the ex_data with EC_KEY_set_ex_data(), the do_sign() callback needs to have a matching change. ok jsing op
2023-06-18libtls: switch ECDSA_METHOD usage to EC_KEY_METHODOmar Polo
smtpd and the bits it needs in libtls are the only consumer left of ECDSA_METHOD, which is long deprecated. This paves the way for the removal in libcrypto. The diff is from gilles' work on OpenSMTPD-portable, libretls had a similar diff. ok tb@, jsing@
2023-06-01Rework tls_check_subject_altname() error handlingTheo Buehler
Default to having rv = -1 and explicitly goto done to set rv = 0. This matches other code better. ok jsing
2023-06-01Check for X509_get_ext_d2i() failureTheo Buehler
X509_get_ext_d2i() (or rather X509V3_get_d2i()) can return NULL for various reasons. If it fails because the extension wasn't found, it sets *crit = -1. In any other case, e.g., the cert is bad or we ran out of memory in X509V3_EXT_d2i(), crit is set to something else, so we should actually error. ok jsing
2023-05-29Correctly catch all return values from X509_NAME_get_index_by_NIDBob Beck
And some comment requests, from jsing@ ok jsing@
2023-05-28correct comment, spotted by tb@Bob Beck
2023-05-28Refactor tls_check_common_name to use lower level API.Bob Beck
X509_NAME_get_text_by_NID is kind of a bad interface that we wish to make safer, and does not give us the visibility we really want here to detect hostile things. Instead call the lower level functions to do some better checking that should be done by X509_NAME_get_text_by_NID, but is not in the OpenSSL version. Specifically we will treat the input as hostile and fail if: 1) The certificate contains more than one CN in the subject. 2) The CN does not decode as UTF-8 3) The CN is of invalid length (must be between 1 and 64 bytes) 4) The CN contains a 0 byte 4) matches the existing logic, 1 and 2, and 3 are new checks. ok tb@
2023-05-25Forcibly update the EVP_PKEY's internal keyOmar Polo
To aid privilege separation, libtls maintains application-specific data on the key inside the EVP_PKEY abstraction because the EVP API doesn't provide a way to do that on the EVP_PKEY itself. OpenSSL 3 changed behavior of EVP_PKEY_get1_RSA() and related functions. These now return a struct from some cache. Thus, modifying the RSA will no longer modify the EVP_PKEY like it did previously, which was clearly implied to be the case in the older documentation. This is a subtle breaking change that affects several applications. While this is documented, no real solution is provided. The transition plan from one OpenSSL major version to the next one tends to involve many #ifdef in the ecosystem, and the only suggestion provided by the new documentation is to switch to a completely unrelated, new API. Instead, forcibly reset the internal key on EVP_PKEY after modification, this way the change is picked up also by OpenSSL 3. Fixes issue 1171 in OpenSMTPD-portable ok tb@, jsing@
2023-05-14add missing #include <string.h>; ok tb@Omar Polo
2023-05-11tls_verify.c: give up on variable alignment in this fileTheo Buehler
The previous commit resulted in misalignment, which impacts my OCD worse than no alignment at all. Alignment wasn't consistently done in this file anyway. op tells me it won't affect current efforts in reducing the diff.
2023-05-10switch two ASN1_STRING_data() to ASN1_STRING_get0_data()Omar Polo
and while here mark as const data. This diff is actually from gilles@, in OpenSMTPD-portable bundled libtls. ok tb@, jsing@
2023-05-05Use -Wshadow with clangTheo Buehler
ok jsing (a very long time ago)
2023-05-05Fix error handling in tls_check_common_name()Theo Buehler
A calloc failure should be a fatal error, so make it return -1. Also switch the default rv to -1 and distinguish error cases with acceptable situations with goto err/goto done. ok jsing
2023-04-25Bump majors after symbol addition and removalTheo Buehler
2023-04-09Drop X9.31 support from libtlsTheo Buehler
The TLS signer isn't exposed in public API (we should finally fix it...) and it supports X9.31, a standard that has been retired and deprecated for a very long time. libcrypto will stop supporting it soon, this step is needed to prepare userland. ok jsing
2023-03-10Crankl libcrypto/libssl/libtls minors after symbol additionTheo Buehler
2022-11-13Bump libtls minor to match libcrypto and libsslTheo Buehler
2022-09-11bump major after libcrypto and libssl major bumpTheo Buehler
2022-07-07Bump libtls minor after libcrypto and libssl minor bumpTheo Buehler
2022-03-24Crank major after symbol removal.Theo Buehler
2022-03-24Hide the tls_signer from public visibility. It's not ready yet andTheo Buehler
should not be used. It will be revisited after release. ok beck inoguchi jsing
2022-02-08Plug a long standing leak in libtls CRL handlingTheo Buehler
X509_STORE_add_crl() does not take ownership of the CRL, it bumps its refcount. So nulling out the CRL from the stack will leak it. Issue reported by KS Sreeram, thanks! ok jsing
2022-02-01Provide our own signature padding defines.Joel Sing
Rather than leaking libcrypto defines through the tls_sign_cb and tls_signer_sign() interfaces, provide and use our own TLS_PADDING_* defines. ok inoguchi@ tb@
2022-02-01Revise signer callback interface.Joel Sing
The current design of tls_sign_cb provides a pointer to a buffer where the signature needs to be copied, however it fails to provide a length which could result in buffer overwrites. Furthermore, tls_signer_sign() is designed such that it allocates and returns ownership to the caller. Revise tls_sign_cb so that the called function is expected to allocate a buffer, returning ownership of the buffer (along with its length) to the caller of the callback. This makes it far easier (and safer) to implement a tls_sign_cb callback, plus tls_signer_sign can be directly plugged in (with an appropriate cast). While here, rename and reorder some arguments - while we will normally sign a digest, there is no requirement for this to be the case hence use 'input' and 'input_len'. Move padding (an input) before the outputs and add some additional bounds/return value checks. This is technically an API/ABI break that would need a libtls major bump, however since nothing is using the signer interface (outside of regress), we'll ride the original minor bump. With input from tb@ ok inoguchi@ tb@