File tree Expand file tree Collapse file tree
Common/tests/System/Security/Cryptography/AlgorithmImplementations
System.Security.Cryptography/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -122,9 +122,16 @@ private static int GetSecondMin(KeySizes[] keySizes)
122122
123123 private static bool GetHasSecondMinSize ( )
124124 {
125- using ( DSA dsa = DSAFactory . Create ( ) )
125+ try
126+ {
127+ using ( DSA dsa = DSAFactory . Create ( ) )
128+ {
129+ return GetSecondMin ( dsa . LegalKeySizes ) != int . MaxValue ;
130+ }
131+ }
132+ catch ( PlatformNotSupportedException )
126133 {
127- return GetSecondMin ( dsa . LegalKeySizes ) != int . MaxValue ;
134+ return false ;
128135 }
129136 }
130137 }
Original file line number Diff line number Diff line change @@ -455,9 +455,9 @@ private static bool TestRsa16384()
455455
456456 return true ;
457457 }
458- catch ( CryptographicException )
458+ catch ( Exception e ) when ( e is CryptographicException or PlatformNotSupportedException )
459459 {
460- // The key is too big for this platform.
460+ // The key is too big for this platform or the platform is not supported .
461461 return false ;
462462 }
463463 }
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ using System . Runtime . InteropServices ;
5+
6+ namespace System . Security . Cryptography . EcDiffieHellman . Tests
7+ {
8+ public partial class ECDiffieHellmanProvider : IECDiffieHellmanProvider
9+ {
10+ public bool IsCurveValid ( Oid oid ) => false ;
11+ public bool ExplicitCurvesSupported => false ;
12+ public bool CanDeriveNewPublicKey => false ;
13+ public bool SupportsRawDerivation => false ;
14+ public bool SupportsSha3 => false ;
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the MIT license.
3+
4+ using System . Runtime . InteropServices ;
5+
6+ namespace System . Security . Cryptography . EcDsa . Tests
7+ {
8+ public partial class ECDsaProvider : IECDsaProvider
9+ {
10+ public bool IsCurveValid ( Oid oid ) => false ;
11+ public bool ExplicitCurvesSupported => false ;
12+ private static bool IsValueOrFriendlyNameValid ( string friendlyNameOrValue ) => false ;
13+ }
14+ }
Original file line number Diff line number Diff line change 388388 <Compile Include =" DefaultECDsaProvider.Windows.cs" />
389389 <Compile Include =" DefaultECDiffieHellmanProvider.Windows.cs" />
390390 </ItemGroup >
391- <ItemGroup Condition =" '$(TargetPlatformIdentifier)' != 'windows' and '$(UseAndroidCrypto)' != 'true'" >
391+ <ItemGroup Condition =" '$(TargetPlatformIdentifier)' != 'windows' and '$(UseAndroidCrypto)' != 'true' and '$(TargetPlatformIdentifier)' != 'browser' " >
392392 <Compile Include =" DefaultECDsaProvider.Unix.cs" />
393393 <Compile Include =" DefaultECDiffieHellmanProvider.Unix.cs" />
394394 <Compile Include =" $(CommonPath)Interop\Unix\Interop.Libraries.cs"
395395 Link =" Common\Interop\Unix\Interop.Libraries.cs" />
396396 <Compile Include =" $(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs"
397397 Link =" Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs" />
398398 </ItemGroup >
399+ <ItemGroup Condition =" '$(TargetPlatformIdentifier)' == 'browser'" >
400+ <Compile Include =" DefaultECDsaProvider.Browser.cs" />
401+ <Compile Include =" DefaultECDiffieHellmanProvider.Browser.cs" />
402+ </ItemGroup >
399403 <ItemGroup Condition =" '$(UseAndroidCrypto)' == 'true' or '$(UseAppleCrypto)' == 'true'" >
400404 <Compile Include =" X509Certificates\X509StoreMutableTests.cs" />
401405 </ItemGroup >
Original file line number Diff line number Diff line change @@ -534,6 +534,12 @@ private static bool DetectPssSupport()
534534 return false ;
535535 }
536536
537+ if ( PlatformDetection . IsBrowser )
538+ {
539+ // Browser doesn't support PSS or RSA at all.
540+ return false ;
541+ }
542+
537543 using ( X509Certificate2 cert = new X509Certificate2 ( TestData . PfxData , TestData . PfxDataPassword ) )
538544 using ( RSA rsa = cert . GetRSAPrivateKey ( ) )
539545 {
Original file line number Diff line number Diff line change @@ -13,7 +13,23 @@ public class SignatureSupport
1313 //
1414 // If there's ever a platform that blocks RSASSA+SHA-1 but doesn't block ECDSA or DSA with SHA-1,
1515 // the logic here will need to get more complicated.
16- public static bool SupportsX509Sha1Signatures { get ; } =
17- System . Security . Cryptography . Tests . SignatureSupport . CanProduceSha1Signature ( RSA . Create ( ) ) ;
16+ public static bool SupportsX509Sha1Signatures { get ; } = GetSupportsX509Sha1Signatures ( ) ;
17+
18+
19+ private static bool GetSupportsX509Sha1Signatures ( )
20+ {
21+ RSA rsa ;
22+
23+ try
24+ {
25+ rsa = RSA . Create ( ) ;
26+ }
27+ catch ( PlatformNotSupportedException )
28+ {
29+ return false ;
30+ }
31+
32+ return System . Security . Cryptography . Tests . SignatureSupport . CanProduceSha1Signature ( rsa ) ;
33+ }
1834 }
1935}
You can’t perform that action at this time.
0 commit comments