diff --git a/Extensions/CngKeyExtensions.cs b/Extensions/CngKeyExtensions.cs index 576b717..36d52c0 100644 --- a/Extensions/CngKeyExtensions.cs +++ b/Extensions/CngKeyExtensions.cs @@ -1,9 +1,11 @@ using System; using System.Security.Cryptography; -using System.Linq; namespace SecurityDriven.Inferno.Extensions { +#if NET5_0_OR_GREATER + [System.Runtime.Versioning.SupportedOSPlatform("windows")] +#endif public static class CngKeyExtensions { static readonly CngKeyCreationParameters cngKeyCreationParameters = new CngKeyCreationParameters { ExportPolicy = CngExportPolicies.AllowPlaintextExport }; @@ -46,13 +48,11 @@ public static CngKey ToPublicKeyFromBlob(this byte[] publicBlob) /// public static byte[] GetSharedDhmSecret(this CngKey privateDhmKey, CngKey publicDhmKey, byte[] contextAppend = null, byte[] contextPrepend = null) { -#if (NET462 || NETCOREAPP3_1) - using (var ecdh = new ECDiffieHellmanCng(privateDhmKey) { HashAlgorithm = CngAlgorithm.Sha384, SecretAppend = contextAppend, SecretPrepend = contextPrepend }) - return ecdh.DeriveKeyMaterial(publicDhmKey); -#elif NETSTANDARD2_0 +#if NETSTANDARD2_0 throw new PlatformNotSupportedException($"ECDiffieHellman is not supported on .NET Standard 2.0. Please reference \"{typeof(CngKeyExtensions).Assembly.GetName().Name}\" from .NET Framework or .NET Core for ECDiffieHellman support."); #else -#error Unknown target + using (var ecdh = new ECDiffieHellmanCng(privateDhmKey) { HashAlgorithm = CngAlgorithm.Sha384, SecretAppend = contextAppend, SecretPrepend = contextPrepend }) + return ecdh.DeriveKeyMaterial(publicDhmKey); #endif }// GetSharedDhmSecret() diff --git a/SecurityDriven.Inferno.csproj b/SecurityDriven.Inferno.csproj index de8753c..7d9e7c5 100644 --- a/SecurityDriven.Inferno.csproj +++ b/SecurityDriven.Inferno.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1;net462;netstandard2.0 + net8.0;netcoreapp3.1;net462;netstandard2.0 latest true SecurityDriven.Inferno @@ -41,11 +41,14 @@ - + - + + + +