2010-02-28 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Sun, 28 Feb 2010 16:28:11 +0000 (16:28 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sun, 28 Feb 2010 16:28:11 +0000 (16:28 -0000)
        *Mono.Security.Protocol.Tls/HttpsClientStream.cs,
        Mono.Security.Protocol.Tls/SslStreamBase.cs,
        Mono.Security.X509/PKCS12.cs,
        Mono.Security.X509/X509Certificate.cs,
        Mono.Security.Cryptography/RSAManaged.cs,
        Mono.Security.Cryptography/SymmetricTransform.cs,
        Mono.Security/ASN1Convert.cs: Drop the pre-NET 2.0 support.

svn path=/trunk/mcs/; revision=152622

mcs/class/Mono.Security/ChangeLog
mcs/class/Mono.Security/Mono.Security.Cryptography/RSAManaged.cs
mcs/class/Mono.Security/Mono.Security.Cryptography/SymmetricTransform.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Tls/HttpsClientStream.cs
mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslStreamBase.cs
mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs
mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs
mcs/class/Mono.Security/Mono.Security/ASN1Convert.cs

index c28d51bcdeb5d9eb5344e56f2d9d27e9f8f917c8..b44d10435eadf72237ffcecce00a223aff7c0b1e 100644 (file)
@@ -1,3 +1,13 @@
+2010-02-28  Miguel de Icaza  <miguel@novell.com>
+
+       *Mono.Security.Protocol.Tls/HttpsClientStream.cs,
+       Mono.Security.Protocol.Tls/SslStreamBase.cs,
+       Mono.Security.X509/PKCS12.cs,
+       Mono.Security.X509/X509Certificate.cs,
+       Mono.Security.Cryptography/RSAManaged.cs,
+       Mono.Security.Cryptography/SymmetricTransform.cs,
+       Mono.Security/ASN1Convert.cs: Drop the pre-NET 2.0 support.
+
 2008-06-26  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Mono.Security_test.dll.sources: Added SubjectAltNameExtension unit
index 29ee75a21ced7c9ee8d28fe8ce1b0a1fd1271057..9c406a200c73b9c557c78bac455378663640b2a3 100644 (file)
@@ -476,23 +476,13 @@ namespace Mono.Security.Cryptography {
                // internal for Mono 1.0.x in order to preserve public contract
                // they are public for Mono 1.1.x (for 1.2) as the API isn't froze ATM
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               bool UseKeyBlinding {
+               public bool UseKeyBlinding {
                        get { return keyBlinding; }
                        // you REALLY shoudn't touch this (true is fine ;-)
                        set { keyBlinding = value; }
                }
 
-#if NET_2_0
-               public
-#else
-               internal
-#endif
-               bool IsCrtPossible {
+               public bool IsCrtPossible {
                        // either the key pair isn't generated (and will be 
                        // generated with CRT parameters) or CRT is (or isn't)
                        // possible (in case the key was imported)
index 097e02878dbd4d2ea859f9bdf0ae9e3f2195af90..ab43c4a5becc4599a62a0bfe2fce1edcbb8f5e32 100644 (file)
@@ -69,14 +69,13 @@ namespace Mono.Security.Cryptography {
                        } else {
                                rgbIV = (byte[]) rgbIV.Clone ();
                        }
-#if NET_2_0
                        // compare the IV length with the "currently selected" block size and *ignore* IV that are too big
                        if (rgbIV.Length < BlockSizeByte) {
                                string msg = Locale.GetText ("IV is too small ({0} bytes), it should be {1} bytes long.",
                                        rgbIV.Length, BlockSizeByte);
                                throw new CryptographicException (msg);
                        }
-#endif
+
                        // mode buffers
                        temp = new byte [BlockSizeByte];
                        Buffer.BlockCopy (rgbIV, 0, temp, 0, System.Math.Min (BlockSizeByte, rgbIV.Length));
@@ -265,11 +264,7 @@ namespace Mono.Security.Cryptography {
                        } else if (KeepLastBlock) {
 #endif
                                if (0 > len + BlockSizeByte) {
-#if NET_2_0
                                        throw new CryptographicException ("outputBuffer", Locale.GetText ("Overflow"));
-#else
-                                       throw new IndexOutOfRangeException (Locale.GetText ("Overflow"));
-#endif
                                }
                        } else {
                                if (0 > len) {
@@ -340,7 +335,7 @@ namespace Mono.Security.Cryptography {
                        return total;
                }
 
-#if NET_2_0 && (!NET_2_1 || MONOTOUCH)
+#if (!NET_2_1 || MONOTOUCH)
                RandomNumberGenerator _rng;
 
                private void Random (byte[] buffer, int start, int length)
@@ -376,10 +371,8 @@ namespace Mono.Security.Cryptography {
                        total += BlockSizeByte;
 #else
                        switch (algo.Padding) {
-#if NET_2_0
                        case PaddingMode.ANSIX923:
                        case PaddingMode.ISO10126:
-#endif
                        case PaddingMode.PKCS7:
                                // we need to add an extra block for padding
                                total += BlockSizeByte;
@@ -423,7 +416,6 @@ namespace Mono.Security.Cryptography {
                        InternalTransformBlock (res, full, BlockSizeByte, res, full);
 #else
                        switch (algo.Padding) {
-#if NET_2_0
                        case PaddingMode.ANSIX923:
                                // XX 00 00 00 00 00 00 07 (zero + padding length)
                                res [res.Length - 1] = padding;
@@ -439,7 +431,6 @@ namespace Mono.Security.Cryptography {
                                // the last padded block will be transformed in-place
                                InternalTransformBlock (res, full, BlockSizeByte, res, full);
                                break;
-#endif // NET_2_0
                        case PaddingMode.PKCS7:
                                // XX 07 07 07 07 07 07 07 (padding length)
                                for (int i = res.Length; --i >= (res.Length - padding);) 
@@ -495,7 +486,6 @@ namespace Mono.Security.Cryptography {
                        total -= padding;
 #else
                        switch (algo.Padding) {
-#if NET_2_0
                        case PaddingMode.ANSIX923:
                                if ((padding == 0) || (padding > BlockSizeByte))
                                        ThrowBadPaddingException (algo.Padding, padding, -1);
@@ -523,7 +513,7 @@ namespace Mono.Security.Cryptography {
                        case PaddingMode.PKCS7:
                                total -= padding;
                                break;
-#endif // NET_2_0
+
                        case PaddingMode.None:  // nothing to do - it's a multiple of block size
                        case PaddingMode.Zeros: // nothing to do - user must unpad himself
                                break;
index 6f1bcc5e5acb8c8612d9f14dfd2707eaea1cd4ee..6c971dc39b07ec9c8f002380ea4341a6b289d4eb 100644 (file)
@@ -32,10 +32,8 @@ using System.IO;
 using System.Net;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
-#if NET_2_0
 using SNS = System.Net.Security;
 using SNCX = System.Security.Cryptography.X509Certificates;
-#endif
 
 namespace Mono.Security.Protocol.Tls {
 
@@ -61,7 +59,6 @@ namespace Mono.Security.Protocol.Tls {
                         // also saved from reflection
                         base.CheckCertRevocationStatus = ServicePointManager.CheckCertificateRevocationList;
 #endif
-#if NET_2_0
                        ClientCertSelection += delegate (X509CertificateCollection clientCerts, X509Certificate serverCertificate,
                                string targetHost, X509CertificateCollection serverRequestedCertificates) {
                                return ((clientCerts == null) || (clientCerts.Count == 0)) ? null : clientCerts [0];
@@ -70,7 +67,6 @@ namespace Mono.Security.Protocol.Tls {
                                X509Certificate2 cert = (certificate as X509Certificate2);
                                return (cert == null) ? null : cert.PrivateKey;
                        };
-#endif
                }
 
                public bool TrustFailure {
@@ -91,9 +87,7 @@ namespace Mono.Security.Protocol.Tls {
                        // only one problem can be reported by this interface
                        _status = ((failed) ? certificateErrors [0] : 0);
 
-#if NET_2_0
 #pragma warning disable 618
-#endif
                        if (ServicePointManager.CertificatePolicy != null) {
                                ServicePoint sp = _request.ServicePoint;
                                bool res = ServicePointManager.CertificatePolicy.CheckValidationResult (sp, certificate, _request, _status);
@@ -101,10 +95,8 @@ namespace Mono.Security.Protocol.Tls {
                                        return false;
                                failed = true;
                        }
-#if NET_2_0
 #pragma warning restore 618
-#endif
-#if NET_2_0
+
                        SNS.RemoteCertificateValidationCallback cb = ServicePointManager.ServerCertificateValidationCallback;
                        if (cb != null) {
                                SNS.SslPolicyErrors ssl_errors = 0;
@@ -122,7 +114,6 @@ namespace Mono.Security.Protocol.Tls {
                                        ssl_errors |= SNS.SslPolicyErrors.RemoteCertificateChainErrors;
                                return cb (_request, cert2, chain, ssl_errors);
                        }
-#endif
                        return failed;
                }
         }
index 988749b005bf68eac60da6a435e631655b49e608..34f8ceaa73e36c80bad808e87ba03a26063608f1 100644 (file)
@@ -901,11 +901,7 @@ namespace Mono.Security.Protocol.Tls
 
                public override void Close()
                {
-#if NET_2_0
                        base.Close ();
-#else
-                       ((IDisposable)this).Dispose();
-#endif
                }
 
                public override void Flush()
@@ -1164,17 +1160,7 @@ namespace Mono.Security.Protocol.Tls
                        this.Dispose(false);
                }
 
-#if !NET_2_0
-               public void Dispose()
-               {
-                       this.Dispose(true);
-                       GC.SuppressFinalize(this);
-               }
-
-               protected virtual void Dispose (bool disposing)
-#else
                protected override void Dispose (bool disposing)
-#endif
                {
                        if (!this.disposed)
                        {
@@ -1200,9 +1186,7 @@ namespace Mono.Security.Protocol.Tls
                                }
 
                                this.disposed = true;
-#if NET_2_0
                                base.Dispose (disposing);
-#endif
                        }
                }
 
index 86f4606106ad9c095a2f9b0c9096796b3a93c9b6..5ecce72b8db96d41dbc1aaa51cdfd990a99cb69f 100644 (file)
@@ -329,14 +329,14 @@ namespace Mono.Security.X509 {
                        Password = password;
                        Decode (data);
                }
-#if NET_2_0
+
                public PKCS12 (byte[] data, byte[] password)
                        : this ()
                {
                        _password = password;
                        Decode (data);
                }
-#endif
+
                private void Decode (byte[] data)
                {
                        ASN1 pfx = new ASN1 (data);
index 38edf17e71eb4a629c1b973221fb594466ace580..367be8dd90adccb544f4c61c8f772f238f992e67 100644 (file)
@@ -44,10 +44,8 @@ namespace Mono.Security.X509 {
 
 #if INSIDE_CORLIB
        internal class X509Certificate : ISerializable {
-#elif NET_2_0
-       public class X509Certificate : ISerializable {
 #else
-       public class X509Certificate {
+       public class X509Certificate : ISerializable {
 #endif
 
                private ASN1 decoder;
@@ -272,13 +270,12 @@ namespace Mono.Security.X509 {
                                }
                                return _dsa; 
                        }
-#if NET_2_0
+
                        set {
                                _dsa = value;
                                if (value != null)
                                        _rsa = null;
                        }
-#endif
                }
 
                public X509ExtensionCollection Extensions {
@@ -369,13 +366,12 @@ namespace Mono.Security.X509 {
                                }
                                return _rsa; 
                        }
-#if NET_2_0
+
                        set {
                                if (value != null)
                                        _dsa = null;
                                _rsa = value;
                        }
-#endif
                }
                
                public virtual byte[] RawData {
@@ -545,7 +541,7 @@ namespace Mono.Security.X509 {
                        }
                }
 
-#if INSIDE_CORLIB || NET_2_0
+#if INSIDE_CORLIB
                public ASN1 GetIssuerName ()
                {
                        return issuer;
index 612917cf3bcf6b5cf1021379061c278b053bffdb..c878a999eacc0b5e21d4d57f24694283e50fa37c 100644 (file)
@@ -46,15 +46,7 @@ namespace Mono.Security {
 #else
        public
 #endif
-#if NET_2_0
        static class ASN1Convert {
-#else
-       sealed class ASN1Convert {
-
-               private ASN1Convert ()
-               {
-               }
-#endif
                // RFC3280, section 4.2.1.5
                // CAs conforming to this profile MUST always encode certificate
                // validity dates through the year 2049 as UTCTime; certificate validity
@@ -182,9 +174,6 @@ namespace Mono.Security {
                        // to support both UTCTime and GeneralizedTime (and not so common format)
                        string mask = null;
                        int year;
-#if !NET_2_0
-                       bool utc = true;
-#endif
                        switch (t.Length) {
                                case 11:
                                        // illegal format, still it's supported for compatibility
@@ -215,19 +204,9 @@ namespace Mono.Security {
                                        t = String.Format ("{0}{1}{2}{3}{4}:{5}{6}", century, t.Substring (0, 12), sign, 
                                                t[13], t[14], t[15], t[16]);
                                        mask = "yyyyMMddHHmmsszzz";
-#if !NET_2_0
-                                       utc = false;
-#endif
                                        break;
                        }
-#if NET_2_0
                        return DateTime.ParseExact (t, mask, null, DateTimeStyles.AdjustToUniversal);
-#else
-                       DateTime result = DateTime.ParseExact (t, mask, null);
-                       if (utc)
-                               return result;
-                       return result.ToUniversalTime ();
-#endif
                }
        }
 }