summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-11-11Fix a few bugs in X509v3_asid_add*()Theo Buehler
These 'builder' functions, usually used together, can result in corrupt ASIdentifiers on failure. In general, no caller should ever try to recover from OpenSSL API failure. There are simply too many traps. We can still make an effort to leave the objects in unmodified state on failure. This is tricky because ownership transfer happens. Unfortunately a really clean version of this seems impossible, maybe a future iteration will bring improvements... The nasty bit here is that the caller of X509v3_asid_add_id_or_range() can't know from the return value whether ownership of min and max was transferred or not. An inspection of (*choice)->u.range is required. If a caller frees min and max after sk_ASIdOrRange_push() failed, there is a double free. All these complications could have been avoided if the API interface had simply used uint32_t instead of ASN1_INTEGERs. The entire RFC 3779 API was clearly written without proper review. I don't know if there ever was an actual consumer before rpki-client. If it existed, nobody with the requisite skill set looked at it in depth. ok beck for the general direction with a lot of input and ok jsing
2023-11-11Delete the useless .\" ----- comments before .Sh.Ingo Schwarze
Wo don't have them anywhere else, so we don't need them here. No text change.
2023-11-11more details about error recoveryIngo Schwarze
OK millert@ jmc@ triggered by a question from cheloha@
2023-11-10Give ober_printf_elements() a ber_element array, similar toMartijn van Duren
ober_scanf_elements(). This allows us to move down and back up multiple levels in with nested sequences and sets. While here, on failure, make sure we free (and unlink if needed) all elements we created. OK claudio@, tb@
2023-11-10MNT_SOFTDEP and mount -o softdep no longer have any effectIngo Schwarze
OK kn@ jmc@
2023-11-09Forgot to fix the RFC number in the new commentTheo Buehler
2023-11-09Convert PKCS7_SIGNER_INFO_set() to X509_ALGOR_set0_by_nid()Theo Buehler
This is a straightforward conversion because I'm not going to start a cleanup here. Explain why this is not using X509_ALGOR_set_md(). See below. ok jca Let me include a beautiful note from RFC 5754 in its entirety: NOTE: There are two possible encodings for the AlgorithmIdentifier parameters field associated with these object identifiers. The two alternatives arise from the loss of the OPTIONAL associated with the algorithm identifier parameters when the 1988 syntax for AlgorithmIdentifier was translated into the 1997 syntax. Later, the OPTIONAL was recovered via a defect report, but by then many people thought that algorithm parameters were mandatory. Because of this history, some implementations encode parameters as a NULL element while others omit them entirely. The correct encoding is to omit the parameters field; however, when some uses of these algorithms were defined, it was done using the NULL parameters rather than absent parameters. For example, PKCS#1 [RFC3447] requires that the padding used for RSA signatures (EMSA-PKCS1-v1_5) MUST use SHA2 AlgorithmIdentifiers with NULL parameters (to clarify, the requirement "MUST generate SHA2 AlgorithmIdentifiers with absent parameters" in the previous paragraph does not apply to this padding).
2023-11-09Convert ecx_item_sign() to X509_ALGOR_set0_by_nid()Theo Buehler
ok jca
2023-11-09Convert asn1_item_sign() to X509_ALGOR_set0_by_nid()Theo Buehler
ok jca
2023-11-09missing full stopJasper Lievisse Adriaanse
2023-11-09Fix X509_ALGOR_set0() usage in rsa_alg_set_oaep_padding()Theo Buehler
Replace X509_ALGOR_set0() with X509_ALGOR_set0_by_nid(). This way there is no missing error checking for OBJ_nid2obj() and no nested functions. Slightly more importantly, this plugs two long standing potential leaks in this function (or previously rsa_cms_encrypt()) due to missing error checking: in the unlikely event that X509_ALGOR_set0() failed, astr/ostr would leak. ok jsing
2023-11-09Use X509_ALGOR_set0_by_nid() in rsa_mgf1md_to_maskGenAlgorithm()Theo Buehler
ok jsing
2023-11-08More minor cleanup in rsa_alg_set_oaep_padding()Theo Buehler
Test and assign one more instance replace a useless comment by an empty line.
2023-11-08Prepare further fixes of X509_ALGOR_set0() misuseTheo Buehler
In rsa_alg_set_oaep_padding() rename los to ostr for consistency with astr, make it have function scope, free ostr in the error path and assume X509_ALGOR_set0() success. ok jca
2023-11-08zap a stray spaceTheo Buehler
2023-11-08Rename os into astr in rsa_alg_set_oaep_padding()Theo Buehler
2023-11-08Rename pkctx to pkey_ctx in rsa_alg_set_oaep_padding() and rsa_cms_encrypt()Theo Buehler
2023-11-08Some simple cosmetics in rsa_alg_set_oaep_padding()Theo Buehler
Rename rv into ret and split it on its own line, move labellen a bit down add some empty lines. To match style elsewhere. Most of this was requested by jsing
2023-11-08Split OAEP padding handling into a helper functionTheo Buehler
This matches what is done for PKCS#1 1.5 and PSS. This function needs a lot of work still, but it's easier to do that without having to tiptoe around a lot of other garbage. ok jsing
2023-11-08libc, librthread: _twait: fully validate absolute timeoutScott Soule Cheloha
Use timespecisvalid(3) to check both bounds for tv_nsec. Link: https://marc.info/?l=openbsd-tech&m=169913314230496&w=2 ok miod@
2023-11-07Move CMS_RecipientInfo_ktri_get0_algs() down a few lines and fix itsTheo Buehler
error check
2023-11-07Move CMS_RecipientInfo_get0_pkey_ctx() to first use of pkctxTheo Buehler
2023-11-07Inline rsa_ctx_to_pss_string()Theo Buehler
After previous refactoring, rsa_all_set_pss_padding() is the last remaining caller of the weirdly named and ugly rsa_all_set_pss_padding(). This can be handled in a few simple lines now that this mess has slightly cleaner code.
2023-11-07Rename pkctx to pkey_ctx in rsa_{cms,item}_sign()Theo Buehler
2023-11-07Trivial cleanup in rsa_cms_sign()Theo Buehler
Check and assign the EVP_PKEY_CTX and move the extraction of the algorithm identifier from the signer info a few lines down.
2023-11-07Rework RSA_PKCS1_PSS_PADDING handling in rsa_item_sign()Theo Buehler
The current convoluted mess can be handled with two calls to the new rsa_alg_set_pss_padding() helper. Not that this would be obvious at all. This fixes two more leaks in case of X509_ALGOR_set0() failure. ok jsing
2023-11-07Add a helper to set RSASSA-PSS padding parametersTheo Buehler
This sets the AlgorithmIdentifier's algorithm to id-RSASSA-PSS with appropriate RSASSA-PSS parameters. This pulls a chunk of code out of rsa_cms_sign() and rewrites it with proper error checking, thereby fixing a long-standing leak. This helper can also be used in rsa_item_sign(), but that part is a bit special, and will therefore be commmitted separately. ok jsing
2023-11-07Add a helper to set RSA PKCS #1 v1.5 padding OIDTheo Buehler
This removes a few duplicated and unchecked X509_ALGOR_set0() calls and factors them into a helper function that sets the AlgorithmIdentifier on the recipient info or signer info to rsaEncryption with null parameters. ok jsing
2023-11-04KNF plus fixed a few signed vs unsigned compares (that we actuallyOtto Moerbeek
not real problems)
2023-11-02Fix a few bizarre line wraps in x509.hTheo Buehler
2023-11-01Use X509_ALGOR_set0_by_nid() in X509_ALGOR_set_evp_md()Theo Buehler
ok jsing
2023-11-01Add X509_ALGOR_set0_by_nid()Theo Buehler
X509_ALGOR_set0() is annoyingly unergonomic since it takes an ASN1_OBJECT rather than a nid. This means that almost all callers call OBJ_obj2nid() and they often do this inline without error checking so that the resulting X509_ALGOR object is corrupted and may lead to incorrect encodings. Provide an internal alternative X509_ALGOR_set0_by_nid() that takes a nid instead of an ASN1_OBJECT and performs proper error checking. This will be used to convert callers of X509_ALGOR_set0() in the library. ok jsing
2023-11-01Explain the weird order of doing things in X509_ALGOR_set0()Theo Buehler
2023-11-01Rename ptype and pval to parameter_type and parameter_valueTheo Buehler
ok jsing
2023-11-01Unindent X509_ALGOR_set0_parameter()Theo Buehler
ok jsing
2023-11-01Split X509_ALGOR_set0_parameter() out of X509_ALGOR_set0()Theo Buehler
ok jsing
2023-11-01Split X509_ALGOR_set0_obj() out of X509_ALGOR_set0()Theo Buehler
ok jsing
2023-10-30seperate -> separate;Jason McIntyre
2023-10-30make special note, right at the start, that DNS is handled seperatelyTheo de Raadt
from regular network. All the crummy pledge clones don't do that. ok millert
2023-10-29libc: Makefile.inc: remove "sparc" from quad support list; ok deraadt@Scott Soule Cheloha
2023-10-29Enable ISO C11 APIs when building libc, even with an older compiler.Todd C. Miller
Otherwise, the prototypes for timespec_get() and aligned_alloc() are not visible. OK guenther@
2023-10-29Fix an error exit in X509v3_addr_validate_path()Theo Buehler
If the topmost cert is invalid, this should result in a validation failure. Do the same dance as elsewhere permitting the verify callback to intercept the error but ensuring that we throw an error. ok jsing
2023-10-29Add a test to the end of agentx_varbind_finalize(), after completing theMartijn van Duren
full OID, that checks if we're >= searchrange.end. If so, just make it an endOfMIBView. OK tb@
2023-10-26A few micro-optimizations; ok asou@Otto Moerbeek
2023-10-26Tidy includesTheo Buehler
2023-10-26Hide X509_ALGOR_set_md() for LIBRESSL_INTERNALTheo Buehler
2023-10-26Rework the MD setting in the RSA ASN.1 methodTheo Buehler
This streamlines the code to use safer idioms, do proper error checking and be slightly less convoluted. Sprinkle a few references to RFC 8017 and explain better what we are doing and why. Clarify ownership and use more consistent style. This removes the last internal use of X509_ALGOR_set_md(). ok jsing
2023-10-24Require callers to use ibuf_fd_get() to extract the passed fd from an ibuf.Claudio Jeker
In imsg_free() close any fd that was not claimed automatically to prevent filedescriptor leaks. In ibuf_dequeue() remvoe code which is now part of imsg_free(). OK tb@
2023-10-24Add chacha aliases for OpenSSL compatibilityTheo Buehler
OpenSSL has the 20 in the long and short names, so add aliases to the existing names to make things work. In particular, EVP_get_cipherbyname() will now return EVP_chacha20() for both 'ChaCha20' and 'chacha20'. Found by Facundo Tuesca when trying to add LibreSSL support for ChaCha20 in https://github.com/pyca/cryptography/pull/9209 ok jsing
2023-10-24According to RFC2741 section 6.1.1 an agentx-response-pdu shouldn't haveMartijn van Duren
the NON_DEFAULT_CONTEXT set. Remove the argument from ax_response(). OK tb@