summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2022-04-21Clarify comments at the start of {asid,addr}_validate_path_internal()Theo Buehler
Requested by jsing
2022-04-21Avoid expensive RFC 3779 checks during cert verificationTheo Buehler
X509v3_{addr,asid}_is_canonical() check that the ipAddrBlocks and autonomousSysIds extension conform to RFC 3779. These checks are not cheap. Certs containing non-conformant extensions should not be considered valid, so mark them with EXFLAG_INVALID while caching the extension information in x509v3_cache_extensions(). This way the expensive check while walking the chains during X509_verify_cert() is replaced with a cheap check of the extension flags. This avoids a lot of superfluous work when validating numerous certs with similar chains against the same roots as is done in rpki-client. Issue noticed and fix suggested by claudio ok claudio inoguchi jsing
2022-04-21Fix X509_get_extension_flags()Theo Buehler
Ensure that EXFLAG_INVALID is set on X509_get_purpose() failure. ok inoguchi jsing
2022-04-20Use glob to expand wildcards in "other device" paths rather than aJoshua Stein
custom implementation that only allowed matching all files in a directory. ok millert
2022-04-20Make the termp and winp arguments for openpty, et al. const.Todd C. Miller
This matches the prototypes in glibc and musl libc. From Matthew Martin. OK tb@
2022-04-20Avoid use of uninitialized in BN_mod_exp_recp()Theo Buehler
If either of the two initial BN_CTX_get() fails, we will call BN_RECP_CTX_free() on the uninitialized recp, which won't end well, so hoist the BN_RECP_CTX_init() call a few lines up. From Pauli, OpenSSL ad249412 ok inoguchi jsing
2022-04-19Drop unused KeyUpdate from debug printfTheo Buehler
The handshake state machine does not handle key updates since that's a post-handshake handshake message. This is code under #ifdef TLS13_DEBUG and if it is ever to be reused in tls13_handshake_msg.c, that will have to be revisited. ok inoguchi jsing
2022-04-15delete an ancient paragraph suggesting the wrong reason to use close(2)Theo de Raadt
(and we all laughed a little)
2022-04-13Fix typo in last commit.Todd C. Miller
2022-04-13ftok: avoid left shift of a signed in by 24 placesTodd C. Miller
Fix "left shift of 255 by 24 places cannot be represented in type 'int'" error from UBSAN. Adapted from a FreeBSD diff via tb@. OK tb@ deraadt@
2022-04-13inet_net_pton_ipv6: avoid signed vs unsigned comparisonTodd C. Miller
Use a temporary variable to store the number of bytes to be copied (size_t) and also use it as the memcpy(3) length. Previously we copied "size" bytes instead of just the necessary number. OK claudio@ tb@
2022-04-12KNF for a brace and zap trailing blank lineTheo Buehler
2022-04-10Set ASN1_OBJECT_FLAG_DYNAMIC_DATA flag with t2i_ASN1_OBJECT_internalKinichiro Inoguchi
'flags' should have ASN1_OBJECT_FLAG_DYNAMIC_DATA bit to free 'data' by ASN1_OBJECT_free as c2i_ASN1_OBJECT_cbs does. ok jsing@ tb@
2022-04-07Avoid infinite loop on parsing DSA private keysTheo Buehler
DSA private keys with ill-chosen g could cause an infinite loop on deserializing. Add a few sanity checks that ensure that g is according to the FIPS 186-4: check 1 < g < p and g^q == 1 (mod p). This is enough to ascertain that g is a generator of a multiplicative group of order q once we know that q is prime (which is checked a bit later). Issue reported with reproducers by Hanno Boeck. Additional variants and analysis by David Benjamin. ok beck jsing
2022-04-07Avoid infinite loop for custom curves of order 1Theo Buehler
If a private key encoded with EC parameters happens to have order 1 and is used for ECDSA signatures, this causes an infinite loop since a random integer x in the interval [0,1) will be 0, so do ... while (x == 0); will loop indefinitely. Found and reported with a reproducer by Hanno Boeck. Helpful comments and analysis from David Benjamin. ok beck jsing
2022-03-31man pages: fix some typos found while looking for other issuesChristian Weisgerber
2022-03-31man pages: add missing commas between subordinate and main clausesChristian Weisgerber
jmc@ dislikes a comma before "then" in a conditional, so leave those untouched. ok jmc@
2022-03-31Fix leak in ASN1_TIME_adj_internal()Theo Buehler
p is allocated by asprintf() in one of the *_from_tm() functions, so it needs to be freed as in the other error path below. CID 346194 ok jsing
2022-03-31Simplify priv_key handling in d2i_ECPrivateKey()Theo Buehler
d2i_EC_PRIVATEKEY() can handle the allocation of priv_key internally, no need to do this up front and reach it through the dangerous reuse mechanism. There's also no point in freeing a variable we know to be NULL. ok jsing
2022-03-30Avoid segfaults in EVP_PKEY_CTX_free()Theo Buehler
It is possible to call pmeth->cleanup() with an EVP_PKEY_CTX whose data is NULL. If pmeth->init() in int_ctx_new() fails, EVP_PKEY_CTX_free() is called with such a context. This in turn calls pmeth->cleanup(), and thus these cleanup functions must be careful not to use NULL data. Most of them are, but one of GOST's functions and HMAC's aren't. Reported for HMAC by Masaru Masada https://github.com/libressl-portable/openbsd/issues/129 ok bcook jsing
2022-03-30pkey_hmac_init(): use calloc()Theo Buehler
Instead of using malloc() and setting most struct members to 0, simply use calloc(). ok bcook jsing
2022-03-29man pages: add missing word, The foo() ... -> The foo() function ...Christian Weisgerber
ok jmc@ schwarze@
2022-03-29Given asn1/a_object.c rev. 1.45 by jsing@, stop talking about BUGSIngo Schwarze
we no longer have, focus on what our implementation now does, but keep short warnings in how far other implementations might be more fragile. Some improvements to wordings and clarity while here. OK tb@
2022-03-29man pages: add missing commas in enumerationsChristian Weisgerber
2022-03-29Bound cofactor in EC_GROUP_set_generator()Theo Buehler
Instead of bounding only bounding the group order, also bound the cofactor using Hasse's theorem. This could probably be made a lot tighter since all curves of cryptographic interest have small cofactors, but for now this is good enough. A timeout found by oss-fuzz creates a "group" with insane parameters over a 40-bit field: the order is 14464, and the cofactor has 4196223 bits (which is obviously impossible by Hasse's theorem). These led to running an expensive loop in ec_GFp_simple_mul_ct() millions of times. Fixes oss-fuzz #46056 Diagnosed and fix joint with jsing ok inoguchi jsing (previous version)
2022-03-29Do not zero cofactor on ec_guess_cofactor() successTheo Buehler
The cofactor we tried to calculate should only be zeroed if we failed to compute it. ok inoguchi jsing
2022-03-29Zap trailing whitespaceTheo Buehler
2022-03-29Basic copy editing:Ingo Schwarze
Eliminate weasel words and needless parentheses, reduce "will" and "shall" and "may", add more precision, some grammar fixes, shorten and improve wordings, add some missing macros. Triggered by a question from naddy@.
2022-03-28Remove extra 'or'Claudio Jeker
OK tb@
2022-03-28tweak the pflog ifname filter to include the terminating nul.David Gwynne
without this the code effectively just compares the start of the string, which means you can get a prefix match unexpectedly. including the nul in the comparison means it only works for whole interface names, as it was originally intended. reported by Aner Perez on misc@ ok deraadt@ (who also dug through the history behind this)
2022-03-26name constraints: be more careful with NULsTheo Buehler
An IA5STRING is a Pascal string that can have embedded NULs and is not NUL terminated (except that for legacy reasons it happens to be). Instead of taking the strlen(), use the already known ASN.1 length and use strndup() instead of strdup() to generate NUL terminated strings after some existing code has checked that there are no embedded NULs. In v2i_GENERAL_NAME_ex() use %.*s to print the bytes. This is not optimal and might be switched to using strvis() later. ok beck inoguchi jsing
2022-03-26Clean up {dtls1,ssl3}_read_bytes()Joel Sing
Now that {dtls1,ssl3}_read_bytes() have been refactored, do a clean up pass - this cleans up various parts of the code and reduces differences between these two functions. ok = 1; *(&(ok)) tb@ ok inoguchi@
2022-03-26Remove the minimum record length checks from dtls1_read_bytes()Joel Sing
The code that handles each record type already has appropriate length checks. Furthermore, the handling of application data here is likely incorrect and bypasses the normal state checks at the end of this function. ok inoguchi@ tb@
2022-03-26Convert c2i_ASN1_OBJECT() and d2i_ASN1_OBJECT to CBS.Joel Sing
Along the way, rather than having yet another piece of code that parses OID arcs, reuse oid_parse_arc(). Always allocate a new ASN1_OBJECT rather than doing a crazy dance with ASN1_OBJECT_FLAG_DYNAMIC and trying to free parts of an ASN1_OBJECT if one is passed in. ok inoguchi@ tb@
2022-03-26Provide asn1_get_primitive()Joel Sing
This takes a CBS, gets the ASN.1 identifier and length, ensures the resulting identifier is a valid primitive, then returns the tag number and the content as a CBS. ok inoguchi@ tb@
2022-03-25use the new CPU_ID_AA64ISAR0 sysctl to determine CPU features on arm64Robert Nagy
ok tb@, deraadt@, kettenis@
2022-03-25Improve error checking in deflatePrime()Theo Buehler
This is a small follow-up commit to the previous commit. ok mbuhl millert commit 4346a16853e19b45787ce933666026903fb8f3f8 Author: Mark Adler <madler@alumni.caltech.edu> Date: Tue Apr 17 22:44:41 2018 -0700 Assure that the number of bits for deflatePrime() is valid. https://github.com/madler/zlib/commit/4346a16853e19b45787ce933666026903fb8f3f8
2022-03-25Fix memory corruption bug in zlibTheo Buehler
zlib has a crashing bug. The bug fix has been sitting in the unreleased develop branch for nearly four years. Pull in this fix. ok mbuhl millert Reported by Tavis Ormandy on oss-security: https://marc.info/?l=oss-security&m=164809382107156&w=2 commit 5c44459c3b28a9bd3283aaceab7c615f8020c531 Author: Mark Adler <madler@alumni.caltech.edu> Date: Tue Apr 17 22:09:22 2018 -0700 Fix a bug that can crash deflate on some input when using Z_FIXED. This bug was reported by Danilo Ramos of Eideticom, Inc. It has lain in wait 13 years before being found! The bug was introduced in zlib 1.2.2.2, with the addition of the Z_FIXED option. That option forces the use of fixed Huffman codes. For rare inputs with a large number of distant matches, the pending buffer into which the compressed data is written can overwrite the distance symbol table which it overlays. That results in corrupted output due to invalid distances, and can result in out-of-bound accesses, crashing the application. The fix here combines the distance buffer and literal/length buffers into a single symbol buffer. Now three bytes of pending buffer space are opened up for each literal or length/distance pair consumed, instead of the previous two bytes. This assures that the pending buffer cannot overwrite the symbol table, since the maximum fixed code compressed length/distance is 31 bits, and since there are four bytes of pending space for every three bytes of symbol space. https://github.com/madler/zlib/commit/5c44459c3b28a9bd3283aaceab7c615f8020c531
2022-03-24Backport zlib fix for the multi line CLEAR_HASH macro. There isAlexander Bluhm
an else branch where only half of the macro is executed conditionally. Acording to upstream comment this has only little impact. https://github.com/madler/zlib/commit/38e8ce32afbaa82f67d992b9f3056f281fe69259 OK deraadt@ tb@
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-03-23Start disentangling armv7 and aarch64 codeTheo Buehler
arm_arch.h and armcap.c are shared between armv7 and aarch64 which results in an inscrutable #ifdef maze. Move copies of these files into arch/{arm,aarch64}/ with appropriate names and some trivial minor adjustments. ok deraadt inoguchi kettenis
2022-03-23Remove extra space at EOL in last commit.Todd C. Miller
2022-03-23Expand the description of the LOGIN_SET* bits.Todd C. Miller
Specifically, describe the default behavior if the corresponding login.conf fields are not present. OK deraadt@
2022-03-23setclasscontext: support LOGIN_SETRTABLE tooTodd C. Miller
Do not clear LOGIN_SETRTABLE if it is set in flags. OK deraadt@
2022-03-20setusercontext: only call setrtable(2) if "rtable" set explicitly.Todd C. Miller
When LOGIN_SETRTABLE is set in flags, only call setrtable(2) if there is an "rtable" entry in login.conf. Previously, a default value of 0 was used if the capability was missing. That had the effect of resetting the rtable for every program that uses setusercontext(3), even if a different rtable was chosen by, e.g., "route -T exec command". OK deraadt@ matthieu@
2022-03-20Move/group i2d_ASN1_OBJECT() and d2i_ASN1_OBJECT().Joel Sing
2022-03-19Remove three useless tests filesTheo Buehler
The asn1test depends on asn1_mac.h which had a date with the bitbucket a few years back (and the test "isn't meant to run particularly, it's just to test type checking"). methtest.c tests an API that was never present in OpenSSL's git history. r160test.c is nothing but a licence. "nuke away" jsing
2022-03-19Provide t2i_ASN1_OBJECT_internal() and use it for OBJ_txt2obj()Joel Sing
The current OBJ_txt2obj() implementation converts the text to ASN.1 object content octets, builds a full DER encoding from it, then feeds the entire thing back through the DER to ASN.1 object conversion. Rather than doing this crazy dance, provide an t2i_ASN1_OBJECT_internal() function that converts the text to ASN.1 object content octets, then creates a new ASN1_OBJECT and attaches the content octets to it. ok inoguchi@ tb@
2022-03-19Rewrite ascii/text to ASN.1 object conversion.Joel Sing
Rewrite the ascii/text to ASN.1 object conversion code using CBB/CBS, while also addressing some of the bizarre behaviour (such as allowing mixed separators and treating '..' as a zero value). ok inoguchi@ tb@