Bug 23348 - Add SHA*CryptoServiceProvider and related types to System.Security.Cryptography under Mobile Profile
Summary: Add SHA*CryptoServiceProvider and related types to System.Security.Cryptograp...
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Security ()
Version: unspecified
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-24 13:22 UTC by Cody Beyer (MSFT)
Modified: 2015-10-23 09:49 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description Cody Beyer (MSFT) 2014-09-24 13:22:56 UTC
Such as: 
SHA256CryptoServiceProvider
SHA384CryptoServiceProvider
SHA512CryptoServiceProvider

Thanks
Comment 1 James Athey 2014-09-24 14:10:48 UTC
The documentation claims that these classes are present, in version 4.0.0.0 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 2.0.5.0, and 4.0.0.0 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).
Comment 2 Miguel de Icaza [MSFT] 2015-10-22 17:48:55 UTC
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.
Comment 3 James Athey 2015-10-23 09:49:56 UTC
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?