Skip to content

Support builds with neither RSA nor ECDSA - #1257

Merged
philljj merged 11 commits into
wolfSSL:masterfrom
ejohnstown:no-rsa-no-ecc
Sep 17, 2026
Merged

philljj merged 11 commits into
wolfSSL:masterfrom
ejohnstown:no-rsa-no-ecc

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

An Ed25519-only wolfSSH build now compiles, links, and passes the test suite. Ed25519 was reachable only where RSA or ECDSA was also compiled in, and a few RSA-only details broke the build outright.

  • Ed25519 host keys compile without ECDSA, and the WOLFSSH_NO_ECC guard, which nothing defines, gives way to the derived WOLFSSH_NO_ECDSA
  • ValidateKexDhGexGroup() shifts with mp_rshb() instead of mp_div_2(), which SP math builds only for ECC
  • three RSA-only locals no longer draw -Werror warnings, and PrimeNameForId() is guarded on ECDSA alone
  • PrepareUserAuthRequestEd25519() takes a DER private key, matching the RSA and ECDSA paths
  • the Ed25519 public key auth test runs without ECDSA, and unit.c and api.c build their Ed25519 cases
  • echoserver carries Ed25519 sample public keys, so public key auth works there instead of falling back to passwords

Copilot AI lite review requested due to automatic review settings September 15, 2026 22:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes support Ed25519-only builds with corresponding tests and example updates.

Pull request overview

Adds support for Ed25519-only wolfSSH builds, including authentication paths, tests, and example configuration.

Changes:

  • Corrects ECDSA guards and reduced-crypto compilation.
  • Adds Ed25519 DER authentication fixtures and coverage.
  • Enables Ed25519 keys in the echoserver.
File summaries
File Description
tests/unit.c Enables Ed25519 ASN.1 test helpers.
tests/auth.c Adds Ed25519 authentication coverage.
tests/api.c Adds Ed25519 key fixtures.
src/ssh.c Handles builds without ECDSA or ECDH.
src/internal.c Fixes reduced-crypto compilation and Ed25519 DER handling.
examples/echoserver/echoserver.c Adds Ed25519 host and authorized-key support.
examples/client/common.c Updates ECDSA feature guards.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1257

Scan targets checked: wolfssh-src, wolfssh-bugs

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

The ID_ED25519 arm of SendKexGetSigningKey() sat inside the
"#ifndef WOLFSSH_NO_ECDSA" block that precedes it, so a build with ECDSA
off never compiled the case that decodes and hashes an Ed25519 host key.
Close the ECDSA guard at the end of the ECDSA cases instead.
mp_div_2() maps to sp_div_2(), which SP math compiles only for ECC, so
the safe-prime check in ValidateKexDhGexGroup() fails to link when RSA
and ECC are both off. mp_rshb() is unconditional and q is positive here,
so the two do the same thing.
Three locals feed only RSA and ECDSA code and draw -Werror warnings once
both are compiled out.

- digestSz in DoUserAuthRequestPublicKey(), read only by the RSA and
  ECDSA verify arms
- heap in SendKexGetSigningKey(), used only where a key is allocated
- the id parameter of CurveNameForId(), unread with no curve to name
Nothing defines WOLFSSH_NO_ECC, so every "#ifndef WOLFSSH_NO_ECC" block
was always compiled and the sample ECC keys behind them reached their
"#error" with no curve available. Use WOLFSSH_NO_ECDSA, which
wolfssh/internal.h derives.

- echoserver builds load_key() and its two default host keys only when
  RSA or ECDSA is there; the Ed25519 host key still loads
- ECC_PATH moves inside that guard, its only reader
- peerEcc is now read only by load_key(), so mark it used
The Ed25519 key DER helpers arrive through asn.h, which unit.c includes
only for RSA, and the host key that test_wolfSSH_SetAlgoList() installs
came only in RSA and ECDSA flavors.

- include wolfssl/wolfcrypt/asn_public.h unconditionally in unit.c
- add ./keys/server-key-ed25519.der to api.c as the last host key
  fallback
PrimeNameForId() is called only from the three ECDSA paths, so it now
sits in its own WOLFSSH_NO_ECDSA block. wcPrimeForId() keeps the wider
"ECDSA or ECDH" condition that its curve lookups still need.
PrepareUserAuthRequestEd25519() tries wc_Ed25519PrivateKeyDecode() and
falls back to the OpenSSH container only when that decode fails, as the
RSA and ECDSA paths do. A private-only DER gets its public key derived
the way SendKexGetSigningKey() does, or is rejected when it cannot be.
test_pubkey_auth_ed25519_privonly_hostkey() authenticates with an
Ed25519 user key rather than hansel's ECDSA key, so it covers Ed25519
user auth alongside the host key derive fallback and needs no ECDSA.

- load_key() falls back to the Ed25519 host key when neither RSA nor
  ECDSA is available
- guard run_pubkey_test() on RSA or ECDSA, its only callers
The example server loads hansel's and gretel's Ed25519 public keys when
neither RSA nor ECDSA is compiled in, so public key auth works there
instead of falling back to passwords. That arm is the "#if" and the
userEcc choice the "#else", so no empty if/else is left behind.
The sample clients load hansel's Ed25519 key when neither RSA nor ECDSA
is compiled in, so public key auth reaches the echoserver's matching
sample keys instead of sending a request carrying no key.

- commit keys/{hansel,gretel}-key-ed25519.{der,pem,pub}, the pair to the
  echoserver's sample authorized keys
- ClientUserAuth() fails a publickey request with no key loaded, so the
  library can offer another method
os-check builds a wolfSSL with neither, then wolfssh against it, so the
Ed25519-only paths are exercised. That wolfSSL line names two things the
short option list does not imply: --enable-ed25519-stream, which wolfSSH
needs to keep Ed25519, and --enable-base64encode, which the ssh client
app needs and which defaults off away from x86_64.
@philljj
philljj merged commit b40148a into wolfSSL:master Sep 17, 2026
187 checks passed
@ejohnstown
ejohnstown deleted the no-rsa-no-ecc branch September 17, 2026 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants