Repository navigation
Conversation
RFC 8410 section 7 encodes the Ed25519 seed as a CurvePrivateKey OCTET STRING inside the PKCS#8 privateKey OCTET STRING. The PKCS#8 parser passed the outer contents (the 04 20 header followed by the first 30 seed bytes) to ED25519Key, so the key loaded without error but had the wrong private and public key. Decode the inner OCTET STRING and require a 32-byte seed. Add a test that checks the key material of the existing Ed25519 PKCS#8 fixtures against the matching OpenSSH fixture.
cmclendon
requested review from
Rob-Hague,
WojciechNagorski and
drieseng
as code owners
November 25, 2026 22:34
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.
RFC 8410 section 7 encodes the Ed25519 seed as a
CurvePrivateKeyOCTET STRING inside the PKCS#8privateKeyOCTET STRING. The PKCS#8 parser passed the outer contents (04 20followed by the first 30 seed bytes) toED25519Key, so the key loaded without an error but had the wrong private and public key.Changes:
PrivateKeyFile.PKCS8.cs: decode the inner OCTET STRING withAsnReader(as the EC branch already does), reject trailing data, and require a 32-byte seed.PrivateKeyFileTest.cs: newTest_PrivateKey_ED25519_KeyMaterialchecks the private and public key of the two existing Ed25519 PKCS#8 fixtures (plain and encrypted) against the expected values ofKey.OPENSSH.ED25519.txt, which is the same key. The OpenSSH row is a control. Expected values come fromopenssl pkeyandKey.OPENSSH.ED25519.pub.Testing:
Run on Windows Server 2025 (10.0.26100), .NET SDK 11.0.100, .NET Framework 4.8.1, from
developb0d6c59 with this commit applied:dotnet build -c Releaseof the solution: 0 warnings, 0 errors, for every target ofRenci.SshNet(net462, netstandard2.0, net10.0, net11.0) andRenci.SshNet.Tests(net462, net10.0, net11.0).Renci.SshNet.Testssuite with the fix: no failures. net462 has 2393 passed and 26 skipped; net10.0 and net11.0 each have 2398 passed and 26 skipped. Unpatcheddevelopon net11.0 has 2395 passed and 26 skipped, so the 26 skipped tests are the repository's own, and the only new tests are the 3 rows above.Renci.SshNet.IntegrationTestswith the fix, on Linux x64 with Docker (.NET SDK 11.0.100, runtimes 10.0.15 and 11.0.0): 410 of 410 pass on net10.0 and on net11.0. They also pass 410 of 410 on net11.0 on macOS arm64.Renci.SshNet.IntegrationTestswith the fix on net48, run on the Windows Server 2025 machine above against a remote Linux Docker engine: 406 passed, 1 skipped (the same test is skipped when no Docker engine is reachable, so the skip is the suite's own), 0 failed.AI disclosure, per CONTRIBUTING.md: under my direction, an AI coding assistant helped stress test the edge cases and the fix across platforms, and drafted the patch, the test and this description, which I reviewed.