Repository navigation
Add Ed25519 and X25519 key generation, import and use - #57
Open
FlorianFranzen wants to merge 2 commits into
Open
FlorianFranzen wants to merge 2 commits into
FlorianFranzen wants to merge 2 commits into
Conversation
Co-authored-by: Emanuele Cesena <emanuele.cesena@gmail.com>
FlorianFranzen
added a commit
to FlorianFranzen/piv-authenticator
that referenced
this pull request
Oct 16, 2026
FlorianFranzen
added a commit
to FlorianFranzen/piv-authenticator
that referenced
this pull request
Oct 16, 2026
…ep one, with the curve25519 arm
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits, one per algorithm, under the identifiers Yubico firmware 5.7, piv-go and pivy agreed on (#17, #13).
Ed25519 (0xE0)
Adds Ed25519 under the non-standard algorithm identifier
0xE0that Yubico firmware 5.7, piv-go and pivy use (#17, #13). Only this variant is appended toAsymmetricAlgorithms, so persisted key metadata keeps its variant indices.7F49 { 86 }, without the SEC104prefix, as Yubico does.07, the DO ykman/yubikit send.sign_lenbecomessign_input_len() -> Option<usize>;Nonemeans any length up toMAX_MESSAGE_LENGTH, so an oversized request answers6A80instead of panicking in thesyscall!.0xE0. The test-side algorithm enum is corrected to the identifiers the app uses (05,16,E0,E1).Tests: generate + sign with length checks, an oversized message, and an import of RFC 8032 test vector 2 with a byte-exact signature. The pivy expectation is updated. Verified by hand with ykman 5.9 against the vpicc card:
ykman piv keys generate -a ED25519,ykman piv keys importof an openssl key (public key matches), and signatures verified by Nix (nix store verify). ykman also needs #49 to select the application.The generate and sign paths come from the
v0.8branch (4bd37ef) by @0x0ece, credited as co-author. The ML-DSA-44 half of that branch is left out: its mechanism implementation only exists in the solokeys trussed fork (trussed-dev/trussed#219 is still open) and the fork spells the variantMlDsa44where released trussed-core hasMldsa44, so it only builds with a git override.X25519 (0xE1)
The second commit adds X25519 under the Yubico/piv-go/pivy identifier
0xE1(#17, #15), appended afterEd25519so persisted variant indices stay put.7F49 { 86 }, the same encoding as Ed25519.08, the DO ykman/yubikit send for X25519.85, where the NIST curves take a SEC1 point. The shared secret comes back in7C { 82 }as before. An all-zero secret (a low-order peer key, RFC 7748 section 6.1) is rejected with 6A80, since the ladder itself never fails.sign_mechanismreturns anOptionso that signing with an X25519 key answers6985, mirroring what key agreement already answers for a signature-only key.0xE1.Tests: generate + key agreement with length checks, a rejected sign, a rejected short peer key, a rejected order-4 peer key, and an import of RFC 7748 section 6.1 (Alice's key, Bob's public key) producing the RFC's shared secret byte for byte. The pivy expectation is updated for the
X25519entry.Both commits conflict textually with #56 in
import_asymmetric_key(each adds an arm after the RSA one) and in itsscalar_len, which then needs an arm for the new variants; whichever lands second keeps all arms and thersa-gated fallback.