Skip to content

ossh: OpenSSH private-key parser fixes - #1351

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ossh-key-parser
Open

ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ossh-key-parser

Conversation

@ejohnstown

@ejohnstown ejohnstown commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

The OpenSSH private-key parser now requires block-aligned padding, and
its key decoders keep the real error and the caller's heap.

  • A private section that is not a whole number of blocks is rejected,
    and every pad byte is checked
  • The Ed25519 decoder keeps its parse errors and reports WS_ED25519_E
    instead of WS_ECC_E
  • Every OpenSSH key decoder initializes its key on the WS_KeySignature
    heap

This and #1352 both add a test at the same spot in tests/unit.c;
whichever merges second will be rebased onto the other.

Issue: F-12551, F-13925, F-11653, F-11656

GetOpenSshKey checked the padding only when the private section was a
whole number of blocks, so a misaligned section, or one ending in junk,
loaded. It now rejects a section that is not a multiple of MIN_BLOCK_SZ,
as OpenSSH does, and compares every pad byte before deciding.

- tests: parse crafted Ed25519 keys with good, missing, junk and bad
  padding

Issue: F-12551, F-13925
GetOpenSshKeyEd25519 now returns its parse errors as they are and
reports a wolfCrypt failure as WS_ED25519_E instead of WS_ECC_E. The
OpenSSH key decoders take the WS_KeySignature heap and initialize the
key with it, where they used NULL or the zeroed key's own heap field.

- tests: check the Ed25519 decoder errors and the heap of a decoded
  key

Issue: F-11653, F-11656
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:07

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 1 of 2 in-scope changed file(s) opened by the reviewer; not opened: tests/unit.c

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