Repository navigation
Verify RSA host key signatures by encoding - #1359
Open
ejohnstown wants to merge 2 commits into
Open
ejohnstown wants to merge 2 commits into
ejohnstown wants to merge 2 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
🟢 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
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
over-long signatures
Issue: F-17075