tb [Sat, 30 Dec 2023 08:58:18 +0000 (08:58 +0000)]
Add extended regress coverage for ASN.1 methods
Validate that every alias resolves to a non-alias in one step and that
non-aliases have pkey_id == pkey_base_id, an info string and a pem_str.
They can be looked up by their pkey_id or pem_str.
Conversely, all these are false for aliases.
tb [Sat, 30 Dec 2023 06:25:56 +0000 (06:25 +0000)]
Fix two more unchecked EVP_PKEY_assign() calls
In SSL{_CTX}_use_RSAPrivateKey() switch from EVP_PKEY_assign_RSA() to
EVP_PKEY_set1_RSA() and hold on to the reference of the the pkey for
the duration of ssl_set_pkey(). Use single exit and other minor style
cleanups.
ok joshua jsing
tb [Fri, 29 Dec 2023 22:37:47 +0000 (22:37 +0000)]
fix previous: key -> parameter
tb [Fri, 29 Dec 2023 19:19:48 +0000 (19:19 +0000)]
A .Xr to DSA_generate_parameters_ex() was lost accidentally
tb [Fri, 29 Dec 2023 19:15:52 +0000 (19:15 +0000)]
sync
tb [Fri, 29 Dec 2023 19:15:15 +0000 (19:15 +0000)]
Move DSA_generate_parameters.3 to DSA_generate_parameters_ex.3
tb [Fri, 29 Dec 2023 19:12:46 +0000 (19:12 +0000)]
Adjust documentation for upcoming DSA_generate_parameters removal
This removes any mention of DSA_generate_parameters in the manuals apart
from a comment that it is intentionally undocumented and adapts cross
references to DSA_generate_parameters_ex. The file itself will be moved
in a second step.
tb [Fri, 29 Dec 2023 19:00:31 +0000 (19:00 +0000)]
ameth_lib: zap trailing empty line
tb [Fri, 29 Dec 2023 18:52:11 +0000 (18:52 +0000)]
bump version
tb [Fri, 29 Dec 2023 18:49:06 +0000 (18:49 +0000)]
eckey: adjust some variable names and unwrap function definitions
ok jsing
tb [Fri, 29 Dec 2023 18:48:25 +0000 (18:48 +0000)]
Clean up old_ec_priv_decode()
As per usual. Stylistic adjustments and missing error check.
ok jsing
tb [Fri, 29 Dec 2023 18:47:47 +0000 (18:47 +0000)]
Clean up eckey_param_decode()
This aligns eckey's parameter decoding routine with the one of other
cipher abstractions: better variable names, single exit and add missing
check for EVP_PKEY_assign_EC_KEY().
ok jsing
tb [Fri, 29 Dec 2023 18:46:24 +0000 (18:46 +0000)]
Rework eckey_priv_decode()
Factor out the pubkey computation and bring it into more sensible form.
This removes lots of pointless setting of errors (twice) and makes the
code a bit easier on the eyes. Other than that perform some stylistic
cleanup like single exit and add an error check for EVP_PKEY_assign().
ok jsing
tb [Fri, 29 Dec 2023 18:45:39 +0000 (18:45 +0000)]
Move a call to X509_ALGOR_get0() down a line
tb [Fri, 29 Dec 2023 17:15:10 +0000 (17:15 +0000)]
Pass correct file to warnx()
We end up here only if mft1 == NULL, which can happen because file1 == NULL.
Use file2 instead because mft2 != NULL implies file2 != NULL.
ok job
claudio [Fri, 29 Dec 2023 16:02:29 +0000 (16:02 +0000)]
There is no need to include sys/uio.h here.
job [Fri, 29 Dec 2023 14:35:43 +0000 (14:35 +0000)]
Fix a NULL access or use-after-free bug
This is a bandaid, the proc_parser_mft() is too complex and needs reworking
OK tb@
jca [Fri, 29 Dec 2023 13:23:27 +0000 (13:23 +0000)]
Use a per cpu pool cache for pmap_pv_pool
Improves performance on my 8 cores box. ok cheloha@ kettenis@
tb [Fri, 29 Dec 2023 12:24:33 +0000 (12:24 +0000)]
Neuter the SSL_set_debug(3) API
The TLSv1.3 stack didn't support this in the first place, and in the legacy
stack it only added some dubious BIO_flush(3) calls. The sleep call between
SSL_read(3) and SSL_write(3) advertised in the comment next to the flag has
been a sleep call in the s_server since time immemorial, nota bene between
calls to BIO_gets(3). Anyway. This can all go and what remains will go with
the next major bump.
ok jsing
tb [Fri, 29 Dec 2023 12:15:49 +0000 (12:15 +0000)]
Garbage collect the last users of SSL_set_debug(3)
This undocumented, incomplete public function has never done anything
useful. It will be removed from libssl. Removing it from openssl(1)
clears the way for this.
ok jsing
tb [Fri, 29 Dec 2023 12:06:48 +0000 (12:06 +0000)]
s_client: pause hasn't worked in ages. Just ignore it
ok jsing
claudio [Fri, 29 Dec 2023 11:57:38 +0000 (11:57 +0000)]
There is no default for the rtable login.conf capability.
If it is not set it will use the current rtable. It will not force every
login to the default (0) rtable. For that rtable should be set to 0.
OK schwarze@ a long time ago
claudio [Fri, 29 Dec 2023 11:48:47 +0000 (11:48 +0000)]
Cleanup required headers form imsg.h.
Right now only sys/queue.h is required to be included for imsg.h. The
only exception is if imsg_composev() is used, then sys/uio.h is needed
to access struct iovec.
OK tb@
bluhm [Fri, 29 Dec 2023 11:43:04 +0000 (11:43 +0000)]
Make loopback interface counters MP safe.
Create and use the MP safe version of the interface counters for
lo(4). Input packets were counted twice. As interface input queue
is already counting, remove input count in if_input_local().
Multicast and siplex packets are counted at the ethernet interface.
Add a comment that this not MP safe.
OK mvs@
tb [Fri, 29 Dec 2023 10:59:00 +0000 (10:59 +0000)]
Move the EVP_PKEY_asn1_* API that will stay to evp/p_lib.c
Most of these functions are only called from this file internally apart
from the pem_str lookups from pem/. In the next major bump we can then
remove asn/ameth_lib.c. Also move EVP_PKEY_ASN1_METHOD to evp_local.h.
While this is used to dispatch to various ASN.1 decoding routines, it
doesn't fit into asn1/ at all.
tb [Fri, 29 Dec 2023 10:31:50 +0000 (10:31 +0000)]
Zap some whitespace
tb [Fri, 29 Dec 2023 10:17:26 +0000 (10:17 +0000)]
Replace outdated comment on EVP_PKEY_asn1_find() with a todo item
tb [Fri, 29 Dec 2023 10:08:44 +0000 (10:08 +0000)]
Move EVP_PKEY_asn1_add* to the end of the file
Also add a reminder to remove most of the public API in this file.
kettenis [Fri, 29 Dec 2023 10:00:18 +0000 (10:00 +0000)]
Support for "control" nodes was removed from the drm subsystem some time
ago, but some code in drmopen() remained which means that opening a drm
device node with a minor that matches the range for the "control" nodes
will hit a kernel assertion. A similar issue exists for "render" nodes
corresponding to a driver that only supports KMS (such as rkdrm(4)).
Add checks to see if the minor is valid and return ENXIO if that isn't the
case to prevent a kernel crash.
ok jsg@, miod@
tb [Fri, 29 Dec 2023 07:22:47 +0000 (07:22 +0000)]
Move the EVP_MD block size accessor down
This way all the EVP_MD accessors are in the order of the struct fields.
Well, arguably the EVP_MD_meth* should come first, but they are scheduled
to go meet the dodo.
tb [Fri, 29 Dec 2023 07:14:02 +0000 (07:14 +0000)]
Move the EVP_MD_CTX flag accessors up a bit
This way the accessors are sorted the same way as the struct.
tb [Fri, 29 Dec 2023 07:09:44 +0000 (07:09 +0000)]
Hoist EVP_MD_CTX accessors to after EVP_MD_CTX_ctrl
This way the file has EVP_Digest*, then EVP_MD_CTX new/free/clean,
then ctrl then the EVP_MD_CTX accessors, then the EVP_MD accessors
and finally the EVP_MD_meth stuff and the order of things starts
making a wee bit of sense.
tb [Fri, 29 Dec 2023 07:02:28 +0000 (07:02 +0000)]
Move init/reset next to cleanup
This way new/free aka create/destroy are next to each other. reset/cleanup
are the same thing and init will join the club after some other fixing
because two APIs that do the exact same thing aren't enough.
tb [Fri, 29 Dec 2023 06:59:24 +0000 (06:59 +0000)]
Move the copy/copy_ex stuff down below the new/free/clear mess
tb [Fri, 29 Dec 2023 06:56:38 +0000 (06:56 +0000)]
Merge the EVP_CIPHER_meth_* API into evp_cipher.c
tb [Fri, 29 Dec 2023 06:17:58 +0000 (06:17 +0000)]
Merge the remainder of evp_lib.c into evp_cipher.c
tb [Fri, 29 Dec 2023 06:08:01 +0000 (06:08 +0000)]
Move the middle part of evp_lib.c to evp_digest.c
These are ~200 lines of EVP_MD API that separated two parts of the file
dedicated to EVP_CIPHER thingies.
tb [Fri, 29 Dec 2023 05:57:24 +0000 (05:57 +0000)]
Use more consistent naming for some files in evp
EVP_Digest{Init,Update,Final}() move from digest.c to evp_digest.c which
will become the home of all things related to EVP_MD{,_CTX} handling.
EVP_Cipher{Init,Update,Final}() move from evp_enc.c to evp_cipher.c which
will become the home of all things related to EVP_CIPHER{,_CTX} handling.
EVP_Encode{Init,Update,Final}() move from encode.c to evp_encode.c which
already is the home of EVP_ENCODE_CTX_{new,free}().
discussed with jsing
tb [Fri, 29 Dec 2023 05:33:32 +0000 (05:33 +0000)]
Use a void pointer rather than char for method_data
This way we don't need to cast from BY_DIR * to char * and back in
its only consumer, the lovely by_dir.
tb [Fri, 29 Dec 2023 05:17:20 +0000 (05:17 +0000)]
Remove the unused init flag of X509_LOOKUP
deraadt [Fri, 29 Dec 2023 02:42:20 +0000 (02:42 +0000)]
sync
aisha [Fri, 29 Dec 2023 02:37:39 +0000 (02:37 +0000)]
more regress tests for RB_* and RBT_* macros
help, pointers and OK bluhm@
tb [Thu, 28 Dec 2023 22:12:37 +0000 (22:12 +0000)]
Clean up pkey_ec_paramgen()
This is basically the same as the dh and dsa version, except it's
different because it's EC. Single exit, uniform error checking.
"Plug" another leak.
With this I earned another shining turd for my collection.
ok jsing
tb [Thu, 28 Dec 2023 22:11:26 +0000 (22:11 +0000)]
Rework pkey_das_paramgen()
Another copy-paste-then-tweak-and-diverge version of the same old thing.
Fix it the same way as pkey_rsa_paramgen() and pkey_dh_paramgen(). The
callbacks are initialized at the top and the weird error checking is
turned into something much simpler.
ok jsing
tb [Thu, 28 Dec 2023 22:10:33 +0000 (22:10 +0000)]
Rework pkey_dh_paramgen()
Similar to pkey_rsa_paramgen() this function does some strange dances
with the pkey_gencb and initialization plus missing error checks. Fix
all that and use the idiom established in previous commits.
ok jsing
tb [Thu, 28 Dec 2023 22:09:10 +0000 (22:09 +0000)]
Fix pkey_ec_keygen()
The EC code came later, and people got better at writing terrible code.
In this case, they could remain quite close to what they copy-pasted
from DH, so it was relatively straightforward (for once). There's only
one slight extra twist and that's easily dealt with.
ok jsing
tb [Thu, 28 Dec 2023 22:07:23 +0000 (22:07 +0000)]
Rework pkey_dsa_keygen()
Very similar to pkey_dh_keygen(): single exit and hold on to an extra
reference by calling EVP_PKEY_set1_DSA() instead of assigning the DSA
to the pkey. "Fixes" another leak that Coverity missed.
ok jsing
tb [Thu, 28 Dec 2023 22:06:41 +0000 (22:06 +0000)]
Rework pkey_dh_keygen()
Single exit, fix error checking and hold on to the DH by keeping a
reference. In other words, switch from EVP_PKEY_assign() to using
EVP_PKEY_set1_DH() and free unconditionally in the error path.
ok jsing
tb [Thu, 28 Dec 2023 22:00:56 +0000 (22:00 +0000)]
Rework and fix pkey_hmac_keygen()
The usual: single exit, error check all functions even if they can't
actually fail. This one was flagged again.
ok jsing
CID 471706 (false positive)
tb [Thu, 28 Dec 2023 21:59:07 +0000 (21:59 +0000)]
Rework pkey_rsa_keygen()
As usual, make the function single exit. Initialize the pkey callback
pointer and the BN_GENCB on the stack at the top rather than relying
on the weird trans_cb() in evp_pkey_set_cb_translate() to do so.
Greatly simplify the control flow and add missing error checks.
ok jsing
tb [Thu, 28 Dec 2023 21:58:12 +0000 (21:58 +0000)]
Rework rsa_priv_decode()
Turn the function into single exit and error check EVP_PKEY_assign()
for style.
ok jsing
tb [Thu, 28 Dec 2023 21:57:08 +0000 (21:57 +0000)]
Clean up old_rsa_priv_decode()
Again change this function into the single exit idiom, and error check
EVP_PKEY_assign().
ok jsing
tb [Thu, 28 Dec 2023 21:56:12 +0000 (21:56 +0000)]
Clean up and fix pkey_cmac_keygen()
A void pointer can be passed without any cast or assigning it to an
intermediate variable. That's one of hte puzzling things in old OpenSSL
code: there are plenty of unnecessary casts and assignments of void
pointers.
Make use of this fact and rework the function to be single exit, error
check consistently, including the EVP_PKEY_assign() call that can't
really fail and free the cmkey on exit.
Why coverity didn't flag this one is another mystery.
ok jsing
tb [Thu, 28 Dec 2023 21:53:09 +0000 (21:53 +0000)]
Replace EVP_KEY_assign_GOST() calls with EVP_PKEY_set_type()
Calling EVP_KEY_assign_GOST(pkey, NULL) has the same effect as calling
EVP_PKEY_set_type(pkey, EVP_PKEY_GOSTR01). The only difference is that
the latter form allows for error checking while the former won't let
you do that. Add comments explaining what we're actually doing: freeing
and zeroing the pkey->pkey union.
ok jsing
tb [Thu, 28 Dec 2023 21:49:07 +0000 (21:49 +0000)]
Fix another EVP_PKEY_assign_GOST() call
Again this can't actually fail, but if it did, things would leak.
Call GOST_KEY_free() in the error path.
ok jsing
CID 471706 (false positive)
tb [Thu, 28 Dec 2023 21:47:17 +0000 (21:47 +0000)]
Clean up pkey_gost_mac_keygen()
Make this function single exit, check and assign and finally error
check EVP_PKEY_assign(). This can't actually fail currently, but
if it did, things would leak. Free the key data with freezero.
ok jsing
CID 471704 (false positive)
espie [Thu, 28 Dec 2023 18:05:32 +0000 (18:05 +0000)]
don't add values we won't print, use scandir properly
okay tb@
(logic NOT simplified because I don't want to risk introducing bugs,
and the compiler knows as much boolean logic as me)
stsp [Thu, 28 Dec 2023 17:36:28 +0000 (17:36 +0000)]
Introduce qwx(4), a work-in-progress port of the Linux ath11k driver.
This driver is not working yet. Scanning almost works but a lot more
work remains to be done. So far most of the porting work was done by
myself, with some help from mpi, patrick, and kettenis.
Obviously this driver remains disabled for now. Enable relevant lines
in the kernel config if you want to help out with development.
At present firmware files must be obtained manually and placed
in the directory /etc/firmware/qwx/WCN6855/hw2.1/
This will be improved later.
Thanks to the OpenBSD Foundation for supporting this effort.
aisha [Thu, 28 Dec 2023 16:21:08 +0000 (16:21 +0000)]
use RB_FOREACH_SAFE for pf_purge_expired_src_nodes
OK bluhm@
uwe [Thu, 28 Dec 2023 14:30:28 +0000 (14:30 +0000)]
fix Tx watchdog trigger and freeze in dwqe(4)
dwqe(4) interfaces may trigger the "dwqe_watchdog" function and stop
transmitting packets under heavy Tx load. In this situation, ifconfig(8)
will permanently show OACTIVE until the interface is restarted (ifconfig
down/up).
The problem seems to be triggered by writing to the Tx ring tail pointer
register multiple times during dwqe_start(). Updating the Tx ring tail
pointer only after all Tx descriptors have been updated seems to fix it.
The fix is based on the eqos(4) driver in NetBSD. Verified on an Intel
Elkhart Lake machine but might affect other platforms with DesignWare
Ethernet Quality-of-Service Controller version 4.
Testing by bluhm@, ok kettenis@
uwe [Thu, 28 Dec 2023 14:03:21 +0000 (14:03 +0000)]
assume RGMII-to-Copper mode by default in eephy(4) for 88E151x PHYs
The desired MII mode must be programmed explicitly for Marvel Atlantis
88E1512/
88E1514 variants and we already do this for SGMII.
This change adds a missing case for RGMII-to-Copper that assumes RGMII,
unless the MAC driver sets MII_SGMII before calling mii_attach() or the
mode has already been programmed. (RGMII-to-Copper is also the hardware
default for E1510 and E1518.)
Suggestions and ok kettenis@
kettenis [Thu, 28 Dec 2023 13:32:56 +0000 (13:32 +0000)]
Add stream ID mapping support for PCIe controller found on M2 Pro/Max SoCs.
ok patrick@
jeremy [Wed, 27 Dec 2023 23:46:42 +0000 (23:46 +0000)]
Update lang/ruby module documentation for Ruby 3.3
nicm [Wed, 27 Dec 2023 20:42:01 +0000 (20:42 +0000)]
Only wrap pattern in *s if using a regular expression.
nicm [Wed, 27 Dec 2023 20:23:59 +0000 (20:23 +0000)]
Remove flags from the prefix before comparing with the received key so
that modifier keys with flags work correctly, GitHub issue 3764.
nicm [Wed, 27 Dec 2023 20:20:50 +0000 (20:20 +0000)]
groff apparently generates broken output for some common characters in
mdoc, so escaped versions have to be used instead. From Alexis
Hildebrandt in GitHub issue 3762.
nicm [Wed, 27 Dec 2023 20:17:13 +0000 (20:17 +0000)]
Always initialize screen mode, GitHub issue 3750 from Ding Fei.
nicm [Wed, 27 Dec 2023 20:13:35 +0000 (20:13 +0000)]
Correctly handle window ops with no pane, GitHub issue 3747.
claudio [Wed, 27 Dec 2023 17:22:25 +0000 (17:22 +0000)]
Fix handling of skipped elements on the very first element transmitted.
rsync compares e.g. the first mtime against 0, if the mtime is the epoch
then rsync will skip this field and openrsync will choke when receiving it.
So if there is no first element but a FLIST_XYZ_SAME flag is use 0 as
value.
Problem noticed by job@
OK tb@ job@ and yoda@ for fixing the if statements
jsing [Wed, 27 Dec 2023 12:34:32 +0000 (12:34 +0000)]
Add initial regress for CRYPTO_EX_DATA.
jsing [Wed, 27 Dec 2023 12:26:17 +0000 (12:26 +0000)]
Remove engine regress.
Engines are no longer a thing.
Discussed with tb@
claudio [Wed, 27 Dec 2023 12:00:30 +0000 (12:00 +0000)]
Refactor rtr_parse_error() so that even a NO_DATA_AVAILABLE is logged
as last error. So that bgpctl can show that there was no data available.
OK tb@
op [Wed, 27 Dec 2023 11:29:56 +0000 (11:29 +0000)]
sync table(5) with reality
There are two different parser for table(5)s with different edge cases.
Adjust the documentation to what the strictier of the two (smtpd
internal parser) accepts, even if makemap(8) allows for more.
In particular, adjust the description for the comments (that cannot be
'anywhere in the file'), document the special comment @list and mention
that splitting is done on the colon character too.
ok and many improvements from jmc@
jca [Wed, 27 Dec 2023 08:29:41 +0000 (08:29 +0000)]
'pax' format support for mtime and atime
Access time can't be represented by ustar, so always include it when
using the pax format. Also include an extended header record for mtime
if the file modification time can't be fully represented by ustar (eg
subsecond resolution).
Input & ok millert@
tb [Wed, 27 Dec 2023 07:17:39 +0000 (07:17 +0000)]
Mark rrdp debug logging functions as used in regress
ok claudio
tb [Wed, 27 Dec 2023 07:15:55 +0000 (07:15 +0000)]
Rework the warnings on internet resources
Unify the printing of warnings about AS numbers and IP address blocks to
use a call to as_warn() and ip_warn(). Fix a bug in the latter where the
upper bound of an IP range didn't take the RFC 3779 encoding into account
and passed the address directly to inet_pton() rather than filling the
missing bits with 1. Switch the argument order to match the warnings and
tweak some warning messages.
ok claudio job
tb [Wed, 27 Dec 2023 01:55:25 +0000 (01:55 +0000)]
X509_LOOKUP_shutdown() became a noop.
That we are still calling this (NB without error check because heritage),
made coverity unhappy.
CID 471705
schwarze [Tue, 26 Dec 2023 22:13:00 +0000 (22:13 +0000)]
Rename some argument placeholders to be less cryptic,
in particular s/inl/in_len/ and s/outl/out_len/ as suggested by tb@.
While here, also get rid of the "outm" placeholder that has been
around since the file was added to OpenSSL in 2000, replacing it
with the usual "out" in the four function prototypes affected; tb@
and myself suspect it was simply a typo followed by copy and paste.
Slightly improve variable naming in the examples, too, for clarity and
consistency, even though that doesn't turn the examples into good examples.
OK tb@
schwarze [Tue, 26 Dec 2023 19:09:08 +0000 (19:09 +0000)]
Close some major gaps in the documentation of EVP_Cipher(3),
and describe EVP_CIPHER_CTX_init(3) in a less misleading way.
Joint work with and OK tb@.
miod [Tue, 26 Dec 2023 14:04:50 +0000 (14:04 +0000)]
Update documentation URL
job [Tue, 26 Dec 2023 13:36:18 +0000 (13:36 +0000)]
Align the other RIRs with the recent clarifications from AFRINIC
Following https://lists.afrinic.net/pipermail/dbwg/2023-December/000496.html
Simply apply the inverse of 'afrinic.constraints' r1.2 to the other RIR files
(since no resources can be transferred from AFRINIC to any other RIRs).
OK tb@
tb [Tue, 26 Dec 2023 11:03:27 +0000 (11:03 +0000)]
Do not accept empty delta elements
Ties de Kock found RRDP content that doesn't match the XML schema, most
likely generated by krill: https://github.com/NLnetLabs/krill/issues/1180
Use the state machine to mark a new delta element as empty and check at
the end whether that state was changed (which means it contained publish
or withdraw elements). If so, raise a parse failure.
ok claudio job
kettenis [Tue, 26 Dec 2023 09:25:15 +0000 (09:25 +0000)]
Apple machines with multiple speakers typically have the shutdown pin of
the digital amplifier codecs wired up to a single GPIO. This is apparently
problematic for Linux and Asahi Linux changed their device trees to use a
regulator instead to such that reference counting makes sure that shutdown
isn't asserted until all codecs are ready for it. Follow suit, even though
our regulator code doesn't do the proper reference counting yet.
ok patrick@
kettenis [Tue, 26 Dec 2023 09:19:15 +0000 (09:19 +0000)]
Improve handling of SError interrupts. Print some useful information and
allow additional information to be printed for specific CPU types. Use
this to print the L2C registers on Apple CPUs which can be very useful
in tracking down the source of certain SError interrupts.
ok miod@, dlg@
tb [Tue, 26 Dec 2023 09:04:30 +0000 (09:04 +0000)]
EVP_CipherInit(): remove cleanup call
There is a bizarre EVP_CIPHER_CTX_cleanup() call in EVP_CipherInit()
leading to a subtle behavior difference with EVP_CipherInit_ex().
The history is that before EVP_CIPHER_CTX was made opaque, a context would
often live on the stack (hello, MariaDB) and the EVP_CIPHER_CTX_cleanup()
call was in fact an EVP_CIPHER_CTX_init() which just zeroes out the struct.
The problem with doing this is that on context reuse there could be data
hanging off it, causing leaks. Attempts were made to clean up things in
EVP_CipherFinal*(), but that broke applications reaching into the context
afterward, so they were removed again. Later on, opacity allowed changing
the _init() to a _cleanup() since EVP_CIPHER_CTX could no longer live on
the stack, so it would no longer contain garbage. I have to correct myself:
it would no longer contain stack garbage.
Now: EVP_CipherInit_ex() does some extra dances to preserve the AES key
wrap flag, which is cleared unconditionally in EVP_CipherInit(). That's
annoying to document and very likely never going to be an issue in the
wild: you'd need to do key wrap and then use the same context for use
with a cipher that does not allow key wrap for this to make a difference.
This way, all our EVP_{Cipher,Decrypt,Encrypt}*_ex() functions are now
trivially wrapped by their non-_ex() versions.
ok jsing
tb [Tue, 26 Dec 2023 08:39:28 +0000 (08:39 +0000)]
EVP_CipherInit_ex() merge two code paths
Clean up the cipher context unconditionally if the cipher is being set.
This allows doing the dance to retain the key wrap flag only once and
makes it more obvious that allocating the cipher data doesn't leak.
suggested by/ok jsing
tb [Mon, 25 Dec 2023 22:41:50 +0000 (22:41 +0000)]
Move EVP_PKEY_assign() a bit up and tweak it slightly
ok jsing
tb [Mon, 25 Dec 2023 22:14:23 +0000 (22:14 +0000)]
Remove unused X509_LOOKUP_METHODs
None of these function pointers were ever set. Now that the structure is
opaque they won't ever be, so time for them to hit the bitbucket. Infinite
extensibility of the toolkit results in complications, bugs, and dead code.
ok jsing
tb [Mon, 25 Dec 2023 22:02:59 +0000 (22:02 +0000)]
Avoid out-of-bounds accesses in ASN1_BIT_STRING_{get,set}()
If a negative n is passed, these functions would underrun the bitstring's
data array. So add checks for that and drop spades of unnecessary parens.
These functions are quite broken anyway. The setter attempts to zap the
unnecessary trailing zero octets, but fails to do so if the bit being
cleared isn't already set. Worse is the getter where you can't tell an
error (like attempting an out-of-bounds read) from the bit being unset.
ok joshua
tb [Mon, 25 Dec 2023 21:55:31 +0000 (21:55 +0000)]
Rename a few ret into pkey
tb [Mon, 25 Dec 2023 21:51:57 +0000 (21:51 +0000)]
Rework EVP_PKEY_set_type{,_str}()
These two functions previously wrapped a pkey_set_type() helper, which
was an utter mess because of ENGINE. With the long awaited departure of
ENGINE, this function became a lot simpler. A further simplification is
obtained by not doing the optimization to avoid an ameth lookup: this
requires walking a list of 11 ameths. We should consider bsearch()...
With this gone and a saner implementation of EVP_PKEY_free_it(), we can
implement these functions with a dozen lines of code each.
ok jsing
tb [Mon, 25 Dec 2023 21:41:19 +0000 (21:41 +0000)]
Rework EVP_PKEY_free()
Use pkey instead of x, remove the pointless variable i, no need to check
for NULL before sk_X509_ATTRIBUTE_pop_free(), switch to freezero() to
leave fewer invalid pointers around.
ok jsing
tb [Mon, 25 Dec 2023 21:37:26 +0000 (21:37 +0000)]
Move EVP_PKEY_free() up next to evp_pkey_free_pkey_ptr()
ok jsing
tb [Mon, 25 Dec 2023 21:36:05 +0000 (21:36 +0000)]
Fix EVP_PKEY_up_ref() - must have hit ^X somehow
tb [Mon, 25 Dec 2023 21:33:50 +0000 (21:33 +0000)]
Rework evp_pkey_free_pkey_ptr()
Rename the variable from x into pkey, make it NULL safe and unindent.
ok jsing
tb [Mon, 25 Dec 2023 21:31:58 +0000 (21:31 +0000)]
Rename EVP_PKEY_free_it() into evp_pkey_free_pkey_ptr()
ok jsing
tb [Mon, 25 Dec 2023 21:30:53 +0000 (21:30 +0000)]
Move the confusingly named EVP_PKEY_free_it() a bit up
ok jsing
tb [Mon, 25 Dec 2023 21:27:03 +0000 (21:27 +0000)]
Simplify EVP_PKEY_up_ref()
There is no need for a local variable and a ternary operator here.
ok jsing
tb [Mon, 25 Dec 2023 21:25:24 +0000 (21:25 +0000)]
Switch EVP_PKEY_new() from malloc() to calloc()
ok jsing
schwarze [Mon, 25 Dec 2023 15:52:18 +0000 (15:52 +0000)]
Clarify that the ENGINE argument is ignored; OK tb@.
While here, also switch the argument placeholder from *impl to *engine
as suggested by tb@.