Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,16 @@ private static int GetSecondMin(KeySizes[] keySizes)

private static bool GetHasSecondMinSize()
{
using (DSA dsa = DSAFactory.Create())
try
{
using (DSA dsa = DSAFactory.Create())
{
return GetSecondMin(dsa.LegalKeySizes) != int.MaxValue;
}
}
catch (PlatformNotSupportedException)
{
return GetSecondMin(dsa.LegalKeySizes) != int.MaxValue;
return false;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ private static bool TestRsa16384()

return true;
}
catch (CryptographicException)
catch (Exception e) when (e is CryptographicException or PlatformNotSupportedException)
{
// The key is too big for this platform.
// The key is too big for this platform or the platform is not supported.
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace System.Security.Cryptography.EcDiffieHellman.Tests
{
public partial class ECDiffieHellmanProvider : IECDiffieHellmanProvider
{
public bool IsCurveValid(Oid oid) => false;
public bool ExplicitCurvesSupported => false;
public bool CanDeriveNewPublicKey => false;
public bool SupportsRawDerivation => false;
public bool SupportsSha3 => false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace System.Security.Cryptography.EcDsa.Tests
{
public partial class ECDsaProvider : IECDsaProvider
{
public bool IsCurveValid(Oid oid) => false;
public bool ExplicitCurvesSupported => false;
private static bool IsValueOrFriendlyNameValid(string friendlyNameOrValue) => false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,18 @@
<Compile Include="DefaultECDsaProvider.Windows.cs" />
<Compile Include="DefaultECDiffieHellmanProvider.Windows.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows' and '$(UseAndroidCrypto)' != 'true'">
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows' and '$(UseAndroidCrypto)' != 'true' and '$(TargetPlatformIdentifier)' != 'browser'">
<Compile Include="DefaultECDsaProvider.Unix.cs" />
<Compile Include="DefaultECDiffieHellmanProvider.Unix.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
Link="Common\Interop\Unix\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs"
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.Initialization.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'browser'">
<Compile Include="DefaultECDsaProvider.Browser.cs" />
<Compile Include="DefaultECDiffieHellmanProvider.Browser.cs" />
</ItemGroup>
<ItemGroup Condition="'$(UseAndroidCrypto)' == 'true' or '$(UseAppleCrypto)' == 'true'">
<Compile Include="X509Certificates\X509StoreMutableTests.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,12 @@ private static bool DetectPssSupport()
return false;
}

if (PlatformDetection.IsBrowser)
{
// Browser doesn't support PSS or RSA at all.
return false;
}

using (X509Certificate2 cert = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword))
using (RSA rsa = cert.GetRSAPrivateKey())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@ public class SignatureSupport
//
// If there's ever a platform that blocks RSASSA+SHA-1 but doesn't block ECDSA or DSA with SHA-1,
// the logic here will need to get more complicated.
public static bool SupportsX509Sha1Signatures { get; } =
System.Security.Cryptography.Tests.SignatureSupport.CanProduceSha1Signature(RSA.Create());
public static bool SupportsX509Sha1Signatures { get; } = GetSupportsX509Sha1Signatures();


private static bool GetSupportsX509Sha1Signatures()
{
RSA rsa;

try
{
rsa = RSA.Create();
}
catch (PlatformNotSupportedException)
{
return false;
}

return System.Security.Cryptography.Tests.SignatureSupport.CanProduceSha1Signature(rsa);
}
}
}