internal: gate public-key auth on every compiled signing algorithm - #1183
internal: gate public-key auth on every compiled signing algorithm#1183yosuke-wolfssl wants to merge 1 commit into
Conversation
- wolfssh/internal.h derives WOLFSSH_NO_PUBKEY_AUTH when RSA, ECDSA, Ed25519, and ML-DSA are all disabled. - DoUserAuthRequestPublicKey(), the publickey dispatch in DoUserAuthRequest(), the ID_USERAUTH_PUBLICKEY case in DoUserAuthFailure(), Prepare/BuildUserAuthRequestPublicKey(), and GetAllowedAuth() are all guarded by that macro. - The DoUserAuthFailure() and GetAllowedAuth() guards previously omitted Ed25519 and ML-DSA; the DoUserAuthFailure() guard also carried a WOLFSSH_TPM term, which is dropped. Issue: F-10542
There was a problem hiding this comment.
Pull request overview
This pull request fixes a compile-time gating inconsistency for SSH publickey user authentication by introducing a single shared “no public-key auth available” predicate and using it consistently across the internal user-auth flow. This ensures publickey auth remains reachable/advertised when any supported signing algorithm family (RSA/ECDSA/Ed25519/ML-DSA) is compiled in, including Ed25519-only/ML-DSA-only builds.
Changes:
- Add a derived
WOLFSSH_NO_PUBKEY_AUTHmacro inwolfssh/internal.hwhen all compiled signing algorithm families are disabled. - Replace multiple per-site algorithm guard expressions in
src/internal.cwith#ifndef WOLFSSH_NO_PUBKEY_AUTHat the five affected sites. - Remove the prior
WOLFSSH_TPMexception from the client-sideID_USERAUTH_PUBLICKEYenablement path, aligning behavior with actual available signing algorithms.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| wolfssh/internal.h | Introduces a shared derived macro (WOLFSSH_NO_PUBKEY_AUTH) to centralize the “no publickey auth possible” compile-time predicate. |
| src/internal.c | Switches all five publickey auth gating sites to use #ifndef WOLFSSH_NO_PUBKEY_AUTH for consistent reachability/advertisement across configurations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wolfSSL-Fenrir-bot
left a comment
There was a problem hiding this comment.
Fenrir Automated Review — PR #1183
Scan targets checked: wolfssh-bugs, wolfssh-src
Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)
This review was generated automatically by Fenrir. Findings are non-blocking.
Problem
Public-key user authentication is gated on compile-time algorithm macros in five places in
src/internal.c, but the guards are not the same expression. Two of them list only RSA and ECDSA:GetAllowedAuth()— the server's default advertised method listDoUserAuthFailure()— the client'sID_USERAUTH_PUBLICKEYcaseEd25519 and ML-DSA are fully supported public-key user-auth algorithms:
DoUserAuthRequestPublicKey(),PrepareUserAuthRequestPublicKey()andBuildUserAuthRequestPublicKey()all have real branches for them, and all three are guarded on the correct four-way predicate.So in a build with
WOLFSSH_NO_RSA+WOLFSSH_NO_ECDSAand Ed25519 (or ML-DSA) enabled, the verify and sign paths are compiled in but unreachable: the server never advertisespublickey, and the client drops it fromauthType, so a peer list containing onlypublickeyreturnsWS_USER_AUTH_E. Public-key auth is unusable in those configurations. Closes f-10542.Fix (
src/internal.c,wolfssh/internal.h)wolfssh/internal.hderives a shared predicate next to the existingWOLFSSH_NO_RSA/WOLFSSH_NO_ECDSAaggregates:All five sites now use
#ifndef WOLFSSH_NO_PUBKEY_AUTH, so the predicate has one definition.Not a pure rename at two sites — these are the behavioral fixes:
GetAllowedAuth()!NO_RSA || !NO_ECDSADoUserAuthFailure()!NO_RSA || !NO_ECDSA || WOLFSSH_TPMThe
WOLFSSH_TPMterm is dropped. The TPM user-auth signer exists only for RSA, and with all four algorithm families disabled the "You need at least one signing algorithm"#errorfires, so no buildable config relied on it.Verification
--enable-all: 11 passed, 1 skipped (external.test), 0 failed.-Werrorpreflight sweep: 6 configurations clean.-DWOLFSSH_NO_RSA -DWOLFSSH_NO_ECDSAagainst wolfSSL with--enable-ed25519-stream):src/internal.ccompiles clean, and preprocessing confirms bothtypeAllowed |= WOLFSSH_USERAUTH_PUBLICKEYand theID_USERAUTH_PUBLICKEYcase now survive. Negative control: both disappear with the change reverted.Not in this PR
No test is added: the Ed25519-only configuration cannot run
make checktoday becauseexamples/client/common.candexamples/echoserver/echoserver.cfail to compile there — they guard the ECDSA sample keys onWOLFSSH_NO_ECC(curve support) while selecting the key material onWOLFSSH_NO_ECDSA_SHA2_NISTP*(signing). That is pre-existing and tracked separately; fixing it is the prerequisite for adding an Ed25519-only CI job.