Skip to content

Commit 638504d

Browse files
committed
Make ECDSA Key Bits accessible
You cant export imported CngKeys. To be able to export them to agent or Key-Files make the private bits also accessible.
1 parent 6e79603 commit 638504d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

+11
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,11 @@ public override BigInteger[] Public
212212
}
213213
}
214214

215+
/// <summary>
216+
/// Gets the PrivateKey Bytes
217+
/// </summary>
218+
public byte[] PrivateKey { get; private set; }
219+
215220
/// <summary>
216221
/// Gets ECDsa Object
217222
/// </summary>
@@ -297,7 +302,10 @@ private void Import(string curve_oid, byte[] publickey, byte[] privatekey)
297302
parameter.Q.Y = qy;
298303

299304
if (privatekey != null)
305+
{
300306
parameter.D = privatekey.TrimLeadingZeros().Pad(cord_size);
307+
PrivateKey = parameter.D;
308+
}
301309

302310
Ecdsa = ECDsa.Create(parameter);
303311
#else
@@ -335,7 +343,10 @@ private void Import(string curve_oid, byte[] publickey, byte[] privatekey)
335343
Buffer.BlockCopy(publickey, cord_size + 1, qy, 0, qy.Length);
336344

337345
if (privatekey != null)
346+
{
338347
privatekey = privatekey.Pad(cord_size);
348+
PrivateKey = privatekey;
349+
}
339350

340351
int headerSize = Marshal.SizeOf(typeof(BCRYPT_ECCKEY_BLOB));
341352
int blobSize = headerSize + qx.Length + qy.Length;

0 commit comments

Comments
 (0)