Skip to content

Commit

Permalink
Add throwing PNSE to System.Security.Cryptography on WASM (#38379)
Browse files Browse the repository at this point in the history
Since the entire set of System.Security.Cryptography.* tests has been disabled on WASM recently in dotnet/runtime#37723, we need to let everyone know that those areas are not quite supported on WASM at the moment. In that case System.Security.Cryptography classes could throw PlatformNotSupportedException until some solution comes (dotnet/runtime#37669)
  • Loading branch information
MaximLipnin authored and kevinwkt committed Jul 15, 2020
1 parent 6ad5a78 commit d06f134
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
T:System.Security.Cryptography.RandomNumberGenerator
T:System.Security.Cryptography.RandomNumberGeneratorImplementation
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,7 @@
<data name="Cryptography_Okm_TooLarge" xml:space="preserve">
<value>Output keying material length can be at most {0} bytes (255 * hash length).</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1\AsnXml.targets" />
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" />
<ItemGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
<GeneratePlatformNotSupportedAdditionalParameters Condition="'$(TargetsBrowser)' == 'true'">--exclude-api-list ExcludeApiList.PNSE.Browser.txt</GeneratePlatformNotSupportedAdditionalParameters>
</PropertyGroup>
<ItemGroup Condition="'$(TargetsBrowser)' != 'true'">
<Compile Include="Internal\Cryptography\AesImplementation.cs" />
<Compile Include="Internal\Cryptography\DesImplementation.cs" />
<Compile Include="Internal\Cryptography\Helpers.cs" />
Expand Down Expand Up @@ -412,7 +416,7 @@
<Compile Include="$(CommonPath)System\Security\Cryptography\RSACng.SignVerify.cs"
Link="Common\System\Security\Cryptography\RSACng.SignVerify.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' and '$(TargetsOSX)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetstvOS)' != 'true'">
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' and '$(TargetsOSX)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetstvOS)' != 'true' and '$(TargetsBrowser)' != 'true'">
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.cs"
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ASN1.Nid.cs"
Expand Down Expand Up @@ -554,7 +558,7 @@
<Compile Include="Internal\Cryptography\TripleDesImplementation.OSX.cs" />
<Compile Include="System\Security\Cryptography\ECDiffieHellman.Create.SecurityTransforms.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsUnix)' == 'true'">
<ItemGroup Condition=" '$(TargetsUnix)' == 'true' and '$(TargetsBrowser)' != 'true'">
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs"
Link="Common\Interop\Unix\System.Security.Cryptography.Native\Interop.EVP.Cipher.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Security.Cryptography.Native\Interop.ERR.cs"
Expand All @@ -573,9 +577,13 @@
<Compile Include="System\Security\Cryptography\AesGcm.Unix.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetsBrowser)' == 'true'">
<Compile Include="System\Security\Cryptography\RandomNumberGenerator.cs" />
<Compile Include="Internal\Cryptography\RandomNumberGeneratorImplementation.cs" />
<Compile Include="Internal\Cryptography\RandomNumberGeneratorImplementation.Browser.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.GetRandomBytes.cs"
Link="Common\Interop\Unix\System.Native\Interop.GetRandomBytes.cs" />
<Compile Include="$(CommonPath)Interop\Unix\Interop.Libraries.cs"
Link="Common\Interop\Unix\Interop.Libraries.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Collections" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,7 @@
<data name="CspParameter_invalid" xml:space="preserve">
<value>CSPParameters cannot be null</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Security\Cryptography\AesCryptoServiceProvider.cs" />
<Compile Include="System\Security\Cryptography\CapiHelper.DSA.Shared.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,7 @@
<data name="ObjectDisposed_Generic" xml:space="preserve">
<value>Cannot access a disposed object.</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1\AsnXml.targets" Condition=" '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" />
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition=" '$(TargetsOSX)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true'" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PropertyGroup>
<AssemblyVersion Condition="'$(TargetFramework)' == 'netstandard2.0'">4.1.0.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsUnix)' != 'true'">
<PropertyGroup Condition="'$(TargetsUnix)' != 'true' or '$(TargetsBrowser)' == 'true'">
<GeneratePlatformNotSupportedAssemblyMessage>SR.PlatformNotSupported_CryptographyOpenSSL</GeneratePlatformNotSupportedAssemblyMessage>
<!-- Clear PackageTargetRuntime on Windows to package the PlatformNotSupported assembly
without a RID so that it applies in desktop packages.config projects as well -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,7 @@
<data name="Cryptography_Cms_CertificateAlreadyInCollection" xml:space="preserve">
<value>Certificate already present in the collection.</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<!-- Currently the netstandard build is locked to the $(NetFrameworkCurrent) API -->
<AssemblyVersion Condition="$(TargetFramework.StartsWith('netstandard'))">4.0.4.0</AssemblyVersion>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1\AsnXml.targets" Condition="'$(IsPartialFacadeAssembly)' != 'true'" />
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" Condition="'$(IsPartialFacadeAssembly)' != 'true'" />
<!-- Don't delete these clauses even if they look useless. They tell the VS IDE that "Windows_Debug", etc., are
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,7 @@
<data name="InvalidOperation_IncorrectImplementation" xml:space="preserve">
<value>The algorithm's implementation is incorrect.</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Security\Cryptography\AsymmetricAlgorithm.cs" />
<Compile Include="System\Security\Cryptography\CipherMode.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,4 +427,7 @@
<data name="Cryptography_NotValidPrivateKey" xml:space="preserve">
<value>Key is not a valid private key.</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<TargetFrameworks>$(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-OSX;$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1\AsnXml.targets" />
<Import Project="$(CommonPath)System\Security\Cryptography\Asn1Reader\System.Security.Cryptography.Asn1Reader.Shared.projitems" />
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,7 @@
<data name="Log_UnsafeTransformMethod" xml:space="preserve">
<value>Transform method "{0}" is not on the safe list. Safe transform methods are: {1}.</value>
</data>
<data name="Cryptography_PlatformNotSupported_Browser" xml:space="preserve">
<value>System.Security.Cryptography is not supported on Browser.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<PropertyGroup>
<IsPartialFacadeAssembly Condition="$(TargetFramework.StartsWith('net4'))">true</IsPartialFacadeAssembly>
</PropertyGroup>
<PropertyGroup>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetsBrowser)' == 'true'">SR.Cryptography_PlatformNotSupported_Browser</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>
<ItemGroup Condition="'$(IsPartialFacadeAssembly)' != 'true'">
<Compile Include="System\Security\Cryptography\Xml\AncestralNamespaceContextManager.cs" />
<Compile Include="System\Security\Cryptography\Xml\AttributeSortOrder.cs" />
Expand Down

0 comments on commit d06f134

Please sign in to comment.