summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2024-02-24Replace uses of endbr64 with _CET_ENDBR from cet.hTheo Buehler
cet.h is needed for other platforms to emit the relevant .gnu.properties sections that are necessary for them to enable IBT. It also avoids issues with older toolchains on macOS that explode on encountering endbr64. based on a diff by kettenis ok beck kettenis
2024-02-24Remove custom key length handlingTheo Buehler
No cipher in libcrypto is marked EVP_CIPH_CUSTOM_KEY_LENGTH and no control handler deals with EVP_CTRL_SET_KEY_LENGTH, which means that this code is dead as far as libcrypto is concerned. Almost nothing uses EVP_CIPHER_meth* (this was added for a single project) and nothing sets a custom ctrl. This isn't going to change anyway since EVP_CIPHER_meth* is deprecated in order to promote more provider beauty. ok beck jsing
2024-02-24Remove last calls to CRYPTO_{push,pop}_info()Theo Buehler
These don't do anything but return 0 and will be garbage collected in the upcoming bump. ok jsing
2024-02-24err.c: fix incorrect line wrappingTheo Buehler
2024-02-23Prepare to provide X509_STORE_get1_objects()Theo Buehler
The OpenSSL 1.1 API X509_STORE_get0_objects() is not thread safe. It exposes a naked internal pointer containing certificates, CRLs and cached objects added by X509_LOOKUP_hash_dir(). Thus, if the store is shared between threads, it is not possible to inspect this pointer safely since another thread could concurrently add to it. This may happen in particular during certificate verification. This API led to security issues in rust-openssl and is also problematic in current Python. Other consumers of X509_STORE_get0_objects() are haproxy, isync, openvpn. The solution is to take a snapshot of the state under a lock and return that. This is what X509_STORE_get1_objects() does. It returns a newly allocated stack that needs to be freed with sk_X509_OBJECT_pop_free(), passing X509_OBJECT_free as a second argument. Based on a diff by David Benjamin for BoringSSL. https://boringssl-review.googlesource.com/c/boringssl/+/65787 ok beck jsing PS: Variants of this have landed in Python and OpenSSL 3 as well. There the sk_*deep_copy() API is used, which in OpenSSL relies on evaluating function pointers after casts (BoringSSL fixed that). Instead of using this macro insanity and exposing that garbage in public, we can do this by implementing a pedestrian, static sk_X509_OBJECT_deep_copy() by hand.
2024-02-23Remove ASN1_time_clamp_notafter() prototypeTheo Buehler
There is now a prototype in x509_internal.h, so no need to repeat that here.
2024-02-20x509_asid: NULL out min/max on extract_min_max() failureTheo Buehler
requested by/ok jsing
2024-02-19x509_asid: fix some KNF botchesTheo Buehler
When this file was brought into KNF, a few things became particularly ugly. This makes {a,b}{,_{min,max}} have function scope in canonize/is_canonical, which removes unfortunate line wraps and some other silliness. ok job
2024-02-19pk7_attr.c: tidy includesTheo Buehler
2024-02-18Update ASN1_TIME_set(3)Theo Buehler
Document OPENSSL_{posix_to_tm,tm_to_posix}() and fix the documentation of OPENSSL_{gmtime,timegm}(). ok jsing
2024-02-18Add posix_time.h from BoringSSLTheo Buehler
This is prepares to expose some internal API as OPENSSL_tm_to_posix() and OPENSSL_posix_to_tm(). They will be used in libtls and ocspcheck(8) to get rid of the portability nightmare that is timegm(). Also fix the location of OPENSSL_gmtime() and OPENSSL_timegm() (this API is not yet exposed). The former is from OpenSSL and surprisingly lives in crypto.h, not asn1.h, and the latter is BoringSSL API and lives in the new posix_time.h. Initial diff from beck, this pulls in further upstream work after review feedback. ok jsing
2024-02-18Align EVP_CIPHER_CTX_init() and _legacy_clear()Theo Buehler
2024-02-18Hide EVP_{CIPHER,MD}_CTX_init() from internalsTheo Buehler
ok jsing
2024-02-18Use EVP_MD_CTX_legacy_clear() internallyTheo Buehler
ok jsing
2024-02-18Use EVP_CIPHER_CTX_legacy_clear() internallyTheo Buehler
ok jsing
2024-02-18Add EVP_MD_CTX_legacy_clear()Theo Buehler
This is analogous to EVP_CIPHER_CTX_legacy_clear() and will serve as an internal replacement for EVP_MD_CTX_init() until the conversion to heap allocated ctx is completed. This way EVP_MD_CTX_init() can be changed to match the OpenSSL 1.1 API. ok jsing
2024-02-18Add EVP_CIPHER_CTX_legacy_clear()Theo Buehler
OpenSSL 1.1 made EVP_CIPHER_CTX_init() an alias of EVP_CIPHER_CTX_reset(). In particular, it changed signature and it would no longer leak internal state if used on an already used ctx. On the other hand, it can't be used for ctx on the stack. libcrypto still has a few ctx on the stack which will be converted to heap allocated contexts at some point. Until this is completed, we will use EVP_CIPHER_CTX_legacy_clear() internally, so that the public API can be changed to match OpenSSL 1.1. ok jsing
2024-02-17Use calloc() instead of malloc() in BIO_new().Joel Sing
ok tb@
2024-02-16Inline and disable BIO_set().Joel Sing
BIO_set() is a dangerous function that cannot be used safely. Thankfully, the only consumer is BIO_new(), hence inline the functionality and disable the BIO_set() function (for complete removal in the near future). ok tb@
2024-02-16Use 'bio' more consistently for function arguments.Joel Sing
Rather than 'a' or 'b', use 'bio' more consistently - there are still some more complex cases that have been left alone for now. Also use fewer parentheses. No change to generated assembly other than line numbers.
2024-02-16Make it explicit that the EC_KEY setters don't check thingsTheo Buehler
While EC_POINT_set_affine_coordinates() checks that the resulting point is on the elliptic curve, this is only necessary, but not sufficient, to ensure that the point can serve as a valid public key. For example, this does not check for normalized coordinates or exclude that it is zero (the point at infinity). Such checks, and more, are performed by the similarly named EC_KEY_set_public_key_affine_coordinates(). This kind of makes sense from the mathematical standpoint as an elliptic curve point isn't a priori a public key, even if you are not going to use libcrypto for actual mathematics (or anything really) unless you like pain. In a cryptographic library such differences are more of a hazard than a help. This is exacerbated by the fact that EC_KEY_set_public_key() does almost no checking (it only checks that the point's EC_POINT method matches the one of group set of the EC_KEY, which is far from enough). The API expects that you call EC_KEY_check_key() on your own. This is kind of confusing since EC_KEY_set_public_key_affine_coordinates() does that for you. Unfortunately, adding sanity checks to EC_KEY_set_public_key() isn't easy since it's going to penalize those who already check. Caching the result of a check is dangerous and fragile if there are a million ways of fiddling with an EC_KEY. While the elliptic curve code is really bad, its documentation is worse (another thing that applies to OpenSSL in general). Try to help that a little bit by making it more explicit that you are supposed to call EC_KEY_check_key() after using lower-level EC_KEY setters. Also make it clearer that the setters copy the data, they don't take ownership (which isn't obvious from the naming). If OpenSSL 3 got one thing kind of right, it was to deprecate the EC_KEY and EC_POINT APIs. But if you are going to deprecate something, you should either be prepared to remove it or have a reasonable replacement... Found by Guido Vranken using cryptofuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66667 ok jsing
2024-02-15BIO_dump*() avoid signed integer overflowTheo Buehler
This API returns an int encoding the number of bytes printed. Thus, a dump of a large enough byte string can make this overflow and rely on undefined behavior. With an indent of 64, as little as 26 MB is enough to make this happen. ok jsing
2024-02-13Document a portability caveat about GeneralizedTime and UTCTimeJob Snijders
OK tb@
2024-02-13Pull in z_off64_t handling from upstreamTheo Buehler
Since we don't define Z_LARGE64, we continue to define z_off64_t to z_off_t and all the other changes are no-ops for OpenBSD. ok kettenis millert
2024-02-11Remove needless includes of netinet6/ip6_var.h header in userland.Alexander Bluhm
OK millert@
2024-02-11libz: more windows ifdef turd shining from upstreamTheo Buehler
2024-02-11Update libexpat to version 2.6.0.Alexander Bluhm
This fixes CVE-2023-52425. OpenBSD is not affected by CVE-2023-52426. Relevant for OpenBSD are security fixes #789 #814, bug fixes #753 #812 #813, other changes #771 #788 #764 #765, and examples, docs, compiler warnings, clang-tidy, tests. Only a minor library bump is necessary, this has been discussed with tb@ guenther@ kettenis@. OK deraadt@
2024-02-10libz: sync with upstreamTheo Buehler
- fix type of local variable in deflate_stored() - more Windows compat shuffling - wrap overlong line in gzread
2024-02-09pull in another upstream tweak for windowsTheo Buehler
2024-02-09Don't assume MPPE-{Send,Recv}-Keys are used only for MS-CHAP (orYASUOKA Masahiko
16 bytes length). initial diff from markus
2024-02-09zlib: sync with upstreamTheo Buehler
2024-02-09Remove a useless EVP_MD_CTX_init() callTheo Buehler
The hash was just created with EVP_MD_CTX_new(), so we memset a calloced piece of memory to 0.
2024-02-08Feed more generated files to the clean target; joint work with naddy@Miod Vallat
2024-02-07sync with upstreamTheo Buehler
2024-02-07sync with zlib.hTheo Buehler
ok jmc
2024-02-07Sync doc-comment for deflateInit2 with upstreamTheo Buehler
2024-02-07libkeynote: use DSA_generate_parameters_ex()Theo Buehler
DSA_generate_parameters() was deprecated in 2002. Its removal was blocked because someone added "enhanced DSA support" to rust-openssl. Fortunately this was fixed recently by the pyca people. So we can remove it now. Of course, DSA_generate_parameters_ex() wasn't an improvement. While it no longer uses the old callback version, it also needs a DSA object passed in thus making it more annoying for callers. ok jsing
2024-02-04Of course libssl also has a few missing voidTheo Buehler
From Christian Andersen
2024-02-04Move ctype.h defines to the _CTYPE_ prefix, avoids clashes with identifiers ↵Jeremie Courreges-Anglas
in ports Even if those _[BCNLPSUX] defines are in the reserved namespace, some ports make use of those identifiers and thus need pointless headscratching and patches. Just use a longer reserved prefix. We can't just #undef those defines as they are used in libc. Change similar to what NetBSD did around 2010. Went through base builds and an amd64 bulk build, the only fallout was lib(e)stdc++ base_ctype.h. "make includes" will install the latest ctype.h and libstdc++ ctype_base.h. "makes sense" deraadt@, ok sthen@ tb@
2024-02-04Change rune-specific #defines from _CTYPE_ prefix to _RUNETYPE_ prefixJeremie Courreges-Anglas
Similar to what NetBSD did around 2010, this lets us move some defines in ctype.h to the _CTYPE_ prefix. No functional change. "makes sense" deraadt, ok sthen@ tb@
2024-02-03Rework the exit path of tls13_handshake_recv_action()Theo Buehler
If an error occurs in action->recv() for a handshake that needs to downgrade to legacy TLS, the artistic exit path led to hiding the error under TLS13_IO_USE_LEGACY. Rework the exit path to be easier to follow, preserving behavior except that the error can no longer be masked. Detailed analysis and initial diff by Masaru Masuda. Fixes https://github.com/libressl/openbsd/issues/146 ok beck
2024-02-03Remove last peeking at TLS1_FLAGS_SKIP_CERT_VERIFYTheo Buehler
This was used for some GOST weirdness. The flag is unused in ports and there is no user in Debian's codesearch. ok beck
2024-02-03Zap a trailing blank that snuck into ssl3_get_client_hello()Theo Buehler
2024-02-03Remove GOST and STREEBOG support from libssl.Bob Beck
This version of GOST is old and not anywhere close to compliant with modern GOST standards. It is also very intrusive in libssl and makes a mess everywhere. Efforts to entice a suitably minded anyone to care about it have been unsuccessful. At this point it is probably best to remove this, and if someone ever showed up who truly needed a working version, it should be a clean implementation from scratch, and have it use something closer to the typical API in libcrypto so it would integrate less painfully here. This removes it from libssl in preparation for it's removal from libcrypto with a future major bump ok tb@
2024-02-02Ignore EVP_MD_CTX_reset() return valueTheo Buehler
Also drop now unnecessary NULL checks before it.
2024-02-02Ignore EVP_CIPHER_CTX_reset() return value, it can't failTheo Buehler
2024-02-02Reimplement BIO_dump_indent() with CBS/CBB and BIO_printf()Theo Buehler
Instead of heaps of unchecked strlcpy/strlcat/snprintf doing hard to follow gymnastics, use a byte string, a somewhat comprehensible computation of the number of bytes to dump per output line and write using checked BIO_printf() directly to the BIO. Longer strings will still overflow the terminal width of 80 and even longer strings will still overflow the return value (undefined behavior). I don't care much about the former but the latter should be fixed in a later pass. ok beck
2024-02-01Fix the verifier to use the trust storeBob Beck
the trust store is yet another obscure way to add a trust anchor
2024-02-01Inline EVP_PBE_find() in its last two callersTheo Buehler
This API was already cleaned up quite a bit, but it is unused in the ecosystem and the two internal callers can be simplified a lot when inlining the lookups. EVP_PBE_CipherInit() can walk the table of "outer" PBEs and reach into the matching pbe for its cipher_nid, md_nid and keygen(). PKCS5_v2_PBKDF2_keyivgen() uses EVP_PBE_find() as a way to mapping a PRF (given by the nid of an HMAC with some digest) to the digest's nid. This can be done by a simple switch. Move MD5 to the top and GOST to the end in that switch and wrap the latter in OPENSSL_NO_GOST, so it will go away once we define OPENSSL_NO_GOST. ok beck
2024-02-01Prepare to remove the _cb() and _fp() versions of BIO_dump()Theo Buehler
apache-httpd uses BIO_dump(), libssl uses BIO_dump_indent(), and the openssl(1) app uses both. Otherwise this is unused. This is horribly bad code even by libcrypto standards. By doing away with the callbacks fixes incorrect error checking for fwrite() but there is a lot more wrong in here. This can be cleaned up in a later pass, the only concern here is to be able to remove the unused variants in the next major bump. ok beck