Skip to content

Anchor the key type checks in ReadKey_file - #1363

Open
ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:readkey-prefixes
Open

ejohnstown wants to merge 1 commit into
wolfSSL:masterfrom
ejohnstown:readkey-prefixes

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

wolfSSH_ReadKey_file() classifies a key file by its first bytes only,
instead of searching the whole file, which may be a private key.

  • match "ssh-mldsa" so composite ML-DSA public keys load as SSH format
  • api test for an ML-DSA public key file

Issue: F-14633, F-14666

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.

🟡 Changes recommended

Active issues leave temporary-file tests incompatible with write-disabled and FatFS configurations, while key-format detection still searches beyond the opening header and can misclassify PEM files.

3 open issues
What changed in this PR

This PR updates wolfSSH_ReadKey_file() to use bounded prefix comparisons for key-type detection and recognize composite ML-DSA public-key names.

Changes:

  • Replaces several whole-file searches with prefix checks.
  • Broadens SSH-format detection from ssh-mldsa- to ssh-mldsa.
  • Adds API coverage for five ML-DSA public-key name variants.
File Description
tests/​api.c Adds and registers file-based ML-DSA classification tests.
src/​ssh.c Adds a prefix-check helper and updates key-format detection.

Review effort: Balanced

Comment thread src/ssh.c Resolved
Comment thread tests/api.c Resolved
Comment thread tests/api.c Resolved
wolfSSH_ReadKey_file() now classifies a key file by comparing only its
first bytes against each SSH key type name and the OpenSSH and PEM
begin markers, rather than searching the whole file, which may be a
private key.

- match "ssh-mldsa" so composite ML-DSA public keys, such as
  ssh-mldsa44-es256@wolfssl.com, load as SSH format
- add test_wolfSSH_ReadKey_file_mldsaPub to api.c

Issue: F-14633, F-14666

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

Scan targets checked: wolfssh-src, wolfssh-bugs
Coverage: 2 of 2 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