summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/merge.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-12-16add a CAVEATS section warning the user to not create cycles;schwarze1-1/+34
OK tb@
2022-12-16Revert BIO_push(3) cycle prevention (bio_lib.c rev. 1.42).schwarze2-39/+7
jsing@ worries that cycle prevention might increase risk because software that is not checking return values (and indeed, not checking is likely common in practice) might silently behave incorrectly with cycle prevention whereas without, it will likely either crash right away through infinite recursion or at least hang in an infinite loop when trying to use the cyclic chain, in both cases making it likely that the bug will be found and fixed. Besides, tb@ points out that BIO_set_next(3) ought to behave as similarly as possible to BIO_push(3), but adding cycle prevention to BIO_set_next(3) would be even less convincing because that function does not provide a return value, encouraging users to expect that it will always succeed. While a safe idiom for checking the success of BIO_set_next(3) could easily be designed, let's be realistic: application software would be highly unlikely to pick up such an idiom.
2022-12-15In curve25519.h rev. 1.4 to 1.7, tb@ and jsing@ providedschwarze1-11/+121
ED25519_keypair(3), ED25519_sign(3), and ED25519_verify(3). Document them.
2022-12-15The argument to ctype functions must be EOF or representable as anflorian1-2/+2
unsigned char. Casting to int is particularly useless because that's what the compiler already does. We need to prevent sign extension, not write down that we want sign extension. OK deraadt, kn, miod, op
2022-12-14In evp.h rev. 1.109 and 1.112, jsing@ and tb@ providedschwarze1-61/+154
EVP_PKEY_new_raw_private_key(3), EVP_PKEY_new_raw_public_key(3), EVP_PKEY_get_raw_private_key(3), and EVP_PKEY_get_raw_public_key(3). Merge the documentation from the OpenSSL 1.1.1 branch, which is still under a free license. I tweaked the text somewhat for conciseness, and argument names for uniformity.
2022-12-14In asn1.h rev. 1.71 and 1.72, jsing@ and tb@ provided ASN1_buf_print(3).schwarze4-5/+78
Document it.
2022-12-12Bump to LibreSSL 3.7.1tb1-3/+3
2022-12-11Add a small blurb on @SECLEVEL=nlibressl-v3.7.0tb1-2/+8
2022-12-10bio chain test: compress some error printingtb1-5/+4
2022-12-10bio chain test: deduplicate chain walking codetb1-52/+40
2022-12-10bio chain test: handle walking of empty chainstb1-27/+15
Rework the loops walking the chains to be correct for empty chains as well. This simplifies the checking at the cost of slightly more initialization and will allow further refactoring in a subsequent check.
2022-12-09bio chain test: add a consistency check for chain lengthstb1-1/+9
2022-12-09bn/Makefile: tidy up and simplifytb1-16/+10
2022-12-09bio chain test: make two errors noisytb1-3/+11
2022-12-09bio chain test: ensure the length of empty chains is 0tb1-3/+9
2022-12-09bio chain test: various minor readability tweakstb1-6/+8
Align initialization in walk_backward() with walk_forward(), fix grammar in a comment and move initialization of oldhead_len in a place consistent with the other length initializations in that function
2022-12-08bio chain test: fix inconsequential off-by-onetb1-2/+2
2022-12-08bio chain test: minor readability tweakstb1-5/+6
2022-12-08bio chain test: rename a few variables for consistencytb1-29/+29
2022-12-08bio chain test: decouple lengths of test chainstb1-59/+89
Add helpers to create and destroy a linear chain of BIOs. Provide two defines for the two lengths of the test chains and make them distinct to rule out coincidences. As a bonus, the code becomes simpler.
2022-12-08bio chain test: refactor link_chains_at()tb1-198/+109
Add helper that validate the chains. This deduplicates a lot of code and makes the heart of the test much easier to read.
2022-12-08bio chain test: lose some do_{,bio_} prefixestb1-12/+12
2022-12-08Split biotest into its three logical partstb4-458/+512
Some parts of this test rely on unportable behavior, so cannot run in portable. This way we can run more tests for portable which is helpful for analysis tools, better coverage, etc.
2022-12-08biotest: Tweak long comment a bittb1-11/+13
2022-12-08Fix copy-paste error that left a paragraph ending in a commatb1-3/+3
2022-12-08Add BIO_push() and BIO_set_next() regress coveragetb1-1/+367
This tests for the behavior changes in bio_lib.c r1.40 and r1.41 and makes sure that BIO_push() and BIO_set_next() act on two chains in the expected and now documented way.
2022-12-08bn_mod_exp test: drop extra parentheses for readabilitytb1-4/+4
2022-12-07Improve the implementation of BIO_push(3) such that it changes nothingschwarze2-6/+39
and reports failure if a call would result in a cycle. The algorithm used was originally suggested by jsing@. Feedback and OK tb@.
2022-12-07Add references to the BIO_{push,pop}(3) exampletb1-3/+8
The reader may not know what digest BIOs, Base64 BIOs and file BIOs are and the relevant function names are non-obvious, hence it's not entirely trivial to find the manuals where they are explained. With these references a reader should be able to turn the example into actual code. ok schwarze
2022-12-07Fix example stringtb1-4/+4
If you want to Base64-encode "Hello World\n" using a BIO, you had better pass "Hello World\n" into it, not something slightly different... While we're touching this, we might as well write it the way K&R did...
2022-12-06Zap extra spacetb1-3/+3
2022-12-06Major rewrite for accuracy and clarity, and document BIO_set_next(3).schwarze1-37/+148
Feedback and OK tb@.
2022-12-06Add a few missing headers and drop a few unused onestb7-20/+20
In bn_test.c include bn_local.h instead of using copy-pasted prototypes.
2022-12-06Make sure BIO_push(3) always preserves all invariants of the prev_bioschwarze1-3/+10
and next_bio fields of all BIO objects in all affected chains, no matter what the arguments are. In particular, if the second argument (the one to be appended) is not at the beginning of its chain, properly detach the beginning of its chain before appending. We have weak indications that this bug might affect real-world code. For example, in FreeRDP, file libfreerdp/crypto/tls.c, function bio_rdp_tls_ctrl(), case BIO_C_SET_SSL, BIO_push(3) is definitely called with a second argument that is *not* at the beginning of its chain. Admittedly, that code is hard to fathom, but it does appear to result in a bogus prev_bio pointer without this patch. The practical impact of this bug in this and other software remains unknown; the consequences might possibly escalate up to use-after-free issues if BIO_pop(3) is afterwards called on corrupted BIO objects. OK tb@
2022-12-06Improve the poorly designed BIO_set_next(3) API to always preserve allschwarze1-3/+18
invariants of the prev_bio and next_bio fields of all BIO objects in all involved chains, no matter which arguments this function is called with. Both real-world uses of this function (in libssl and freerdp) have been audited to make sure this makes nothing worse. We believe libssl behaves correctly before and after the patch (mostly because the second argument is NULL there), and we believe the code in freerdp behaves incorrectly before and after the patch, leaving a prev_bio pointer in place that is becoming bogus, only in a different object before and after the patch. But after the patch, that bogus pointer is due to a separate bug in BIO_push(3), which we are planning to fix afterwards. Joint work with and OK tb@.
2022-12-06arithmethic -> arithmeticjsg1-3/+3
2022-12-05Unbreak rust-openssl-tests on sparc64tb1-8/+4
For the test compilation using the CC crate, base clang is good enough, so we don't need to pull in another heavy dependency just for this test.
2022-12-05bn_mod_exp.c doesn't need <string.h>tb1-2/+1
2022-12-04userspace: remove vestigial '?' cases from top-level getopt(3) loopscheloha2-4/+2
getopt(3) returns '?' when it encounters a flag not present in the in the optstring or if a flag is missing its option argument. We can handle this case with the "default" failure case with no loss of legibility. Hence, remove all the redundant "case '?':" lines. Prompted by dlg@. With help from dlg@ and millert@. Link: https://marc.info/?l=openbsd-tech&m=167011979726449&w=2 ok naddy@ millert@ dlg@
2022-12-04zap weird spaces $EDITOR added in previoustb1-2/+2
2022-12-03skip rust-openssl-tests on sparc64tb1-3/+17
The issue is likely that the build is trying to compile some generated C code with the prehistoric gcc from base, so add a tentative workaround for that. Since I don't currently have access to a sparc64 box where I could validate this easily and check if the workaround is enough, let's not waste lots of cycles on this.
2022-12-03Clean up makefiletb1-8/+6
2022-12-03biotest needs bio_local.h nowtb1-6/+7
Should have been part of the previous commit
2022-12-03Test BIO_{push,pop}() along a linear chaintb1-1/+135
2022-12-03More cleanuptb1-11/+8
Drop unnecessary loading of error strings, fix error path and consistently print to stdout.
2022-12-03Refactor and fix bn_mod_exp testtb1-80/+86
The amount of copy-paste in this test led to a few bugs and it was hard to spot them since things were done in random order. Use a different approach: compute the result of a^b (mod m) according to BN_mod_exp_simple(), then compare the results of all the other *_mod_exp* functions to that. Reuse the test structure from bn_mod_exp_zero.c to loop over the list of functions. This way we test more functions and don't forget to check some crucial bits.
2022-12-03Add missing checks for BN_mod_exp_{non,}ct()tb1-6/+8
Someone added a few more functions to test, but forgot to check their results, so if they would not do the expected thing that would only be noticed if one of the already tested functions would break.
2022-12-03Fix some ancient silliness with a random bytetb1-8/+5
For nearly 25 years this test has attempted to generate random numbers of bit length between 192 and 319 bits. Unfortunately, it used an unsigned char so instead of generating numbers in the interval [-64..63] and add them to 256, it used numbers in the intervals [0..63] and [192..255]...
2022-12-02Drop 'perhaps a little', plus grammar and spelling nitstb1-5/+5
BIO_push() and BIO_pop() are misnamed. No need to gently and politely suggest that their 'names [...] are perhaps a little misleading'.
2022-12-02Revert bio_prev removaltb2-2/+12
As schwarze points out, you can pop any BIO in a chain, not just the first one (bonus points for a great name for this API). The internal doubly linked was used to fix up the BIO chain bio was part of when you BIO_pop() a bio that wasn't in the first position, which is explicitly allowed in our documentation and implied by OpenSSL's.