Skip to content

Commit 0cce3eb

Browse files
committed
Allow to set PrivateKeyFile Key directly
So you can add your own Key-Classes to SSH.NET Add ED25519 ctor for just pub key part.
1 parent f072c5f commit 0cce3eb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Renci.SshNet/PrivateKeyFile.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ public class PrivateKeyFile : IDisposable
7979
/// </summary>
8080
public HostAlgorithm HostKey { get; private set; }
8181

82+
/// <summary>
83+
/// Initializes a new instance of the <see cref="PrivateKeyFile"/> class.
84+
/// </summary>
85+
/// <param name="key">The key.</param>
86+
public PrivateKeyFile(Key key)
87+
{
88+
HostKey = new KeyHostAlgorithm(key.ToString(), key);
89+
}
90+
8291
/// <summary>
8392
/// Initializes a new instance of the <see cref="PrivateKeyFile"/> class.
8493
/// </summary>

src/Renci.SshNet/Security/Cryptography/ED25519Key.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ public ED25519Key()
9999
{
100100
}
101101

102+
/// <summary>
103+
/// Initializes a new instance of the <see cref="ED25519Key"/> class.
104+
/// </summary>
105+
/// <param name="pk">pk data.</param>
106+
public ED25519Key(byte[] pk)
107+
{
108+
publicKey = pk.TrimLeadingZeros().Pad(Ed25519.PublicKeySizeInBytes);
109+
}
110+
102111
/// <summary>
103112
/// Initializes a new instance of the <see cref="ED25519Key"/> class.
104113
/// </summary>

0 commit comments

Comments
 (0)