Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[corlib] Enable machine.config dependant version of CryptoConfig for net_4_x profile only #7871

Merged
merged 2 commits into from
Apr 3, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions mcs/class/corlib/LinkerDescriptor/mscorlib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<type fullname="System.Exception" preserve="fields">
<!-- used in mini-exceptions.c (if trace is enabled) -->
<method name="get_Message" />
<method name="FixRemotingException" feature="remoting" />
</type>

<!-- exception.c (mono_get_exception_execution_engine) -->
Expand Down Expand Up @@ -229,6 +230,9 @@
<method signature="System.Void .ctor(System.String)" />
</type>

<!-- reflection.c mono_get_reflection_missing_object -->
<type fullname="System.Missing" preserve="fields" />

<type fullname="System.MarshalByRefObject" preserve="fields" feature="remoting" />

<type fullname="System.MethodAccessException">
Expand Down
5 changes: 5 additions & 0 deletions mcs/class/corlib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ endif
TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe \
-define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%) -resource:LinkerDescriptor/mscorlib_test.xml,$(test_lib:.dll=.xml)

ifeq ($(PROFILE),net_4_x)
LIB_MCS_FLAGS += -d:FEATURE_CRYPTO_CONFIGURABLE
TEST_MCS_FLAGS += -d:FEATURE_CRYPTO_CONFIGURABLE
endif


CC_PROFILE := $(filter monotouch% xammac, $(PROFILE))
ifdef CC_PROFILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#if FULL_AOT_RUNTIME
#if !FEATURE_CRYPTO_CONFIGURABLE

// This is a special version of CryptoConfig that is not configurable and
// every "choice" is statiscally compiled. As long as CreateFromName is not
Expand Down Expand Up @@ -61,7 +61,6 @@ public static object CreateFromName (string name)
return CreateFromName (name, null);
}

[PermissionSet (SecurityAction.LinkDemand, Unrestricted = true)]
public static object CreateFromName (string name, params object[] args)
{
if (name == null)
Expand Down Expand Up @@ -156,8 +155,8 @@ public static object CreateFromName (string name, params object[] args)
case "system.security.cryptography.hashalgorithm":
case "system.security.cryptography.sha1":
case "system.security.cryptography.sha1cryptoserviceprovider":
case "system.security.cryptography.sha1cng":
case "sha1":
case "system.security.cryptography.sha1cng":
case "sha":
case "http://www.w3.org/2000/09/xmldsig#sha1":
return new SHA1CryptoServiceProvider ();
Expand Down Expand Up @@ -197,10 +196,10 @@ public static object CreateFromName (string name, params object[] args)
name = "System.Security.Cryptography.X509Certificates.X509Chain, System";
break;
case "aes":
#if FULL_AOT_DESKTOP // TODO: why is this special cased? we could use AesManaged like other full AOT profiles
name = "System.Security.Cryptography.AesCryptoServiceProvider, System.Core";
#else
#if MONOTOUCH || XAMMAC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would need to add XAMMAC_4_5 to keep the previous meaning. But I think we should just go with AesManaged on all !FEATURE_CRYPTO_CONFIGURABLE platforms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file was not used before with XAMMAC_4_5 and it returned null for the value (that's another bug).

.NET returns AesCryptoServiceProvider and I don't think we need to break the compatibility here. My preference would be to remove if MONOTOUCH || XAMMAC instead but that needs more work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, I got confused by all the conditions here :)

name = "System.Security.Cryptography.AesManaged, System.Core";
#else
name = "System.Security.Cryptography.AesCryptoServiceProvider, System.Core";
#endif
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#if !FULL_AOT_RUNTIME
#if FEATURE_CRYPTO_CONFIGURABLE

using System.Collections;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,9 @@ public void CreateFromName ()
// additional names (URL) used for XMLDSIG (System.Security.Cryptography.Xml)
// URL taken from http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/
[Test]
#if MOBILE
[Ignore ("System.Security.dll is not part of Moonlight, MonoTouch and Mono for Android")]
#endif
public void CreateFromURL ()
{
// URL used in SignatureMethod element
CreateFromName ("http://www.w3.org/2000/09/xmldsig#dsa-sha1", "System.Security.Cryptography.DSASignatureDescription");
CreateFromName ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.RSAPKCS1SHA1SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.RSAPKCS1SHA256SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.RSAPKCS1SHA384SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", "System.Security.Cryptography.RSAPKCS1SHA512SignatureDescription");
CreateFromName ("http://www.w3.org/2000/09/xmldsig#hmac-sha1", "System.Security.Cryptography.HMACSHA1");
// URL used in DigestMethod element
CreateFromName ("http://www.w3.org/2000/09/xmldsig#sha1", "System.Security.Cryptography.SHA1CryptoServiceProvider");
#if FEATURE_CRYPTO_CONFIGURABLE
// URL used in Canonicalization or Transform elements
CreateFromName ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315", "System.Security.Cryptography.Xml.XmlDsigC14NTransform");
CreateFromName ("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments", "System.Security.Cryptography.Xml.XmlDsigC14NWithCommentsTransform");
Expand All @@ -171,6 +160,17 @@ public void CreateFromURL ()
CreateFromName ("http://www.w3.org/2000/09/xmldsig# KeyValue/DSAKeyValue", "System.Security.Cryptography.Xml.DSAKeyValue");
CreateFromName ("http://www.w3.org/2000/09/xmldsig# KeyValue/RSAKeyValue", "System.Security.Cryptography.Xml.RSAKeyValue");
CreateFromName ("http://www.w3.org/2000/09/xmldsig# RetrievalMethod", "System.Security.Cryptography.Xml.KeyInfoRetrievalMethod");
#endif
// URL used in SignatureMethod element
CreateFromName ("http://www.w3.org/2000/09/xmldsig#dsa-sha1", "System.Security.Cryptography.DSASignatureDescription");
CreateFromName ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.RSAPKCS1SHA1SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.RSAPKCS1SHA256SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.RSAPKCS1SHA384SignatureDescription");
CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", "System.Security.Cryptography.RSAPKCS1SHA512SignatureDescription");
CreateFromName ("http://www.w3.org/2000/09/xmldsig#hmac-sha1", "System.Security.Cryptography.HMACSHA1");
// URL used in DigestMethod element
CreateFromName ("http://www.w3.org/2000/09/xmldsig#sha1", "System.Security.Cryptography.SHA1CryptoServiceProvider");

CreateFromName ("http://www.w3.org/2001/04/xmlenc#sha256", "System.Security.Cryptography.SHA256Managed");
CreateFromName ("http://www.w3.org/2001/04/xmlenc#sha384", null);
CreateFromName ("http://www.w3.org/2001/04/xmlenc#sha512", "System.Security.Cryptography.SHA512Managed");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,16 @@ public void DSASignatureDescription ()
[Test]
public void RSASignatureDescription ()
{
// TODO: this would be cleaner with NUnit TestCase'es but they're NUnit 2.5+ :(
#if FULL_AOT_RUNTIME || MONOTOUCH || MONODROID || XAMMAC || XAMMAC_4_5
RSASignatureDescriptionCore ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.SHA1Cng", "System.Security.Cryptography.SHA1CryptoServiceProvider");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.SHA256Cng", "System.Security.Cryptography.SHA256Managed");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.SHA384Cng", "System.Security.Cryptography.SHA384Managed");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", "System.Security.Cryptography.SHA512Cng", "System.Security.Cryptography.SHA512Managed");
#else
#if FEATURE_CRYPTO_CONFIGURABLE
RSASignatureDescriptionCore ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.SHA1Cng", "System.Security.Cryptography.SHA1Cng");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.SHA256Cng", "System.Security.Cryptography.SHA256Cng");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.SHA384Cng", "System.Security.Cryptography.SHA384Cng");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", "System.Security.Cryptography.SHA512Cng", "System.Security.Cryptography.SHA512Cng");
#else
RSASignatureDescriptionCore ("http://www.w3.org/2000/09/xmldsig#rsa-sha1", "System.Security.Cryptography.SHA1Cng", "System.Security.Cryptography.SHA1CryptoServiceProvider");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", "System.Security.Cryptography.SHA256Cng", "System.Security.Cryptography.SHA256Managed");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha384", "System.Security.Cryptography.SHA384Cng", "System.Security.Cryptography.SHA384Managed");
RSASignatureDescriptionCore ("http://www.w3.org/2001/04/xmldsig-more#rsa-sha512", "System.Security.Cryptography.SHA512Cng", "System.Security.Cryptography.SHA512Managed");
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion mcs/class/corlib/corlib.dll.sources
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ System.Security.AccessControl/SystemAcl.cs
System.Security.Cryptography/CryptoAPITransform.cs
System.Security.Cryptography/CryptoConfig.cs
System.Security.Cryptography/CryptoConfig.common.cs
System.Security.Cryptography/CryptoConfig.fullaot.cs
System.Security.Cryptography/CryptoConfig.Mobile.cs
System.Security.Cryptography/CspKeyContainerInfo.cs
System.Security.Cryptography/DESCryptoServiceProvider.cs
System.Security.Cryptography/DSACryptoServiceProvider.cs
Expand Down