Imported Upstream version 5.18.0.142

Former-commit-id: 7467d4b717762eeaf652d77f1486dd11ffb1ff1f
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-10-09 08:20:59 +00:00
parent e52655b4dc
commit 0abdbe5a7d
1547 changed files with 93792 additions and 47893 deletions

View File

@ -62,6 +62,8 @@ namespace System.Security.Cryptography {
if (name == null)
throw new ArgumentNullException ("name");
Type algoClass = null;
// TODO: These ignore args
switch (name.ToLowerInvariant ()) {
case "system.security.cryptography.dsacryptoserviceprovider":
@ -190,48 +192,51 @@ namespace System.Security.Cryptography {
case "3des":
return new TripleDESCryptoServiceProvider ();
// These are not yet linker friendly
// Use Type.GetType to be linker friendly
// TODO: This does not work when the assembly is not referenced by the project
case "x509chain":
name = "System.Security.Cryptography.X509Certificates.X509Chain, System";
algoClass = Type.GetType ("System.Security.Cryptography.X509Certificates.X509Chain, System");
break;
case "2.5.29.15":
name = "System.Security.Cryptography.X509Certificates.X509KeyUsageExtension, System";
algoClass = Type.GetType ("System.Security.Cryptography.X509Certificates.X509KeyUsageExtension, System");
break;
case "2.5.29.19":
name = "System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension, System";
algoClass = Type.GetType ("System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension, System");
break;
case "2.5.29.14":
name = "System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension, System";
algoClass = Type.GetType ("System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension, System");
break;
case "2.5.29.37":
name = "System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension, System";
algoClass = Type.GetType ("System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension, System");
break;
case "aes":
#if MONOTOUCH || XAMMAC
name = "System.Security.Cryptography.AesManaged, System.Core";
algoClass = Type.GetType ("System.Security.Cryptography.AesManaged, System.Core");
#else
name = "System.Security.Cryptography.AesCryptoServiceProvider, System.Core";
algoClass = Type.GetType ("System.Security.Cryptography.AesCryptoServiceProvider, System.Core");
#endif
break;
}
lock (lockObject) {
Type algoClass = null;
if (algorithms?.TryGetValue (name, out algoClass) == true) {
try {
return Activator.CreateInstance (algoClass, args);
} catch {
if (algoClass == null) {
lock (lockObject) {
if (algorithms?.TryGetValue (name, out algoClass) == true) {
try {
return Activator.CreateInstance (algoClass, args);
} catch {
}
}
}
algoClass = Type.GetType (name);
}
try {
// last resort, the request type might be available (if care is taken for the type not to be linked
// away) and that can allow some 3rd party code to work (e.g. extra algorithms) and make a few more
// unit tests happy
return Activator.CreateInstance (Type.GetType (name), args);
}
catch {
return Activator.CreateInstance (algoClass, args);
} catch {
// method doesn't throw any exception
return null;
}