You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the System.Security.Cryptography.HashAlgorithmName methods throw a PlatformNotSupportedException when executed in a C# program that got compiled against the wasi-wasm runtime. While the WASI Crypto API hasn't been finalized (AFAICT) and wasmtimedoesn't provide any implementation, it would be really useful if at least the managed implementation of these crypto functions were available for programs running under wasi-wasm.
Reproduction Steps
Compile any program accessing any of the crypto functions (e.g. SHA1). When run an exception will be thrown:
System.PlatformNotSupportedException: SystemSecurityCryptography_PlatformNotSupported
at System.Security.Cryptography.SHA1.Create()
...
Expected behavior
While no WASI Crypto API has been finalized and made available via wasmtime, it would be really useful if the managed implementations could be used. I am trying to use Roslyn APIs, which internally use both SHA1 and SHA256 and thus cannot be executed under wasi-wasm.
Based on the message, I think it's just pulling in the RID-less build; since that looks like the output from <GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.SystemSecurityCryptography_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>
Activity
bartonjs commentedon Mar 5, 2024
There's not a special
wasibuild of System.Security.Cryptography. Is it not the same asbrowser?runtime/src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj
Line 6 in 8688afa
Based on the message, I think it's just pulling in the RID-less build; since that looks like the output from
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' == ''">SR.SystemSecurityCryptography_PlatformNotSupported</GeneratePlatformNotSupportedAssemblyMessage>vcsjones commentedon Mar 5, 2024
It's not. We would need to treat
$(NetCoreAppCurrent)-wasithe same asbrowser.vcsjones commentedon Mar 5, 2024
We would also need to go and annotate all of our UnsupportedOSPlatforms that have browser with "wasi", I think.
lewing commentedon Apr 1, 2024
Correct, since wasi is still an experiemental platform we haven't annotated the apis for the analyzer yet. https://github.com/WebAssembly/WASI-crypto is the proposal we would wrap if we decide to add platform support.
dotnet-policy-service commentedon Jul 10, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
[wasi] Fix FileProviders.Physical test filtering on WASI
[wasi] Quarantine System.Text.Json tests that hash property names
[wasi] Fix FileProviders.Physical test filtering on WASI
13 remaining items
[wasi] Remove crypto quarantines now that WASI has System.Security.Cr…
[wasi] Run Microsoft.Bcl.Cryptography.Tests on WASI
[wasi] Fix FileProviders.Physical test filtering on WASI
[wasi] Quarantine System.Text.Json tests that hash property names
[wasi] Quarantine tests that need System.Security.Cryptography
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Remove crypto quarantines now that WASI has System.Security.Cr…
[wasi] Run Microsoft.Bcl.Cryptography.Tests on WASI
[wasi] Pass runtimeconfig properties to the runtime in wasihost (#134964
[wasi] Fix FileProviders.Physical test filtering on WASI
[wasi] Quarantine System.Text.Json tests that hash property names
[wasi] Quarantine tests that need System.Security.Cryptography
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Remove crypto quarantines now that WASI has System.Security.Cr…
[wasi] Run Microsoft.Bcl.Cryptography.Tests on WASI