diff options
23 files changed, 154 insertions, 25 deletions
diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs index bee47e7b045..0aab36a9fe6 100644 --- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs +++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs @@ -27,6 +27,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System; using System.IO; using System.Security.Cryptography; @@ -279,3 +281,6 @@ namespace Mono.Security.Authenticode { } } } + +#endif + diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs index a92affc4e54..6e7b19ac688 100644 --- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs +++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs @@ -27,6 +27,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System; using System.IO; using System.Runtime.InteropServices; @@ -454,3 +456,6 @@ namespace Mono.Security.Authenticode { } } } + +#endif + diff --git a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog index 314be8aabb6..e1b8d247c02 100644 --- a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog +++ b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog @@ -1,3 +1,7 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * AuthenticodeBase.cs, AuthenticodeDeformatter.cs: Remove from NET_2_1 + 2008-01-10 Sebastien Pouliot <sebastien@ximian.com> * AuthenticodeDeformatter.cs: Use RSAManaged and the new overloaded diff --git a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog index 96a0e2d4edd..4105259a5e4 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog +++ b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog @@ -1,3 +1,10 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * CryptoConvert.cs, PKCS8.cs: Adapt to work with only [DSA|RSA] + Managed when built for NET_2_1, i.e. remove use of [DSA|RSA] + CryptoServiceProvider + * KeyPairPersistence.cs: Remove from NET_2_1 + 2009-04-29 Sebastien Pouliot <sebastien@ximian.com> * PKCS1.cs: Make this work under NET_2_1 where SHA384 and SHA512 diff --git a/mcs/class/corlib/Mono.Security.Cryptography/CryptoConvert.cs b/mcs/class/corlib/Mono.Security.Cryptography/CryptoConvert.cs index 9a3ae265633..a56e94d01e2 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/CryptoConvert.cs +++ b/mcs/class/corlib/Mono.Security.Cryptography/CryptoConvert.cs @@ -166,6 +166,10 @@ namespace Mono.Security.Cryptography { throw new CryptographicException ("Invalid blob.", e); } +#if NET_2_1 + RSA rsa = RSA.Create (); + rsa.ImportParameters (rsap); +#else RSA rsa = null; try { rsa = RSA.Create (); @@ -186,6 +190,7 @@ namespace Mono.Security.Cryptography { throw ce; } } +#endif return rsa; } @@ -246,6 +251,10 @@ namespace Mono.Security.Cryptography { throw new CryptographicException ("Invalid blob.", e); } +#if NET_2_1 + DSA dsa = (DSA)DSA.Create (); + dsa.ImportParameters (dsap); +#else DSA dsa = null; try { dsa = (DSA)DSA.Create (); @@ -266,6 +275,7 @@ namespace Mono.Security.Cryptography { throw ce; } } +#endif return dsa; } @@ -434,7 +444,10 @@ namespace Mono.Security.Cryptography { rsap.Modulus = new byte [byteLen]; Buffer.BlockCopy (blob, pos, rsap.Modulus, 0, byteLen); Array.Reverse (rsap.Modulus); - +#if NET_2_1 + RSA rsa = RSA.Create (); + rsa.ImportParameters (rsap); +#else RSA rsa = null; try { rsa = RSA.Create (); @@ -449,6 +462,7 @@ namespace Mono.Security.Cryptography { rsa = new RSACryptoServiceProvider (csp); rsa.ImportParameters (rsap); } +#endif return rsa; } catch (Exception e) { diff --git a/mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs b/mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs index a19dc7afbe4..fcb379a008d 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs +++ b/mcs/class/corlib/Mono.Security.Cryptography/KeyPairPersistence.cs @@ -26,6 +26,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System; using System.Globalization; using System.IO; @@ -452,3 +454,6 @@ namespace Mono.Security.Cryptography { } } } + +#endif + diff --git a/mcs/class/corlib/Mono.Security.Cryptography/PKCS8.cs b/mcs/class/corlib/Mono.Security.Cryptography/PKCS8.cs index 164466487e1..1ca6b795fed 100644 --- a/mcs/class/corlib/Mono.Security.Cryptography/PKCS8.cs +++ b/mcs/class/corlib/Mono.Security.Cryptography/PKCS8.cs @@ -272,7 +272,10 @@ namespace Mono.Security.Cryptography { param.InverseQ = Normalize (privateKey [8].Value, keysize2); param.P = Normalize (privateKey [4].Value, keysize2); param.Q = Normalize (privateKey [5].Value, keysize2); - +#if NET_2_1 + RSA rsa = RSA.Create (); + rsa.ImportParameters (param); +#else RSA rsa = null; try { rsa = RSA.Create (); @@ -287,6 +290,7 @@ namespace Mono.Security.Cryptography { rsa = new RSACryptoServiceProvider (csp); rsa.ImportParameters (param); } +#endif return rsa; } diff --git a/mcs/class/corlib/Mono.Security.X509/ChangeLog b/mcs/class/corlib/Mono.Security.X509/ChangeLog index 59e1fe7e25f..23e3e27ca28 100644 --- a/mcs/class/corlib/Mono.Security.X509/ChangeLog +++ b/mcs/class/corlib/Mono.Security.X509/ChangeLog @@ -1,3 +1,8 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * X509Certificate.cs: Adapt to work with only [DSA|RSA]Managed when + built for NET_2_1, i.e. remove use of [DSA|RSA]CryptoServiceProvider + 2008-09-12 Sebastien Pouliot <sebastien@ximian.com> * PKCS12.cs, X509Store.cs: Use File.Create instead of OpenWrite to diff --git a/mcs/class/corlib/Mono.Security.X509/X509Certificate.cs b/mcs/class/corlib/Mono.Security.X509/X509Certificate.cs index 38edf17e71e..71afeb0f2a2 100644 --- a/mcs/class/corlib/Mono.Security.X509/X509Certificate.cs +++ b/mcs/class/corlib/Mono.Security.X509/X509Certificate.cs @@ -34,6 +34,8 @@ using SSCX = System.Security.Cryptography.X509Certificates; using System.Security.Permissions; using System.Text; +using Mono.Security.Cryptography; + namespace Mono.Security.X509 { // References: @@ -267,8 +269,12 @@ namespace Mono.Security.X509 { // BUG: MS BCL 1.0 can't import a key which // isn't the same size as the one present in // the container. +#if NET_2_1 + _dsa = new DSAManaged (dsaParams.Y.Length << 3); +#else _dsa = (DSA) new DSACryptoServiceProvider (dsaParams.Y.Length << 3); _dsa.ImportParameters (dsaParams); +#endif } return _dsa; } @@ -364,8 +370,12 @@ namespace Mono.Security.X509 { // isn't the same size as the one present in // the container. int keySize = (rsaParams.Modulus.Length << 3); +#if NET_2_1 + _rsa = new RSAManaged (keySize); +#else _rsa = (RSA) new RSACryptoServiceProvider (keySize); _rsa.ImportParameters (rsaParams); +#endif } return _rsa; } @@ -493,27 +503,33 @@ namespace Mono.Security.X509 { return v.VerifySignature (this.Hash, this.Signature); } + internal string GetHashNameFromOID (string oid) + { + switch (oid) { + // MD2 with RSA encryption + case "1.2.840.113549.1.1.2": + // maybe someone installed MD2 ? + return "MD2"; + // MD5 with RSA encryption + case "1.2.840.113549.1.1.4": + return "MD5"; + // SHA-1 with RSA Encryption + case "1.2.840.113549.1.1.5": + case "1.3.14.3.2.29": + return "SHA1"; + default: + return null; + } + } + internal bool VerifySignature (RSA rsa) { RSAPKCS1SignatureDeformatter v = new RSAPKCS1SignatureDeformatter (rsa); - switch (m_signaturealgo) { - // MD2 with RSA encryption - case "1.2.840.113549.1.1.2": - // maybe someone installed MD2 ? - v.SetHashAlgorithm ("MD2"); - break; - // MD5 with RSA encryption - case "1.2.840.113549.1.1.4": - v.SetHashAlgorithm ("MD5"); - break; - // SHA-1 with RSA Encryption - case "1.2.840.113549.1.1.5": - case "1.3.14.3.2.29": - v.SetHashAlgorithm ("SHA1"); - break; - default: - throw new CryptographicException ("Unsupported hash algorithm: " + m_signaturealgo); - } + string hashName = GetHashNameFromOID (m_signaturealgo); + if (hashName == null) + throw new CryptographicException ("Unsupported hash algorithm: " + m_signaturealgo); + + v.SetHashAlgorithm (hashName); return v.VerifySignature (this.Hash, this.Signature); } @@ -532,8 +548,14 @@ namespace Mono.Security.X509 { public bool CheckSignature (byte[] hash, string hashAlgorithm, byte[] signature) { +#if NET_2_1 + string hashName = GetHashNameFromOID (hashAlgorithm); + HashAlgorithm algo = HashAlgorithm.Create (hashName); + return PKCS1.Verify_v15 (RSA, algo, hash, signature); +#else RSACryptoServiceProvider r = (RSACryptoServiceProvider) RSA; return r.VerifyHash (hash, hashAlgorithm, signature); +#endif } public bool IsSelfSigned { diff --git a/mcs/class/corlib/Mono.Security/ChangeLog b/mcs/class/corlib/Mono.Security/ChangeLog index 7e453b9ed80..4f3f436deb7 100644 --- a/mcs/class/corlib/Mono.Security/ChangeLog +++ b/mcs/class/corlib/Mono.Security/ChangeLog @@ -1,3 +1,8 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * StrongName.cs: Adapt to work with only RSAManaged when built + for NET_2_1, i.e. remove use of RSACryptoServiceProvider + 2008-09-12 Sebastien Pouliot <sebastien@ximian.com> * ASN1.cs: Use File.Create instead of OpenWrite to make sure nothing diff --git a/mcs/class/corlib/Mono.Security/StrongName.cs b/mcs/class/corlib/Mono.Security/StrongName.cs index a2101f57c09..1c696722492 100644 --- a/mcs/class/corlib/Mono.Security/StrongName.cs +++ b/mcs/class/corlib/Mono.Security/StrongName.cs @@ -160,7 +160,7 @@ namespace Mono.Security { get { if (rsa == null) return false; -#if INSIDE_CORLIB +#if INSIDE_CORLIB && !NET_2_1 // the easy way if (RSA is RSACryptoServiceProvider) { // available as internal for corlib diff --git a/mcs/class/corlib/System.Reflection/ChangeLog b/mcs/class/corlib/System.Reflection/ChangeLog index 9af9ef6b63d..5af04cb86cb 100644 --- a/mcs/class/corlib/System.Reflection/ChangeLog +++ b/mcs/class/corlib/System.Reflection/ChangeLog @@ -1,3 +1,10 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * Module.cs: Exclude GetSignerCertificate (Authenticode related) + from NET_2_1 + * StrongNameKeyPair.cs: Adapt to work with only RSAManaged when + built for NET_2_1, i.e. remove use of RSACryptoServiceProvider + 2009-03-26 Zoltan Varga <vargaz@gmail.com> * MonoMethod.cs: Add a 'member' argument to the get_parameter_info () icall. diff --git a/mcs/class/corlib/System.Reflection/Module.cs b/mcs/class/corlib/System.Reflection/Module.cs index 43e05a8c758..db4f1343b94 100644 --- a/mcs/class/corlib/System.Reflection/Module.cs +++ b/mcs/class/corlib/System.Reflection/Module.cs @@ -233,7 +233,8 @@ namespace System.Reflection { UnitySerializationHolder.GetModuleData (this, info, context); } - + +#if !NET_2_1 public X509Certificate GetSignerCertificate () { try { @@ -243,6 +244,7 @@ namespace System.Reflection { return null; } } +#endif #if NET_2_0 [ComVisible (true)] diff --git a/mcs/class/corlib/System.Reflection/StrongNameKeyPair.cs b/mcs/class/corlib/System.Reflection/StrongNameKeyPair.cs index 6dda87f5505..54118698219 100644 --- a/mcs/class/corlib/System.Reflection/StrongNameKeyPair.cs +++ b/mcs/class/corlib/System.Reflection/StrongNameKeyPair.cs @@ -129,11 +129,13 @@ public class StrongNameKeyPair _keyPairArray = null; } } +#if !NET_2_1 else if (_keyPairContainer != null) { CspParameters csp = new CspParameters (); csp.KeyContainerName = _keyPairContainer; _rsa = new RSACryptoServiceProvider (csp); } +#endif return _rsa; } diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog index afe1d3c0444..5835c3fb6e2 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog @@ -1,3 +1,9 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * X509Certificate.cs: Remove CreateFromSignedFile from NET_2_1 + since it's unneeded and bring more code and [SecuritySafeCritical] + API into the assemblies. + 2008-08-18 Sebastien Pouliot <sebastien@ximian.com> * X509Certificate[20].cs: Silverlight 2.0 does not implement either diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs index e39a4a41a59..0722b818517 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs @@ -33,12 +33,14 @@ using System.Security.Permissions; using System.Text; using Mono.Security; -using Mono.Security.Authenticode; using Mono.Security.X509; #if NET_2_0 using System.Runtime.Serialization; #endif +#if !NET_2_1 +using Mono.Security.Authenticode; +#endif namespace System.Security.Cryptography.X509Certificates { @@ -101,7 +103,8 @@ namespace System.Security.Cryptography.X509Certificates { byte[] data = Load (filename); return new X509Certificate (data); } - + +#if !NET_2_1 [MonoTODO ("Incomplete - minimal validation in this version")] public static X509Certificate CreateFromSignedFile (string filename) { @@ -142,7 +145,9 @@ namespace System.Security.Cryptography.X509Certificates { return new X509Certificate (cert); #endif } - + +#endif // NET_2_1 + // constructors // special constructor for Publisher (and related classes). diff --git a/mcs/class/corlib/System.Security.Cryptography/ChangeLog b/mcs/class/corlib/System.Security.Cryptography/ChangeLog index b8022fa6f10..fc930d29417 100644 --- a/mcs/class/corlib/System.Security.Cryptography/ChangeLog +++ b/mcs/class/corlib/System.Security.Cryptography/ChangeLog @@ -1,3 +1,8 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * DSACryptoServiceProvider.cs, RSACryptoServiceProvider.cs: Remove + from NET_2_1 + 2009-04-29 Sebastien Pouliot <sebastien@ximian.com> * DES.cs, DESCryptoServiceProvider.cs: Do not include in NET_2_1 diff --git a/mcs/class/corlib/System.Security.Cryptography/DSACryptoServiceProvider.cs b/mcs/class/corlib/System.Security.Cryptography/DSACryptoServiceProvider.cs index 588de7b2a62..f6500cd3cd1 100644 --- a/mcs/class/corlib/System.Security.Cryptography/DSACryptoServiceProvider.cs +++ b/mcs/class/corlib/System.Security.Cryptography/DSACryptoServiceProvider.cs @@ -31,6 +31,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System.IO; using System.Globalization; using System.Runtime.InteropServices; @@ -314,3 +316,6 @@ namespace System.Security.Cryptography { #endif } } + +#endif + diff --git a/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs b/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs index 6f0e3626167..0b87ee459d6 100644 --- a/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs +++ b/mcs/class/corlib/System.Security.Cryptography/RSACryptoServiceProvider.cs @@ -29,6 +29,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System.IO; using System.Runtime.InteropServices; @@ -428,3 +430,6 @@ namespace System.Security.Cryptography { #endif } } + +#endif + diff --git a/mcs/class/corlib/System.Security.Permissions/ChangeLog b/mcs/class/corlib/System.Security.Permissions/ChangeLog index 623a8ce150a..2d936a875b6 100644 --- a/mcs/class/corlib/System.Security.Permissions/ChangeLog +++ b/mcs/class/corlib/System.Security.Permissions/ChangeLog @@ -1,3 +1,7 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * PublisherIdentityPermissionAttribute.cs: Remove from NET_2_1 + 2008-07-06 Andreas Nahr <ClassDevelopment@A-SoftTech.com> * ReflectionPermissionFlag.cs: Add missing member diff --git a/mcs/class/corlib/System.Security.Permissions/PublisherIdentityPermissionAttribute.cs b/mcs/class/corlib/System.Security.Permissions/PublisherIdentityPermissionAttribute.cs index 80d034feb92..78fa1710695 100644 --- a/mcs/class/corlib/System.Security.Permissions/PublisherIdentityPermissionAttribute.cs +++ b/mcs/class/corlib/System.Security.Permissions/PublisherIdentityPermissionAttribute.cs @@ -27,6 +27,8 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +#if !NET_2_1 + using System.Runtime.InteropServices; using SSCX = System.Security.Cryptography.X509Certificates; @@ -92,3 +94,6 @@ namespace System.Security.Permissions { } } } + +#endif + diff --git a/mcs/class/corlib/System.Security.Policy/ChangeLog b/mcs/class/corlib/System.Security.Policy/ChangeLog index a07afcc5038..a340589593a 100644 --- a/mcs/class/corlib/System.Security.Policy/ChangeLog +++ b/mcs/class/corlib/System.Security.Policy/ChangeLog @@ -1,3 +1,8 @@ +2009-04-30 Sebastien Pouliot <sebastien@ximian.com> + + * Evidence.cs: Exclude "Mono.Security.Authenticode" when building + NET_2_1 + 2009-04-27 Sebastien Pouliot <sebastien@ximian.com> * Evidence.cs: Custom GetDefaultHostEvidence for NET_2_1 diff --git a/mcs/class/corlib/System.Security.Policy/Evidence.cs b/mcs/class/corlib/System.Security.Policy/Evidence.cs index 1a192663e99..ae4d56ad12b 100644 --- a/mcs/class/corlib/System.Security.Policy/Evidence.cs +++ b/mcs/class/corlib/System.Security.Policy/Evidence.cs @@ -39,7 +39,9 @@ using System.Runtime.InteropServices; using System.Security.Permissions; using System.Security.Cryptography.X509Certificates; +#if !NET_2_1 using Mono.Security.Authenticode; +#endif namespace System.Security.Policy { |