Skip to content

Verify RSA host key signatures by encoding - #1359

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:hostkey-rsa-verify
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:hostkey-rsa-verify

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

DoKexDhReply() checks an RSA host key signature by encoding the
DigestInfo and comparing whole blocks, as userauth does (RFC 8332
Section 5.3). This restores ssh-rsa host keys on wolfSSL 5.9.2 and up.

  • wolfSSH_RsaVerify() refuses a signature longer than the modulus
  • tests: ssh-rsa host key handshake with valid, corrupted, and
    over-long signatures

Issue: F-17075

wolfSSH_RsaVerify() now returns WS_RSA_E when the signature is longer
than the modulus, so trailing bytes after a valid signature no longer
verify. A shorter signature is still left-padded with zeros.

- tests: unit test with one byte appended to a valid signature
DoKexDhReply() now checks an RSA host key signature over H the same way
userauth does: it hashes H, encodes the DigestInfo, and compares whole
blocks with wolfSSH_RsaVerify() per RFC 8332 Section 5.3, in place of
wc_SignatureVerify(). This also restores ssh-rsa host keys on wolfSSL
5.9.2 and later, which refuse SHA-1 in wc_SignatureVerify().

- tests: ssh-rsa host key handshake, valid and corrupted signature
- tests: host key signature with a trailing byte is rejected

Issue: F-17075
Copilot AI balanced review requested due to automatic review settings November 2, 2026 18:56

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

No active review issues block approval of the RSA host key verification changes.

No open issues 🎉

What changed in this PR

This PR restores ssh-rsa host key verification with wolfSSL 5.9.2 and later by using encoded DigestInfo comparison, consistent with user authentication.

Changes:

  • Replaces RSA host key verification with hashing, DigestInfo encoding, and wolfSSH_RsaVerify().
  • Rejects RSA signatures longer than the key modulus.
  • Adds handshake and unit coverage for valid, corrupted, and overlong signatures.
File Description
tests/​unit.c Tests rejection of RSA signatures with an appended byte.
tests/​regress.c Adds valid and corrupted ssh-rsa handshake tests and an overlong RSA signature test.
src/​internal.c Uses encoded DigestInfo for RSA host key verification and rejects overlong signatures.

Review effort: Balanced

@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 #1359

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 3 of 3 in-scope changed file(s) opened by the reviewer

Fenrir result: Approved ✅

No new issues found in the changed files.

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

Review tier: Lite

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.

4 participants