Skip to content

fix: sign with ECDSA keys that have a short scalar - #47

Merged
timweri merged 3 commits into
mainfrom
fix/ecdsa-short-scalar
Sep 24, 2026
Merged

timweri merged 3 commits into
mainfrom
fix/ecdsa-short-scalar

Conversation

@timweri

@timweri timweri commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Flagged by Opus 5.5: When the first byte in the scalar is 0, sshcerts passes only 31 bytes down to ring, which require 32 bytes.

This now allows small and insecure scalars. This PR left-pad the small scalar and then does the safety check. This helps reject insecure keys.

@timweri timweri added the conformance For issues or PRs that deal with conformance to the SSH standard label Sep 24, 2026
@timweri
timweri requested a balanced review from Copilot September 24, 2026 22:51

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 review overview

🟡 Changes recommended

Security-sensitive invalid-scalar rejection paths need regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Left-pads short ECDSA private scalars to the curve width before ring validation and signing.

Changes:

  • Normalizes P-256 and P-384 scalar lengths securely.
  • Adds signing round-trip tests with short scalars.
  • Adds corresponding test keys.
File Description
src/​ssh/​privkey.rs Pads and zeroizes ECDSA scalars.
tests/​signature-creation.rs Tests short-scalar signing.
tests/​keys/​unencrypted/​ecdsa_256_short_scalar Adds P-256 fixture.
tests/​keys/​unencrypted/​ecdsa_384_short_scalar Adds P-384 fixture.

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

Comment thread src/ssh/privkey.rs
@timweri
timweri marked this pull request as ready for review September 24, 2026 22:57
@timweri
timweri merged commit 5b5698c into main Sep 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conformance For issues or PRs that deal with conformance to the SSH standard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants