mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Trim the leading zero from PuTTY ECDSA private keys (#1827)
Fixes #1825
This commit is contained in:
@@ -175,7 +175,7 @@ namespace Renci.SshNet
|
||||
var curve = publicKeyReader.ReadString(Encoding.ASCII);
|
||||
var pub = publicKeyReader.ReadBinary();
|
||||
var prv = privateKeyReader.ReadBinary();
|
||||
parsedKey = new EcdsaKey(curve, pub, prv);
|
||||
parsedKey = new EcdsaKey(curve, pub, prv.TrimLeadingZeros());
|
||||
break;
|
||||
case "ssh-rsa":
|
||||
var exponent = publicKeyReader.ReadBigInt();
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
PuTTY-User-Key-File-3: ecdsa-sha2-nistp256
|
||||
Encryption: none
|
||||
Comment: imported-openssh-key
|
||||
Public-Lines: 3
|
||||
AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNhE4rS0CTev
|
||||
/VEC6BJ/142eE3dU88t1rpzrSJ3iEcyp+3itM0+182eXSswmunZo/TNyvFE1sXKK
|
||||
1x0COQJl6hU=
|
||||
Private-Lines: 1
|
||||
AAAAIQDTj7+GAKceovRR6/NV8TFi+Mc5cHl555sVVokgFkofYA==
|
||||
Private-MAC: 71bc2b8cbe9f209ff693afb9b217f060f5dc4d4ae73e136e28fa1034b0fdd982
|
||||
@@ -346,6 +346,7 @@ namespace Renci.SshNet.Tests.Classes
|
||||
[DataRow("Key.PuTTY2.RSA.Encrypted.12345.ppk", "12345", typeof(RsaKey))]
|
||||
[DataRow("Key.PuTTY2.RSA.ppk", null, typeof(RsaKey))]
|
||||
[DataRow("Key.PuTTY3.ECDSA.Encrypted.Argon2id.12345.ppk", "12345", typeof(EcdsaKey))]
|
||||
[DataRow("Key.PuTTY3.ECDSA.LeadingZero.ppk", null, typeof(EcdsaKey))]
|
||||
[DataRow("Key.PuTTY3.ECDSA.ppk", null, typeof(EcdsaKey))]
|
||||
[DataRow("Key.PuTTY3.Ed25519.Encrypted.Argon2i.12345.ppk", "12345", typeof(ED25519Key))]
|
||||
[DataRow("Key.PuTTY3.Ed25519.Encrypted.Argon2d.12345.ppk", "12345", typeof(ED25519Key))]
|
||||
|
||||
Reference in New Issue
Block a user