Repository navigation
feat: add support for mldsa44-ed25519 (draft-miller-sshm-composite-sigs) - #583
Conversation
|
If I read the draft correctly, public keys, private keys and signature are just "append mldsa(44|87) with (eddsa|ecdsa) (public|private|signature)" together. Would it be possible to make those composite using a macro or something and reuse the existing ed25519/ecdsa keys? I haven't tried it. Happy to. |
|
well, openssh doesn't appear to have mldsa87-p384 support at the moment. |
|
@baloo I'm happy to make the changes, but currently really only mldsa44-ed25519 is supported. Openssh specifically state that they have no plans to add pure mldsa (though as mentioned in the original PR some ssh clients have added it), so I feel that unless there is a change of direction from openssh to make it likely that pure mldsa will be supported, it's not worth introducing the complexity currently. openssh/openssh-portable#703 (comment) Openssh also does not currently support As to the question; yes private key seeds, public keys, and signatures are just concatenated respectively in the encoding, however for signatures specifically 1. the mldsa context is set to a specific label that is composite specific, and 2. they both don't directly sign the data, but they sign a commitment to a prefix, the label, the ctx (and length of it), and the data. So the sign operations from the underlying SSH keys are not directly usable / we would at minimum have to expose a private function for the mldsa keys that exposes the context parameter, but macros could do a lot of the lifting when adding mldsa87-p384 support. LMK which path you prefer |
|
Yeah, I've missed the message it signed was not similar. I'm just worried about the code duplication you're introducing here. |
|
@baloo I restructured the PR to have ml-dsa be separate and pub(crate)`, and to have the composite sig be generated by a macro. Would you mind checking whether this matches your expectation? I think the other key type that openssh doesn't support yet but the draft spec supports, we should easily be able to add later using the macro. |
# Conflicts: # Cargo.lock
Offer the post-quantum hybrid host key / signature algorithm ssh-mldsa44-ed25519 (ML-DSA-44 + Ed25519, draft-miller-sshm-composite-sigs, wire-compatible with OpenSSH 10.x) in addition to the russh defaults, so PQC-only servers negotiate it; the classical algorithms stay ahead of it in the offered list, so servers that have them are unaffected. russh 0.65 offers and negotiates the algorithm, but ssh-key 0.7.0-rc.11 can neither represent its plain wire name (AlgorithmName requires name@domain) nor verify the composite signature, so ssh-key is carried as a vendored [patch.crates-io] fork with the missing pieces until upstream lands them (RustCrypto/SSH#583): the MlDsa44Ed25519 algorithm and key variants behind a mldsa-eddsa feature, the composite codec (public key 1344, signature 2484, seed pair 64) and ML-DSA-44 (ml-dsa) + Ed25519 sign/verify over the composite message representative M'. The path entry can be swapped for a pinned git fork like the existing sqlx one. Verified against the draft-ietf-lamps-pq-composite-sigs known-answer vectors shipped with OpenSSH (seed expansion reproduces the published public key, the OpenSSH-generated composite signature verifies) and end to end against an in-process russh server offering only ssh-mldsa44-ed25519: ML-KEM-768 KEX, composite host key verification and composite user key authentication all succeed. Refs l0ng-ai#3482 Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
|
@baloo / @tarcieri Hey, since this sat stale for a while, is there any chance we could get it reviewed and merged? If not I'll vendor the changes downstream for our use-case for the time being, but from the GitHub references it seems some other projects want to use them too. I've resolved the conflicts that have accumulated on the PR since my last work on this now. |
|
I will try to get this landed soon, everyone |
alex
left a comment
There was a problem hiding this comment.
small nit, but I didn't see any functional bugs. (Didn't review for style)
| matches!(self, Self::Rsa(_)) | ||
| } | ||
|
|
||
| /// Is this key an ML-DSA key? |
There was a problem hiding this comment.
This should probably say composite mldsa-ed25519 key
tarcieri
left a comment
There was a problem hiding this comment.
I'll go ahead and approve this and then look into following up with some changes.
I guess my main reservation has been how composite.rs is implemented and if there were a cleaner, more generic way to implement it that better leverages the existing traits as opposed to the heavily macro-laden approach it's using in addition to defining its own traits.
But we can get this landed as a start, as it seems to interop with OpenSSH 10.6, and I can follow up on that.
|
Followup: #653. I will get a prerelease of this out today, and a final release out hopefully tomorrow. |
The desktop agent can now hold, list and sign with `ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves do, so it is no weaker than Ed25519 alone while resisting a store-now-decrypt-later attack on the classic half. Nothing in the agent filtered on algorithm beyond `PrivateKey`'s conversion from `ssh_key::PrivateKey`, so the wire protocol, approval and session-bind paths needed no change. ssh-key gains the type from a fork pending upstream review (RustCrypto/SSH#583), pinned through `[patch.crates-io]` on all three SSH crates, since the revision changes `Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch once that PR merges and is published. Key generation still offers only Ed25519: `KeyAlgorithm` in the published @bitwarden/sdk-internal has no composite variant yet (bitwarden/sdk-internal#1854).
ssh-key does not yet release the `mldsa44-ed25519` composite key type; RustCrypto/SSH#583 added it and is merged. Point ssh-cipher, ssh-encoding and ssh-key at upstream master through `[patch.crates-io]` so all three come from one revision — it changes `Decode::decode` to take `&mut Decoder<impl Reader>`. Revert once they are published. ssh-encoding 0.4 changes `Mpint`: `from_positive_bytes` is now the fallible `from_bytes`, and `as_bytes` returns the unsigned magnitude, replacing `as_positive_bytes`. RUSTSEC-2023-0071 (Marvin attack) no longer matches any crate in the graph, and cargo-deny rejects an ignore entry that matches nothing. The CXF SSH export fixture changes in its "checkint" field only: ssh-encoding 0.4 dropped the leading sign byte from `Mpint::as_bytes`, which shifts the value ssh-key derives from the private exponent. The key material is byte-identical.
Followup to #583 which provided an ininitial implementation of `mldsa44-ed25519` compsoite signatures compatible with OpenSSH 10.6. This change removes quite a bit of indirection and premature abstractions, leaning on generics and the existing traits instead of macros.
With #583 and #653 landed, and with all of the dependencies already in place, this is fairly easy to add as well. It's not currently implemented by OpenSSH 10.6, but if it were it would be a nice option for systems which implement NIST standards exclusively and don't support Ed25519, for example Apple's SEPs.
With #583 and #653 landed, and with all of the dependencies already in place, this is fairly easy to add as well. It's not currently implemented by OpenSSH 10.6, but if it were it would be a nice option for systems which implement NIST standards exclusively and don't support Ed25519, for example Apple's SEPs.
With #583 and #653 landed, and with all of the dependencies already in place, this is fairly easy to add as well. It's not currently implemented by OpenSSH 10.6, but if it were it would be a nice option for systems which implement NIST standards exclusively and don't support Ed25519, for example Apple's SEPs.
With #583 and #653 landed, and with all of the dependencies already in place, this is fairly easy to add as well. It's not currently implemented by OpenSSH 10.6, but if it were it would be a nice option for systems which implement NIST standards exclusively and don't support Ed25519, for example Apple's SEPs.
|
This is released in v0.7.0-rc.13 |
|
Sweet, thank you @tarcieri ! |
The desktop agent can now hold, list and sign with `ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves do, so it is no weaker than Ed25519 alone while resisting a store-now-decrypt-later attack on the classic half. Nothing in the agent filtered on algorithm beyond `PrivateKey`'s conversion from `ssh_key::PrivateKey`, so the wire protocol, approval and session-bind paths needed no change. ssh-key gains the type from a fork pending upstream review (RustCrypto/SSH#583), pinned through `[patch.crates-io]` on all three SSH crates, since the revision changes `Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch once that PR merges and is published. Key generation still offers only Ed25519: `KeyAlgorithm` in the published @bitwarden/sdk-internal has no composite variant yet (bitwarden/sdk-internal#1854).
ssh-key does not yet release the `mldsa44-ed25519` composite key type; RustCrypto/SSH#583 added it and is merged. Point ssh-cipher, ssh-encoding and ssh-key at upstream master through `[patch.crates-io]` so all three come from one revision — it changes `Decode::decode` to take `&mut Decoder<impl Reader>`. Revert once they are published. ssh-encoding 0.4 changes `Mpint`: `from_positive_bytes` is now the fallible `from_bytes`, and `as_bytes` returns the unsigned magnitude, replacing `as_positive_bytes`. RUSTSEC-2023-0071 (Marvin attack) no longer matches any crate in the graph, and cargo-deny rejects an ignore entry that matches nothing. The CXF SSH export fixture changes in its "checkint" field only: ssh-encoding 0.4 dropped the leading sign byte from `Mpint::as_bytes`, which shifts the value ssh-key derives from the private exponent. The key material is byte-identical.
The desktop agent can now hold, list and sign with `ssh-mldsa44-ed25519@openssh.com` keys imported from OpenSSH. The composite pairs ML-DSA-44 with Ed25519 and verifies only if both halves do, so it is no weaker than Ed25519 alone while resisting a store-now-decrypt-later attack on the classic half. Nothing in the agent filtered on algorithm beyond `PrivateKey`'s conversion from `ssh_key::PrivateKey`, so the wire protocol, approval and session-bind paths needed no change. ssh-key gains the type from a fork pending upstream review (RustCrypto/SSH#583), pinned through `[patch.crates-io]` on all three SSH crates, since the revision changes `Decode::decode` to take `&mut Decoder<impl Reader>`. Drop the patch once that PR merges and is published. Key generation still offers only Ed25519: `KeyAlgorithm` in the published @bitwarden/sdk-internal has no composite variant yet (bitwarden/sdk-internal#1854).
Adds support for https://www.ietf.org/archive/id/draft-miller-sshm-composite-sigs-01.html mldsa44-ed25519 composite keys. Given that openssh currently does not have plans to support raw mldsa keys, this superseeds my other PR.
I've tested support for interoperability on
OpenSSH_10.5p1, OpenSSL 3.6.3 9 Jun 2026in SSH agent (I signed and verified a file signature via SSH agent using this PR's implementation).(With some further patches in Bitwarden's SSH Agent):
