New test.
[mono.git] / mcs / class / corlib / System.Security.Cryptography / TripleDES.cs
index e5715fdb3915526ce7119cc43a3746f5fd72b067..f368f7ca1ca147118a8796d1a429d063fa29976c 100644 (file)
@@ -5,11 +5,32 @@
 //     Sebastien Pouliot <sebastien@ximian.com>
 //
 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
+// Copyright (C) 2004-2006 Novell, Inc (http://www.novell.com)
 //
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if !MOONLIGHT
 
-using System;
 using System.Globalization;
+using System.Runtime.InteropServices;
 using System.Security.Cryptography;
 
 namespace System.Security.Cryptography {
@@ -21,14 +42,15 @@ namespace System.Security.Cryptography {
 //     not free :-(
 //     http://webstore.ansi.org/ansidocstore/product.asp?sku=ANSI+X9%2E52%2D1998
 
+[ComVisible (true)]
 public abstract class TripleDES : SymmetricAlgorithm {
 
-       public TripleDES ()
+       protected TripleDES ()
        {
                // from SymmetricAlgorithm
                KeySizeValue = 192;
                BlockSizeValue = 64;
-               FeedbackSizeValue = 64;
+               FeedbackSizeValue = 8;
 
                LegalKeySizesValue = new KeySizes [1];
                LegalKeySizesValue [0] = new KeySizes (128, 192, 64);
@@ -67,6 +89,8 @@ public abstract class TripleDES : SymmetricAlgorithm {
        //      if ( b == c ) then TripleDES == DES(a) (hence weak key)
        public static bool IsWeakKey (byte[] rgbKey)
        {
+               if (rgbKey == null)
+                       throw new CryptographicException (Locale.GetText ("Null Key"));
                // 128 bits (16 bytes) is 3 DES with 2 keys
                if (rgbKey.Length == 16) {
                        // weak if first half == second half
@@ -109,3 +133,6 @@ public abstract class TripleDES : SymmetricAlgorithm {
 }
 
 }
+
+#endif
+