From e10b4062a21967d9b391f542b38df40d06e19f49 Mon Sep 17 00:00:00 2001 From: Max Ustinov Date: Tue, 23 Jan 2024 15:44:59 -0800 Subject: [PATCH] REL-4359 - KSM .NET SDK v16.6.5 (#560) * KSM-476 fixed parsing keys in DER format (#545) * KSM-484 Upgraded all package dependencies to latest versions and switched from portable to the full version of Bouncy Castle (#553) --- sdk/dotNet/README.md | 5 +++++ .../SecretManagement.Keeper.csproj | 4 ++-- sdk/dotNet/SecretManagement.Keeper/build.ps1 | 2 +- sdk/dotNet/SecretsManager/CryptoUtils.cs | 9 +++++++-- sdk/dotNet/SecretsManager/SecretsManager.csproj | 12 ++++++------ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/sdk/dotNet/README.md b/sdk/dotNet/README.md index 2110d71c..20220ace 100644 --- a/sdk/dotNet/README.md +++ b/sdk/dotNet/README.md @@ -3,6 +3,11 @@ # Change Log +## 16.6.5 + +* KSM-476 - fix public key parsing +* KSM-484 - Update to latest Bouncy Castle version + ## 16.6.4 * KSM-466 - Fixed ExpiresOn conversion from UnixTimeMilliseconds. Closes [Issue #533] diff --git a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj index 6bdf4956..b1d1dcee 100644 --- a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj +++ b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 @@ -9,7 +9,7 @@ - + All diff --git a/sdk/dotNet/SecretManagement.Keeper/build.ps1 b/sdk/dotNet/SecretManagement.Keeper/build.ps1 index 290e72b7..f8b94d3e 100644 --- a/sdk/dotNet/SecretManagement.Keeper/build.ps1 +++ b/sdk/dotNet/SecretManagement.Keeper/build.ps1 @@ -30,7 +30,7 @@ if ($Package) { @( './bin/Release/netstandard2.1/SecretManagement.Keeper.dll' './bin/Release/netstandard2.1/SecretsManager.dll' - './bin/Release/netstandard2.1/BouncyCastle.Crypto.dll' + './bin/Release/netstandard2.1/BouncyCastle.Cryptography.dll' ) | ForEach-Object { Copy-Item -Path $_ -Destination $outDir -Force } diff --git a/sdk/dotNet/SecretsManager/CryptoUtils.cs b/sdk/dotNet/SecretsManager/CryptoUtils.cs index de7e6bb8..fbf5784c 100644 --- a/sdk/dotNet/SecretsManager/CryptoUtils.cs +++ b/sdk/dotNet/SecretsManager/CryptoUtils.cs @@ -15,6 +15,8 @@ using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; +using Org.BouncyCastle.Asn1.Pkcs; +using Org.BouncyCastle.Asn1.Sec; namespace SecretsManager { @@ -105,8 +107,11 @@ private static ECPublicKeyParameters ImportPublicKey(byte[] key) } private static ECPrivateKeyParameters ImportPrivateKey(byte[] privateKeyDer) - { - return new ECPrivateKeyParameters(new BigInteger(1, privateKeyDer.Skip(36).Take(32).ToArray()), ECParameters); + { + var privateKeyInfo = PrivateKeyInfo.GetInstance(privateKeyDer); + var privateKeyStructure = ECPrivateKeyStructure.GetInstance(privateKeyInfo.ParsePrivateKey()); + var privateKeyValue = privateKeyStructure.GetKey(); + return new ECPrivateKeyParameters(privateKeyValue, ECParameters); } private static byte[] GetECIESSymmetricKey(ICipherParameters privateKey, ICipherParameters recipientPublicKey) diff --git a/sdk/dotNet/SecretsManager/SecretsManager.csproj b/sdk/dotNet/SecretsManager/SecretsManager.csproj index 93d49b19..cc475f05 100644 --- a/sdk/dotNet/SecretsManager/SecretsManager.csproj +++ b/sdk/dotNet/SecretsManager/SecretsManager.csproj @@ -5,9 +5,9 @@ 9 Keeper Security Inc. SecretsManager .Net SDK - 16.6.4 - 16.6.4 - 16.6.4 + 16.6.5 + 16.6.5 + 16.6.5 en-US Keeper.SecretsManager Sergey Aldoukhov @@ -22,8 +22,8 @@ - - - + + +