@@ -54,8 +54,7 @@ internal static byte[] GetECDiffieHellmanPublicKeyBlob(ECDiffieHellman ecDiffieH
5454 Buffer . BlockCopy ( ecPoint . X , 0 , keyBlob , ECCPublicKeyBlob . HeaderSize , ECCPublicKeyBlob . KeySize ) ;
5555 Buffer . BlockCopy ( ecPoint . Y , 0 , keyBlob , ECCPublicKeyBlob . HeaderSize + ECCPublicKeyBlob . KeySize , ECCPublicKeyBlob . KeySize ) ;
5656 return keyBlob ;
57- #endif
58- #if NETFRAMEWORK
57+ #else
5958 if ( ecDiffieHellman is ECDiffieHellmanCng cng )
6059 {
6160 return cng . Key . Export ( CngKeyBlobFormat . EccPublicBlob ) ;
@@ -100,8 +99,7 @@ internal static RSA CreateRSAFromPublicKeyBlob(byte[] keyBlob)
10099 Modulus = modulus
101100 } ;
102101 return RSA . Create ( rsaParameters ) ;
103- #endif
104- #if NETFRAMEWORK
102+ #else
105103 CngKey key = CngKey . Import ( keyBlob , CngKeyBlobFormat . GenericPublicBlob ) ;
106104 return new RSACng ( key ) ;
107105#endif
@@ -128,8 +126,7 @@ internal static ECDiffieHellman CreateECDiffieHellmanFromPublicKeyBlob(byte[] ke
128126 } ;
129127
130128 return ECDiffieHellman . Create ( parameters ) ;
131- #endif
132- #if NETFRAMEWORK
129+ #else
133130 CngKey key = CngKey . Import ( keyBlob , CngKeyBlobFormat . GenericPublicBlob ) ;
134131 return new ECDiffieHellmanCng ( key ) ;
135132#endif
@@ -143,8 +140,7 @@ internal static ECDiffieHellman CreateECDiffieHellman(int keySize)
143140 // DeriveKeyFromHash later in DeriveKey
144141 ECDiffieHellman clientDHKey = ECDiffieHellman . Create ( ) ;
145142 clientDHKey . KeySize = keySize ;
146- #endif
147- #if NETFRAMEWORK
143+ #else
148144 // Cng sets the key size and hash algorithm at creation time and these
149145 // parameters are then used later when DeriveKeyMaterial is called
150146 ECDiffieHellmanCng clientDHKey = new ECDiffieHellmanCng ( keySize ) ;
@@ -159,8 +155,7 @@ internal static byte[] DeriveKey(ECDiffieHellman ecDiffieHellman, ECDiffieHellma
159155#if NET6_0_OR_GREATER
160156 // see notes in CreateECDDiffieHellman
161157 return ecDiffieHellman . DeriveKeyFromHash ( publicKey , HashAlgorithmName . SHA256 ) ;
162- #endif
163- #if NETFRAMEWORK
158+ #else
164159 if ( ecDiffieHellman is ECDiffieHellmanCng cng )
165160 {
166161 return cng . DeriveKeyMaterial ( publicKey ) ;
@@ -176,8 +171,7 @@ internal static RSA GetRSAFromCertificate(X509Certificate2 certificate)
176171 {
177172#if NET6_0_OR_GREATER
178173 return certificate . GetRSAPublicKey ( ) ;
179- #endif
180- #if NETFRAMEWORK
174+ #else
181175 RSAParameters parameters ;
182176 using ( RSA rsaCsp = certificate . GetRSAPublicKey ( ) )
183177 {
0 commit comments