Skip to content

ssh-encoding: non-negative Mpint and other OpenSSH alignment - #622

Merged
tarcieri merged 1 commit into
masterfrom
ssh-encoding/non-negative-mpint
Nov 10, 2026
Merged

tarcieri merged 1 commit into
masterfrom
ssh-encoding/non-negative-mpint

Conversation

@tarcieri

Copy link
Copy Markdown
Member

Restrict Mpint to non-negative integers and enforce the 16384-bit cap across every construction path. Match OpenSSH's rejection of negative encodings and acceptance of redundant leading zeros, checking the wire length before normalization and always emitting canonical encodings.

Stores unsigned magnitudes internally and exposes them through from_bytes and as_bytes, removing the positive-specific APIs. Makes conversions from crypto_bigint::Uint fallible and conversions back infallible. Replaces derived bytewise ordering with numeric ordering using ctutils, and preserve canonical zero after zeroization.

Updates ssh-key callers, including parsing PPK Ed25519 seeds as raw byte strings instead of mpints so their high bits and leading zeros are preserved.

@tarcieri
tarcieri force-pushed the ssh-encoding/non-negative-mpint branch 5 times, most recently from 163864a to 231399e Compare November 10, 2026 22:00
Restrict `Mpint` to non-negative integers and enforce the 16384-bit cap
across every construction path. Match OpenSSH's rejection of negative
encodings and acceptance of redundant leading zeros, checking the wire
length before normalization and always emitting canonical encodings.

Stores unsigned magnitudes internally and exposes them through
`from_bytes` and `as_bytes`, removing the positive-specific APIs.
Makes conversions from `crypto_bigint::Uint` fallible and conversions
back infallible. Replaces derived bytewise ordering with numeric
ordering using `ctutils`, and preserve canonical zero after zeroization.

Updates `ssh-key` callers, including parsing PPK Ed25519 seeds as raw
byte strings instead of mpints so their high bits and leading zeros are
preserved.
@tarcieri
tarcieri force-pushed the ssh-encoding/non-negative-mpint branch from 231399e to edf9bc6 Compare November 10, 2026 22:16
@tarcieri
tarcieri merged commit 93bbb2b into master Nov 10, 2026
34 checks passed
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.

1 participant