-
-
Notifications
You must be signed in to change notification settings - Fork 940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ED25519Key PrivateKey doesnt return all bytes #1548
Comments
Chaos.Nacl (old):
BouncyCastle (new):
The size of the privatekey byte array is too small now. Diff could be something like that:
I couldn't find a reasonable BouncyCastle constant. With this patch ED25519 works again in the SshNet-Extensions. |
Looks reasonable, do you want to put up a PR? |
What specific issue if the Ed25519 private key length is 32? |
Is the next 32 bytes public key? |
The answer is yes. var privateKey = Convert.FromHexString("92-F0-5A-EA-18-A5-F3-08-92-B5-66-DD-A6-A4-CC-51-64-D0-66-39-B4-DF-B4-0A-84-1C-76-00-30-A3-F2-BC".Replace("-", string.Empty));
var publicKey = new byte[Ed25519.PublicKeySize];
Ed25519.GeneratePublicKey(privateKey, publicKey);
Console.WriteLine(Convert.ToHexString(publicKey)); Output: |
The issue is if you want to export your private key e.g. in to the SSH Agent or into openssh keyfile it will get rejected as malformed. Sure, I could workaround this by appending the pub key myself to the private key bytes, but I think its an API breaking change and should behave like it did before. |
agree, the behaviour should be preserved |
@Rob-Hague I thought about opening an PR, but I'm not sure if there is a "good" BouncyCastle constant for this size. |
I would agree if there's no SSH.NET/src/Renci.SshNet/Security/Cryptography/ED25519Key.cs Lines 65 to 73 in 3b4f2cf
Regarding OpenSSH private key format, the value contains both private key and public key.
Regarding PuTTY PPK format, the Ed25519 public key and private key are separated:
Regarding PKCS#8 format, the private key is solely private key. In a word, I don't think we should revert to the wrong length just because it was there for long time. How about add another constructor for |
K, will do it myself then. |
Noticed after updating my SshNet.Agent Extension to the current 2024.2.0-Release
2024.1.0 is fine, though.
I would guess it could be fallout from: #1448
Please also see: darinkes/SshNet.Agent#8
The text was updated successfully, but these errors were encountered: