Skip to content

Commit

Permalink
Use #if #else #endif instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
arellegue committed Jun 7, 2024
1 parent 977d795 commit dd08b09
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ internal static byte[] GetECDiffieHellmanPublicKeyBlob(ECDiffieHellman ecDiffieH
Buffer.BlockCopy(ecPoint.X, 0, keyBlob, ECCPublicKeyBlob.HeaderSize, ECCPublicKeyBlob.KeySize);
Buffer.BlockCopy(ecPoint.Y, 0, keyBlob, ECCPublicKeyBlob.HeaderSize + ECCPublicKeyBlob.KeySize, ECCPublicKeyBlob.KeySize);
return keyBlob;
#endif
#if NETFRAMEWORK
#else
if (ecDiffieHellman is ECDiffieHellmanCng cng)
{
return cng.Key.Export(CngKeyBlobFormat.EccPublicBlob);
Expand Down Expand Up @@ -100,8 +99,7 @@ internal static RSA CreateRSAFromPublicKeyBlob(byte[] keyBlob)
Modulus = modulus
};
return RSA.Create(rsaParameters);
#endif
#if NETFRAMEWORK
#else
CngKey key = CngKey.Import(keyBlob, CngKeyBlobFormat.GenericPublicBlob);
return new RSACng(key);
#endif
Expand All @@ -128,8 +126,7 @@ internal static ECDiffieHellman CreateECDiffieHellmanFromPublicKeyBlob(byte[] ke
};

return ECDiffieHellman.Create(parameters);
#endif
#if NETFRAMEWORK
#else
CngKey key = CngKey.Import(keyBlob, CngKeyBlobFormat.GenericPublicBlob);
return new ECDiffieHellmanCng(key);
#endif
Expand All @@ -143,8 +140,7 @@ internal static ECDiffieHellman CreateECDiffieHellman(int keySize)
// DeriveKeyFromHash later in DeriveKey
ECDiffieHellman clientDHKey = ECDiffieHellman.Create();
clientDHKey.KeySize = keySize;
#endif
#if NETFRAMEWORK
#else
// Cng sets the key size and hash algorithm at creation time and these
// parameters are then used later when DeriveKeyMaterial is called
ECDiffieHellmanCng clientDHKey = new ECDiffieHellmanCng(keySize);
Expand All @@ -159,8 +155,7 @@ internal static byte[] DeriveKey(ECDiffieHellman ecDiffieHellman, ECDiffieHellma
#if NET6_0_OR_GREATER
// see notes in CreateECDDiffieHellman
return ecDiffieHellman.DeriveKeyFromHash(publicKey, HashAlgorithmName.SHA256);
#endif
#if NETFRAMEWORK
#else
if (ecDiffieHellman is ECDiffieHellmanCng cng)
{
return cng.DeriveKeyMaterial(publicKey);
Expand All @@ -176,8 +171,7 @@ internal static RSA GetRSAFromCertificate(X509Certificate2 certificate)
{
#if NET6_0_OR_GREATER
return certificate.GetRSAPublicKey();
#endif
#if NETFRAMEWORK
#else
RSAParameters parameters;
using (RSA rsaCsp = certificate.GetRSAPublicKey())
{
Expand Down

0 comments on commit dd08b09

Please sign in to comment.