From c41409faca493f2b9420f5f90bcff0c77f22c976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Fri, 22 Nov 2024 16:48:03 +0100 Subject: [PATCH 1/2] Add support for .NET 8 This allows to use Inferno completely dependency free since System.Numerics.Vectors, System.Runtime.CompilerServices.Unsafe, System.ValueTuple and System.Security.Cryptography.Cng are only required for specific target frameworks. This pull request supersedes #40 --- Extensions/CngKeyExtensions.cs | 12 ++++++------ SecurityDriven.Inferno.csproj | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) 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..e7b9a53 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 @@ - + - + + + + From e8f5010704f14924141618875c7848704937d45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Fri, 22 Nov 2024 16:39:45 +0100 Subject: [PATCH 2/2] Update System.Formats.Asn1 to fix NU1903 warning > warning NU1903: Package 'System.Formats.Asn1' 5.0.0 has a known high severity vulnerability, https://github.com/advisories/GHSA-447r-wph3-92pm --- SecurityDriven.Inferno.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/SecurityDriven.Inferno.csproj b/SecurityDriven.Inferno.csproj index e7b9a53..31353e4 100644 --- a/SecurityDriven.Inferno.csproj +++ b/SecurityDriven.Inferno.csproj @@ -49,6 +49,7 @@ +