// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2007,2011 Novell, Inc (http://www.novell.com)
+// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
CreateFromName ("RIPEMD-160", "System.Security.Cryptography.RIPEMD160Managed");
CreateFromName ("System.Security.Cryptography.RIPEMD160", "System.Security.Cryptography.RIPEMD160Managed");
// x.509 stuff
+#if !TARGET_JVM //TargetJvmNotWorking - this algorithm should be added to System
CreateFromName ("X509Chain", "System.Security.Cryptography.X509Certificates.X509Chain");
+#endif
#endif
// note: CryptoConfig can create any object !
CreateFromName ("System.Security.Cryptography.CryptoConfig", "System.Security.Cryptography.CryptoConfig");
// 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 NET_2_1
+ [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#hmac-sha1", null);
// URL used in DigestMethod element
CreateFromName ("http://www.w3.org/2000/09/xmldsig#sha1", "System.Security.Cryptography.SHA1CryptoServiceProvider");
+#if !TARGET_JVM //TargetJvmNotWorking - algorithms from System.Security assembly
// 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");
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");
+#if NET_2_0
+ 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");
+
+ CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha256", "System.Security.Cryptography.HMACSHA256");
+ CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha384", "System.Security.Cryptography.HMACSHA384");
+ CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#hmac-sha512", "System.Security.Cryptography.HMACSHA512");
+ CreateFromName ("http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160", "System.Security.Cryptography.HMACRIPEMD160");
+#endif
+#endif
}
[Test]
public void CreateFromName_UpperCase ()
{
CreateFromName ("SHA", "System.Security.Cryptography.SHA1CryptoServiceProvider");
+#if NET_2_0
CreateFromName ("SYSTEM.SECURITY.CRYPTOGRAPHY.TRIPLEDES", "System.Security.Cryptography.TripleDESCryptoServiceProvider");
CreateFromName ("HTTP://WWW.W3.ORG/2000/09/XMLDSIG#DSA-SHA1", "System.Security.Cryptography.DSASignatureDescription");
+#else
+ CreateFromName ("SYSTEM.SECURITY.CRYPTOGRAPHY.TRIPLEDES", null);
+ CreateFromName ("HTTP://WWW.W3.ORG/2000/09/XMLDSIG#DSA-SHA1", null);
+#endif
}
[Test]
public void CreateFromName_LowerCase ()
{
+#if NET_2_0
CreateFromName ("sha", "System.Security.Cryptography.SHA1CryptoServiceProvider");
CreateFromName ("system.security.cryptography.tripledes", "System.Security.Cryptography.TripleDESCryptoServiceProvider");
+#else
+ CreateFromName ("sha", null);
+ CreateFromName ("system.security.cryptography.tripledes", null);
+#endif
CreateFromName ("http://www.w3.org/2000/09/xmldsig#dsa-sha1", "System.Security.Cryptography.DSASignatureDescription");
}
[Test]
public void CreateFromName_MixedCase ()
{
+#if NET_2_0
CreateFromName ("ShA", "System.Security.Cryptography.SHA1CryptoServiceProvider");
CreateFromName ("SyStEm.SeCuRiTy.CrYpToGrApHy.TrIpLeDeS", "System.Security.Cryptography.TripleDESCryptoServiceProvider");
CreateFromName ("hTtP://wWw.W3.oRg/2000/09/xMlDsIg#dSa-sHa1", "System.Security.Cryptography.DSASignatureDescription");
+#else
+ CreateFromName ("ShA", null);
+ CreateFromName ("SyStEm.SeCuRiTy.CrYpToGrApHy.TrIpLeDeS", null);
+ CreateFromName ("hTtP://wWw.W3.oRg/2000/09/xMlDsIg#dSa-sHa1", null);
+#endif
}
// Tests created using "A Layer Man Guide to ASN.1" from RSA, page 19-20
MapNameToOID ("SHA512", "2.16.840.1.101.3.4.2.3");
MapNameToOID ("System.Security.Cryptography.SHA512", "2.16.840.1.101.3.4.2.3");
MapNameToOID ("System.Security.Cryptography.SHA512Managed", "2.16.840.1.101.3.4.2.3");
+ MapNameToOID ("RIPEMD160", "1.3.36.3.2.1");
+ MapNameToOID ("System.Security.Cryptography.RIPEMD160", "1.3.36.3.2.1");
+ MapNameToOID ("System.Security.Cryptography.RIPEMD160Managed", "1.3.36.3.2.1");
#else
MapNameToOID ("SHA256", "2.16.840.1.101.3.4.1");
// MapNameToOID ("SHA-256", "2.16.840.1.101.3.4.1");
public void MapNameToOID_UpperCase ()
{
MapNameToOID ("SHA1", "1.3.14.3.2.26");
+#if NET_2_0
MapNameToOID ("SYSTEM.SECURITY.CRYPTOGRAPHY.MD5CRYPTOSERVICEPROVIDER", "1.2.840.113549.2.5");
+#else
+ MapNameToOID ("SYSTEM.SECURITY.CRYPTOGRAPHY.MD5CRYPTOSERVICEPROVIDER", null);
+#endif
}
[Test]
public void MapNameToOID_LowerCase ()
{
+#if NET_2_0
MapNameToOID ("sha1", "1.3.14.3.2.26");
MapNameToOID ("system.security.cryptography.md5cryptoserviceprovider", "1.2.840.113549.2.5");
+#else
+ MapNameToOID ("sha1", null);
+ MapNameToOID ("system.security.cryptography.md5cryptoserviceprovider", null);
+#endif
}
[Test]
public void MapNameToOID_MixedCase ()
{
+#if NET_2_0
MapNameToOID ("sHa1", "1.3.14.3.2.26");
MapNameToOID ("SySteM.SeCuRiTy.CrYpToGrApHy.Md5cRyPtOsErViCePrOvIdEr", "1.2.840.113549.2.5");
+#else
+ MapNameToOID ("sHa1", null);
+ MapNameToOID ("SySteM.SeCuRiTy.CrYpToGrApHy.Md5cRyPtOsErViCePrOvIdEr", null);
+#endif
}
[Test]