-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
[Private Key] Add support for PuTTY private key file format (V3 and V2) #1543
base: develop
Are you sure you want to change the base?
Conversation
#if NET | ||
Convert.FromHexString(_argon2Salt), | ||
#else | ||
Org.BouncyCastle.Utilities.Encoders.Hex.Decode(_argon2Salt), | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can change it to be the same as below code. Or change the below code to be the same as here.
SSH.NET/src/Renci.SshNet/PrivateKeyFile.PKCS1.cs
Lines 46 to 50 in 3ec45e1
var binarySalt = new byte[_salt.Length / 2]; | |
for (var i = 0; i < binarySalt.Length; i++) | |
{ | |
binarySalt[i] = Convert.ToByte(_salt.Substring(i * 2, 2), 16); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or change the below code to be the same as here.
sounds good
switch (keyType) | ||
{ | ||
case "ssh-ed25519": | ||
parsedKey = new ED25519Key(privateKeyReader.ReadBignum2()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ED25519Key
class does not have a constructor with both publicKeyData
and privateKeyData
. The current implementation is to generate public key from private key. Should we add a new constructor?
SSH.NET/src/Renci.SshNet/Security/Cryptography/ED25519Key.cs
Lines 98 to 104 in 3ec45e1
public ED25519Key(byte[] privateKeyData) | |
{ | |
PrivateKey = new byte[Ed25519.SecretKeySize]; | |
PublicKey = new byte[Ed25519.PublicKeySize]; | |
Buffer.BlockCopy(privateKeyData, 0, PrivateKey, 0, Ed25519.SecretKeySize); | |
Ed25519.GeneratePublicKey(privateKeyData, 0, PublicKey, 0); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems ok as it is, but I don't mind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, will wait for a stable BC release
#if NET | ||
Convert.FromHexString(_argon2Salt), | ||
#else | ||
Org.BouncyCastle.Utilities.Encoders.Hex.Decode(_argon2Salt), | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or change the below code to be the same as here.
sounds good
switch (keyType) | ||
{ | ||
case "ssh-ed25519": | ||
parsedKey = new ED25519Key(privateKeyReader.ReadBignum2()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems ok as it is, but I don't mind
This PR adds support for PuTTY private key file format (V3 and V2) described in https://tartarus.org/~simon/putty-snapshots/htmldoc/AppendixC.html
Close #341
Close #431
Close #434
Close #510
Notes: