Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The documentation claims that these classes are present, in version 220.127.116.11 of the System.Core.dll assembly. (See http://androidapi.xamarin.com/?link=T%3aSystem.Security.Cryptography.SHA256CryptoServiceProvider ).
The version of System.Core.dll that ships with Xamarin is 18.104.22.168, and 22.214.171.124 is nowhere to be found.
These CryptoServiceProviders have been part of .NET since 3.5 ( http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha256cryptoserviceprovider(v=vs.110).aspx ) , and implementations of these classes have been part of Mono for 6 years ( https://github.com/mono/mono/tree/master/mcs/class/System.Core/System.Security.Cryptography ).
Other CryptoServiceProviders are already included (MD5 and SHA1).
We in general do not surface those APIs because there is a better option available and because it would increase the metadata for the code that we ship.
In general people should use the factory class, e.g. `SHA256.Create()`, to get the best implementation available
For example, on Xamarin.Mac and XAmarin.iOS those implementations use the hardware accelerated CommonCrypto implementations.
There may be a "better" option available if a developer only needs to target Xamarin.Android or Xamarin.iOS with their own code, but what about existing libraries from third parties? Getting other developers to care about the Xamarin platforms is more difficult when the code they already have requires significant rework just to compile.
There are so many useful NuGet packages in the wild that would be incredibly useful on mobile, but are unavailable because they rely on simple, fully managed classes that are available in desktop Mono but are excluded from Xamarin.
It's extra frustrating because no new code needs to be written. The code already exists in Mono - all that needs to be changed are some #if blocks.
How onerous is the metadata cost? These three classes have small API surface area. Is the additional metadata measured in bytes, or are we talking kilobytes? If the metadata is a concern, why was SHA1CryptoServiceProvider included but not SHA256CryptoServiceProvider?
If SHA256.Create() returns a hardware accelerated implementation on some platforms, why not use that to implement the SHA256CryptoServiceProvider?