openbsd
2 months agoFix argument names: des_in -> der_in and des_out -> der_out main
tb [Thu, 24 Oct 2024 21:42:10 +0000 (21:42 +0000)]
Fix argument names: des_in -> der_in and des_out -> der_out

2 months agoAttach psp(4) version 1.
bluhm [Thu, 24 Oct 2024 18:52:59 +0000 (18:52 +0000)]
Attach psp(4) version 1.

Some AMD CPUs come with an older platform security processor.  It
is detectet by PCI Id and has different register offsets.  Move the
dynamic register offsets into psp_softc.  The PCI attach code is
now in a separate psp_pci.c file and detects the version of the psp
along with the ccp.  The attach code is more verbose to display
where problems might occur.  Now the ccp_wait() has 2 seconds
timeout, both for polling and interrupt.  Also prevent a useless
bus_space_read_4().

OK hshoexer@

2 months agoChange macppc's ci_idepth from -1 to 0 when no interrupts
gkoehler [Thu, 24 Oct 2024 17:37:06 +0000 (17:37 +0000)]
Change macppc's ci_idepth from -1 to 0 when no interrupts

Now curcpu()->ci_idepth == 0 would work on macppc as it does on
powerpc64 and other archs, by checking that we aren't in an interrupt.
This also makes macppc's splassert_check() less different.

locore.S checks for the 1st interrupt when it increments ci_idepth.
Using -1 for no interrupts had saved an instruction, as "addic." was
short for "addi; cmpwi".  Using 0, it now does "cmpwi; addi" to
compare ci_idepth with 0 before incrementing it.

ok mpi@

2 months agoStop leaking kernel stack guard pages.
kettenis [Thu, 24 Oct 2024 17:37:03 +0000 (17:37 +0000)]
Stop leaking kernel stack guard pages.

ok mpi@, anton@

2 months agoAdjust ldapclient prototype to prevent an "argument of type 'int[2]' with
claudio [Thu, 24 Oct 2024 11:47:36 +0000 (11:47 +0000)]
Adjust ldapclient prototype to prevent an "argument of type 'int[2]' with
mismatched bound" warning.
OK tb@

2 months agoremove unused T_BITS define; ok miod@
jsg [Thu, 24 Oct 2024 06:30:28 +0000 (06:30 +0000)]
remove unused T_BITS define; ok miod@

2 months agoAdd missing error check for CBB_init_fixed()
tb [Thu, 24 Oct 2024 05:57:25 +0000 (05:57 +0000)]
Add missing error check for CBB_init_fixed()

CID 511280

2 months agoAdd a ci_intrdepth field to struct cpu_info for sh, and use it to implement
miod [Thu, 24 Oct 2024 05:28:00 +0000 (05:28 +0000)]
Add a ci_intrdepth field to struct cpu_info for sh, and use it to implement
CLKF_INTR properly.

2 months agotest SIGUSR1 dropping all keys from ssh-agent
djm [Thu, 24 Oct 2024 03:28:34 +0000 (03:28 +0000)]
test SIGUSR1 dropping all keys from ssh-agent

2 months agoamake ssh-agent drop all keys when it receives SIGUSR1;
djm [Thu, 24 Oct 2024 03:15:47 +0000 (03:15 +0000)]
amake ssh-agent drop all keys when it receives SIGUSR1;
let's users zap keys without access to $SSH_AUTH_SOCK

ok deraadt@

2 months agorelax valid_domain() checks to allow an underscore as the first
djm [Thu, 24 Oct 2024 03:14:37 +0000 (03:14 +0000)]
relax valid_domain() checks to allow an underscore as the first
character. ok deraadt@

2 months agoRemove not-used-in-the-last-20-years-or-so defines.
miod [Wed, 23 Oct 2024 18:45:34 +0000 (18:45 +0000)]
Remove not-used-in-the-last-20-years-or-so defines.

2 months agoec_point_conversion: cosmetics
tb [Wed, 23 Oct 2024 15:06:46 +0000 (15:06 +0000)]
ec_point_conversion: cosmetics

2 months agoec_point_conversion: extend test coverage by translating back the
tb [Wed, 23 Oct 2024 14:10:03 +0000 (14:10 +0000)]
ec_point_conversion: extend test coverage by translating back the
point to an octet string and match with the initial octet string.

would have caught the regression found by anton

2 months agoEC_POINT_point2oct() need to special case the point at infinity
tb [Wed, 23 Oct 2024 13:42:50 +0000 (13:42 +0000)]
EC_POINT_point2oct() need to special case the point at infinity

This is annoying since it undoes some polishing done before commit and
reintroduces an unpleasant asymmetry.

found by anton via openssl-ruby tests
ok jsing

2 months agoAppend fd to the variable names proc, rsync, rrdp, http since these variables
claudio [Wed, 23 Oct 2024 12:09:14 +0000 (12:09 +0000)]
Append fd to the variable names proc, rsync, rrdp, http since these variables
are used to store file descriptors.
OK tb@

2 months agoEC_get_builtin_curves(): the most appropriate name for a list of curves...
tb [Wed, 23 Oct 2024 10:41:51 +0000 (10:41 +0000)]
EC_get_builtin_curves(): the most appropriate name for a list of curves...

... is obviously r.

2 months agoRename `ci_in_intr' to `ci_idepth'.
mpi [Wed, 23 Oct 2024 07:52:55 +0000 (07:52 +0000)]
Rename `ci_in_intr' to `ci_idepth'.

ok miod@

2 months agoRename `ci_intrdepth' to `ci_idepth'.
mpi [Wed, 23 Oct 2024 07:41:44 +0000 (07:41 +0000)]
Rename `ci_intrdepth' to `ci_idepth'.

ok jsg@, aoyama@

2 months agoRename `ci_intrdepth' to `ci_idepth'.
mpi [Wed, 23 Oct 2024 07:40:20 +0000 (07:40 +0000)]
Rename `ci_intrdepth' to `ci_idepth'.

ok jsg@, visa@

2 months agoDecrement uobj reference count without KERNEL_LOCK().
mpi [Wed, 23 Oct 2024 07:18:44 +0000 (07:18 +0000)]
Decrement uobj reference count without KERNEL_LOCK().

Reduce KERNEL_LOCK() contention when tearing down file-backed regions.  Here
it is safe to interleave the KERNEL_LOCK() and a rwlock because the former
is released if the latter is contented.

Contention analysed by and ok claudio@, ok kettenis@

2 months agodrm/amdgpu: prevent BO_HANDLES error from being overwritten
jsg [Wed, 23 Oct 2024 04:16:05 +0000 (04:16 +0000)]
drm/amdgpu: prevent BO_HANDLES error from being overwritten

From Mohammed Anees
64cf93b87fe34e72557de294718019c0ad2931b4 in linux-6.6.y/6.6.58
c0ec082f10b7a1fd25e8c1e2a686440da913b7a3 in mainline linux

2 months agodrm/amdgpu/swsmu: Only force workload setup on init
jsg [Wed, 23 Oct 2024 04:10:16 +0000 (04:10 +0000)]
drm/amdgpu/swsmu: Only force workload setup on init

From Alex Deucher
db0978d3ed8b1f69b6e09c3ccb66897fd2a9f6d7 in linux-6.6.y/6.6.58
cb07c8338fc2b9d5f949a19d4a07ee4d5ecf8793 in mainline linux

2 months agodrm/radeon: Fix encoder->possible_clones
jsg [Wed, 23 Oct 2024 04:07:37 +0000 (04:07 +0000)]
drm/radeon: Fix encoder->possible_clones

From Ville Syrjala
1a235af0216411a32ab4db54f7bd19020b46c86d in linux-6.6.y/6.6.58
28127dba64d8ae1a0b737b973d6d029908599611 in mainline linux

2 months agoremove duplicate defines
jsg [Wed, 23 Oct 2024 03:14:32 +0000 (03:14 +0000)]
remove duplicate defines

2 months agoremove duplicate IWX_NVM_GET_INFO define
jsg [Wed, 23 Oct 2024 02:16:40 +0000 (02:16 +0000)]
remove duplicate IWX_NVM_GET_INFO define

2 months agoremove duplicate defines; ok tb@
jsg [Wed, 23 Oct 2024 01:57:19 +0000 (01:57 +0000)]
remove duplicate defines; ok tb@

2 months agoremove duplicate MCX_CAP_DEVICE_DRAIN_SIGERR define
jsg [Wed, 23 Oct 2024 01:47:47 +0000 (01:47 +0000)]
remove duplicate MCX_CAP_DEVICE_DRAIN_SIGERR define

2 months agoremove duplicate ET_MAC_HDX_REXMIT_MAX define
jsg [Wed, 23 Oct 2024 01:35:43 +0000 (01:35 +0000)]
remove duplicate ET_MAC_HDX_REXMIT_MAX define

2 months agoremove duplicate ESA_MINISRC_OUT_BUFFER_SIZE define
jsg [Wed, 23 Oct 2024 00:53:28 +0000 (00:53 +0000)]
remove duplicate ESA_MINISRC_OUT_BUFFER_SIZE define

2 months agoremove duplicate RT_BUF_SIZE define
jsg [Tue, 22 Oct 2024 22:50:49 +0000 (22:50 +0000)]
remove duplicate RT_BUF_SIZE define

2 months agoremove duplicate X509v3_asid_add_id_or_range.3 line
jsg [Tue, 22 Oct 2024 22:41:01 +0000 (22:41 +0000)]
remove duplicate X509v3_asid_add_id_or_range.3 line

2 months agoremove duplicate rcs id
jsg [Tue, 22 Oct 2024 22:33:06 +0000 (22:33 +0000)]
remove duplicate rcs id

2 months agorc: Use the correct path to sshd-auth's relink kit
lucas [Tue, 22 Oct 2024 22:23:21 +0000 (22:23 +0000)]
rc: Use the correct path to sshd-auth's relink kit

From Josiah Frentsos <jfrent AT tilde.team>

OK tb

2 months agoremove duplicate entry in match table
jsg [Tue, 22 Oct 2024 22:21:25 +0000 (22:21 +0000)]
remove duplicate entry in match table

2 months agoremove duplicate prototype
jsg [Tue, 22 Oct 2024 22:15:38 +0000 (22:15 +0000)]
remove duplicate prototype

2 months agocorrect argument to klist_free(); ok visa@ mvs@
jsg [Tue, 22 Oct 2024 22:05:17 +0000 (22:05 +0000)]
correct argument to klist_free(); ok visa@ mvs@

2 months agoremove redundant include guard in BUS_SPACE_DEBUG path
jsg [Tue, 22 Oct 2024 22:01:58 +0000 (22:01 +0000)]
remove redundant include guard in BUS_SPACE_DEBUG path
incorrectly renamed in rev 1.26

discussed with claudio@

2 months agoput opening { on same line as struct name
jsg [Tue, 22 Oct 2024 21:50:02 +0000 (21:50 +0000)]
put opening { on same line as struct name
ok claudio@

2 months agoMove a check for hybrid point encoding into a helper function
tb [Tue, 22 Oct 2024 21:28:53 +0000 (21:28 +0000)]
Move a check for hybrid point encoding into a helper function

2 months agoRewrite ec_GFp_simple_point2oct() using CBB
tb [Tue, 22 Oct 2024 21:10:45 +0000 (21:10 +0000)]
Rewrite ec_GFp_simple_point2oct() using CBB

Factor ad-hoc inline code into helper functions. Use CBB and
BN_bn2binpad() instead of batshit crazy skip loops and pointer
banging. With all this done, the function becomes relatively
streamlined and pretty much symmetric with the new oct2point()
implementation.

ok jsing

2 months agoRewrite ec_GFp_simple_oct2point() using CBS
tb [Tue, 22 Oct 2024 21:08:49 +0000 (21:08 +0000)]
Rewrite ec_GFp_simple_oct2point() using CBS

Transform the spaghetti in here into something more readable. Factor
various inline checks into helper functions to make the logic clearer.
This is a bit longer but a lot safer and simpler. It accepts exactly
the same input as the original version.

ok jsing

2 months agoStart cleaning up oct2point and point2oct
tb [Tue, 22 Oct 2024 21:06:16 +0000 (21:06 +0000)]
Start cleaning up oct2point and point2oct

The SEC 1 standard defines various ways of encoding an elliptic curve
point as ASN.1 octet string. It's also used for the public key, which
isn't an octet string but a bit string for whatever historic reason.
The public API is incomplete and inconvenient, so we need to jump
through a few hoops to support it and to preserve our own sanity.

Split a small helper function out of ec_GFp_simple_point2oct() that
checks that a uint8_t represents a valid point conversion form. It
supports exactly the four possible variants and helps translating
from point_conversion_form_t at the API boundary.

Reject the form for the point at infinity since the function has
historically done that even for the case that the point actually is
the point at infinity.

ok jsing

2 months agoSuppress warning noise from deprecated OpenSSL API
tb [Tue, 22 Oct 2024 16:31:10 +0000 (16:31 +0000)]
Suppress warning noise from deprecated OpenSSL API

2 months agoRevert marking EC_GROUP_method_of() and EC_METHOD_get_field_type() unused
tb [Tue, 22 Oct 2024 15:54:33 +0000 (15:54 +0000)]
Revert marking EC_GROUP_method_of() and EC_METHOD_get_field_type() unused

breaks tree as noted by krw

2 months agoUse imsg_get_fd() like everywhere else.
claudio [Tue, 22 Oct 2024 15:19:48 +0000 (15:19 +0000)]
Use imsg_get_fd() like everywhere else.
OK florian@ dv@

2 months agoRename `ci_intrdepth' to `ci_idepth'.
mpi [Tue, 22 Oct 2024 12:51:56 +0000 (12:51 +0000)]
Rename `ci_intrdepth' to `ci_idepth'.

ok gkoehler@, jsg@

2 months agoecp_oct.c: add missing includes
tb [Tue, 22 Oct 2024 12:09:57 +0000 (12:09 +0000)]
ecp_oct.c: add missing includes

2 months agoMark EC_GROUP_method_of() and EC_METHOD_get_field_type() as unused
tb [Tue, 22 Oct 2024 12:07:27 +0000 (12:07 +0000)]
Mark EC_GROUP_method_of() and EC_METHOD_get_field_type() as unused

ok jsing

2 months agoProvide and use ec_group_get_field_type()
tb [Tue, 22 Oct 2024 12:06:08 +0000 (12:06 +0000)]
Provide and use ec_group_get_field_type()

All internal uses of EC_METHOD_get_field_type() and EC_GROUP_method_of()
are chained together. Implement this as a single API call that takes a
group and use it throughout. Gets rid of another eyesore in this part of
the tree. Not that there will be a shortage of eyesores anytime soon...

ok jsing

2 months agoInline a use of EC_GROUP_method_of()
tb [Tue, 22 Oct 2024 12:02:43 +0000 (12:02 +0000)]
Inline a use of EC_GROUP_method_of()

We can just reach into the group to obtain its EC_GROUP_METHOD. After all
ec_local.h has to be in scope.  This will permit marking this ugly API as
unused internally after the next commit.

ok jsing

2 months agoProtect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.
claudio [Tue, 22 Oct 2024 11:54:04 +0000 (11:54 +0000)]
Protect the ps_pgrp pointer by either the KERNEL_LOCK or the ps_mtx.

This should be enough to be on the safe side when unlocking ptsignal
where a pr->ps_pgrp->pg_jobc == 0 check happens.
OK mpi@ kettenis@

2 months agoremove prototypes with no matching function
jsg [Tue, 22 Oct 2024 10:14:49 +0000 (10:14 +0000)]
remove prototypes with no matching function

2 months agoRemove sshd logfile in start_sshd, and ssh and sshd log wrappers before
dtucker [Tue, 22 Oct 2024 07:13:28 +0000 (07:13 +0000)]
Remove sshd logfile in start_sshd, and ssh and sshd log wrappers before
recreating them.  Prevents "can't create" errors during tests when
running tests without SUDO after having run them with SUDO.

2 months agoAdd a sshd debug wrapper to run all of the subprograms from the build
dtucker [Tue, 22 Oct 2024 06:16:26 +0000 (06:16 +0000)]
Add a sshd debug wrapper to run all of the subprograms from the build
directory while developing and debugging.  Should help prevent accidentally
testing against unchanged installed sshd-auth and sshd-session binaries.
ok djm@

2 months agoMake debug call printf("%s", NULL) safe. Prevents problems on platforms
dtucker [Tue, 22 Oct 2024 06:13:00 +0000 (06:13 +0000)]
Make debug call printf("%s", NULL) safe.  Prevents problems on platforms
where this isn't safe (which it's not required to be).  ok djm@

2 months agoremove duplicate DEV_ID_PCH2 defines
jsg [Tue, 22 Oct 2024 05:11:14 +0000 (05:11 +0000)]
remove duplicate DEV_ID_PCH2 defines

2 months agocorrect name of define for ISS data abort S1PTW bit
jsg [Tue, 22 Oct 2024 02:58:10 +0000 (02:58 +0000)]
correct name of define for ISS data abort S1PTW bit

2 months agodefine _MACHINE_ARCH not _MACHINE_ARC
jsg [Mon, 21 Oct 2024 22:55:52 +0000 (22:55 +0000)]
define _MACHINE_ARCH not _MACHINE_ARC

2 months agoremove unneeded includes
jsg [Mon, 21 Oct 2024 22:04:13 +0000 (22:04 +0000)]
remove unneeded includes

2 months agoCorrectly report print screen key in raw mode (i.e. under X); problem
miod [Mon, 21 Oct 2024 19:05:31 +0000 (19:05 +0000)]
Correctly report print screen key in raw mode (i.e. under X); problem
reported by kirill@

2 months agoWe have not been swapping out kernel stacks since forever. So just
kettenis [Mon, 21 Oct 2024 18:27:34 +0000 (18:27 +0000)]
We have not been swapping out kernel stacks since forever.  So just
allocate the uarea with zeroed pages using km_alloc(9).  Adjust the amd64
code that creates a guard page at the top of the kernel stack to use
pmap_kremove(9) instead of pmap_remove(9) to reflect that the uarea no
longer uses "managed" pages.

ok mpi@

2 months agoBump up the maximum for repeat-time (some people want it to be
nicm [Mon, 21 Oct 2024 12:42:06 +0000 (12:42 +0000)]
Bump up the maximum for repeat-time (some people want it to be
effectively infinite).

2 months agoAdd function to get current offset from copy mode, from Michael Grant.
nicm [Mon, 21 Oct 2024 12:39:49 +0000 (12:39 +0000)]
Add function to get current offset from copy mode, from Michael Grant.

2 months agoAdjust how Ctrl and Meta keys are sent to use standard representation if
nicm [Mon, 21 Oct 2024 07:38:06 +0000 (07:38 +0000)]
Adjust how Ctrl and Meta keys are sent to use standard representation if
available in mode 1, from Stanislav Kljuhhin, GitHub issue 4188.

2 months agoremove unneeded includes
jsg [Mon, 21 Oct 2024 07:21:18 +0000 (07:21 +0000)]
remove unneeded includes

2 months agoEmit a warning if all fortunes in the file are too short or too long
tb [Mon, 21 Oct 2024 06:39:03 +0000 (06:39 +0000)]
Emit a warning if all fortunes in the file are too short or too long

From Nir Lichtman

2 months agorevert "try to simplify the locking code around busy maps"
dlg [Mon, 21 Oct 2024 06:07:33 +0000 (06:07 +0000)]
revert "try to simplify the locking code around busy maps"

anton@ and syzkaller have trouble with it.

2 months agoFix lldb doesn't analyze process core correctly.
asou [Mon, 21 Oct 2024 05:18:17 +0000 (05:18 +0000)]
Fix lldb doesn't analyze process core correctly.

ok kettenis@

2 months agoremove unused MP_PICMODE define
jsg [Mon, 21 Oct 2024 03:07:54 +0000 (03:07 +0000)]
remove unused MP_PICMODE define

2 months agoPlug leak of Fortbuf in find_matches()
tb [Sun, 20 Oct 2024 21:07:58 +0000 (21:07 +0000)]
Plug leak of Fortbuf in find_matches()

From Nir Lichtman

2 months agotry to simplify the locking code around busy maps.
dlg [Sun, 20 Oct 2024 11:28:17 +0000 (11:28 +0000)]
try to simplify the locking code around busy maps.

vm_maps have a "feature" where they can mark that they're being
operated on by a specific proc, and then release the rwlock protecting
their state. to relock, you have to be the same proc that marked
it busy.

this diff tries to simplify it a bit. it basically has threads check
the busy field up front and rechecks the busy field inside the
rwlock. if you can sleep, it will sleep up front for the busy field
to become clear, rather than sleep on either the busy field or the
rwlock. some code paths clear the busy field without holding the
rwlock, so it doesn't make sense to me to be waiting for the busy
field but sleeping somewhere else.

ok claudio@ mpi@

2 months agoVM_MAP_BUSY and VM_MAP_WANTLOCK will be removed soon, prep for that.
claudio [Sun, 20 Oct 2024 11:21:24 +0000 (11:21 +0000)]
VM_MAP_BUSY and VM_MAP_WANTLOCK will be removed soon, prep for that.
OK dlg@

2 months agoec_ameth.c: fix includes
tb [Sun, 20 Oct 2024 10:52:51 +0000 (10:52 +0000)]
ec_ameth.c: fix includes

2 months agoec_asn1: add missing includes
tb [Sun, 20 Oct 2024 10:48:29 +0000 (10:48 +0000)]
ec_asn1: add missing includes

2 months agoec_curve: add missing includes
tb [Sun, 20 Oct 2024 10:45:49 +0000 (10:45 +0000)]
ec_curve: add missing includes

2 months agozap an empty line
tb [Sun, 20 Oct 2024 10:28:23 +0000 (10:28 +0000)]
zap an empty line

2 months agoadd comma to fix offsets of trap type strings
jsg [Sun, 20 Oct 2024 06:54:11 +0000 (06:54 +0000)]
add comma to fix offsets of trap type strings
ok miod@

2 months agoChange sdhc_bus_power() behavior to return success and not perform a
hastings [Sat, 19 Oct 2024 21:10:03 +0000 (21:10 +0000)]
Change sdhc_bus_power() behavior to return success and not perform a
power-off voltage switch sequence when card is already operating at
requested voltage.

Zap the NOPWR0 quirk for Intel controllers.

ok stsp@ kettenis@

2 months agoMake ec EVP_PKEY_CTRL_MD handler match dsa/rsa more closely
tb [Sat, 19 Oct 2024 14:41:03 +0000 (14:41 +0000)]
Make ec EVP_PKEY_CTRL_MD handler match dsa/rsa more closely

This makes the thing a bit easier on the eyes and improves greppability.

ok joshua jsing

2 months agoDrop a useless cast in pkey_dsa_ctrl()
tb [Sat, 19 Oct 2024 14:39:44 +0000 (14:39 +0000)]
Drop a useless cast in pkey_dsa_ctrl()

ok joshua jsing

2 months agoRemove IA32 specific code from cryptlib.c.
jsing [Sat, 19 Oct 2024 13:06:11 +0000 (13:06 +0000)]
Remove IA32 specific code from cryptlib.c.

Move the IA32 specific code to arch/{amd64,i386}/crypto_cpu_caps.c, rather
than polluting cryptlib.c with machine dependent code. A stub version of
crypto_cpu_caps_ia32() still remains for now.

2 months agoRemove unused sparc CPU capability detection code.
jsing [Sat, 19 Oct 2024 11:55:32 +0000 (11:55 +0000)]
Remove unused sparc CPU capability detection code.

This has been unused for a long time - it can be found in the attic if
someone wants to clean it up and enable it in the future.

ok tb@

2 months agoEC_GROUP_check(): zap useless comments
tb [Sat, 19 Oct 2024 08:29:40 +0000 (08:29 +0000)]
EC_GROUP_check(): zap useless comments

2 months agoMove EC_GROUP_check() to ec_lib.c
tb [Sat, 19 Oct 2024 08:26:03 +0000 (08:26 +0000)]
Move EC_GROUP_check() to ec_lib.c

EC_GROUP_check() is quite simple. It doesn't need to use its own file.

2 months agoMark two regress/sbin/ifconfig tests as expected failures.
anton [Sat, 19 Oct 2024 07:10:55 +0000 (07:10 +0000)]
Mark two regress/sbin/ifconfig tests as expected failures.
They make use of the by now unsupported SIOCSIFDSTADDR ioctl command.
They should instead make use of the SIOCAIFADDR ioctl command, however
figuring out such change is above my pay grade.

2 months agoec_asn1_test: simplify previous
tb [Fri, 18 Oct 2024 19:58:43 +0000 (19:58 +0000)]
ec_asn1_test: simplify previous

2 months agoec_asn1_test: call EC_GROUP_check() for the builtin curves
tb [Fri, 18 Oct 2024 19:55:34 +0000 (19:55 +0000)]
ec_asn1_test: call EC_GROUP_check() for the builtin curves

This makes the internal curve test in ectest.c superfluous.
Also fix a logic error.

2 months agoSimplify EC_get_builtin_curves().
tb [Fri, 18 Oct 2024 18:03:45 +0000 (18:03 +0000)]
Simplify EC_get_builtin_curves().

When determining the minimum of nitems and EC_CURVE_LIST_LENGTH
we need neither an extra variable nor a ternary operator.

2 months agoUse better naming in ec_curve.c
tb [Fri, 18 Oct 2024 17:56:45 +0000 (17:56 +0000)]
Use better naming in ec_curve.c

Rename struct ec_list_element into struct ec_curve. Accordingly, curve_list
becomes struct ec_curve ec_curve_list[]. Adjust internal API to match.

suggested by jsing

2 months agoec_asn1_test: adjust for rejection of non-builtin curve parameters
tb [Fri, 18 Oct 2024 17:29:24 +0000 (17:29 +0000)]
ec_asn1_test: adjust for rejection of non-builtin curve parameters

2 months agoEnforce that EC Parameters correspond to a builtin curve
tb [Fri, 18 Oct 2024 17:27:07 +0000 (17:27 +0000)]
Enforce that EC Parameters correspond to a builtin curve

EC parameters are very general. While there are some minimal sanity checks,
for the parameters due to DoS risks found in the last decade, the elliptic
curve code is poorly written and a target rich environment for NULL
dereferences, busy loops, expensive computations and whatever other
nastiness you can think of. It is not too hard to come up with parameters
that reach very ugly code. While we have removed for the worst of it (the
"fast" nist code and GF2m come to mind), the code very much resembles the
Augean Stables.

Unfortunately, curve parameters are still in use - even mandatory in some
contexts - for example in machine-readable travel documents signed by ICAO
country signing certification authorities (see ICAO Doc 9303).

To avoid many of these DoS vectors, start enforcing that we know what the
curve parameters are about, namely that they correspond to a builtin curve.
This way we know that the parameters are at least as good as the standards
we implement and checking this is cheap:

Translate curve parameters into the ad hoc representation in the builtin
curve code and check there's a match. That's very cheap since most curves
are distinguished by cofactor and parameter length and we need to use an
actual parameter comparison for at most half a dozen curves, usually only
one or two.

ok jsing

2 months agoRemove now unused x86cpuid.pl.
jsing [Fri, 18 Oct 2024 14:45:02 +0000 (14:45 +0000)]
Remove now unused x86cpuid.pl.

2 months agoProvide crypto_cpu_caps_init() for i386.
jsing [Fri, 18 Oct 2024 14:44:02 +0000 (14:44 +0000)]
Provide crypto_cpu_caps_init() for i386.

This is the same CPU capabilities code that is now used for amd64. Like
amd64 we now only populate OPENSSL_ia32cap_P with bits used by perlasm.

Discussed with tb@

2 months agoRemove now unused x86_64cpuid.pl.
jsing [Fri, 18 Oct 2024 13:38:23 +0000 (13:38 +0000)]
Remove now unused x86_64cpuid.pl.

2 months agoProvide crypto_cpu_caps_init() for amd64.
jsing [Fri, 18 Oct 2024 13:36:24 +0000 (13:36 +0000)]
Provide crypto_cpu_caps_init() for amd64.

This is a CPU capability detection implementation in C, with minimal
inline assembly (for cpuid and xgetbv). This replaces the assembly
mess generated by x86_64cpuid.pl. Rather than populating OPENSSL_ia32cap_P
directly with CPUID output, just set the bits that the remaining
perlasm checks (namely AESNI, AVX, FXSR, INTEL, HT, MMX, PCLMUL, SSE, SSE2
and SSSE3).

ok joshua@ tb@

2 months agoInstead of always following up "power on" with a "reset", only
tobhe [Fri, 18 Oct 2024 12:53:49 +0000 (12:53 +0000)]
Instead of always following up "power on" with a "reset", only
send a single reset during attach.  We have discovered that some
devices such as the built-in keyboard on the Thinkpad T14s Gen 6
don't like getting more than one reset sent or they become
unresponsive.

This has been in snaps for a while and hasn't caused any major
regressions so we are confident the extra reset is not needed on
most hardware.

feedback from kettenis@
ok deraadt@ mlarkin@

2 months agoInline last use of OPENSSL_load_builtin_modules()
tb [Fri, 18 Oct 2024 11:12:10 +0000 (11:12 +0000)]
Inline last use of OPENSSL_load_builtin_modules()

This used to be a trivial wrapper of the ASN1_add_oid_module() horror.
It's no longer exported, so it can go away. It moves from the terribly
named file conf_mall.c to the equally terribly named file conf_sap.c.
I have no idea what mall and sap are supposed to mean in this context.

2 months agoMove EC_GROUP_new_curve_GFp() into ec_lib.c
tb [Fri, 18 Oct 2024 10:57:26 +0000 (10:57 +0000)]
Move EC_GROUP_new_curve_GFp() into ec_lib.c

Another single-function file goes away.

2 months agoMerge EC_GROUP_new_curve_GFp() with ec_group_new_curve()
tb [Fri, 18 Oct 2024 10:50:26 +0000 (10:50 +0000)]
Merge EC_GROUP_new_curve_GFp() with ec_group_new_curve()

The latter was used for EC_GROUP_new_curve_GF2m() and is now pointless.

ok jsing