Merge pull request #697 from linquize/atom-bug
[mono.git] / mcs / class / corlib / System.Security.Cryptography / DSASignatureDeformatter.cs
index a0b74e1fe0f8688095d06d765be35e6350632673..6a7284a036e9e4a2f60d4de8ce7bb9d8b3dff591 100644 (file)
@@ -3,10 +3,11 @@
 //
 // Authors:
 //     Thomas Neidhart (tome@sbox.tugraz.at)
-//     Sebastien Pouliot (sebastien@ximian.com)
+//     Sebastien Pouliot  <sebastien@xamarin.com>
 //
 // Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
 // Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright 2013 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
 using System.Globalization;
 using System.Runtime.InteropServices;
 
+using Mono.Security.Cryptography;
+
 namespace System.Security.Cryptography {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public class DSASignatureDeformatter : AsymmetricSignatureDeformatter {
        
                private DSA dsa;
@@ -54,14 +55,10 @@ namespace System.Security.Cryptography {
                        if (strName == null)
                                throw new ArgumentNullException ("strName");
 
-                       try {
-                               // just to test, we don't need the object
-                               SHA1.Create (strName);
-                       }
-                       catch (InvalidCastException) {
+                       var instance = PKCS1.CreateFromName (strName) as SHA1;
+                       if (instance == null)
                                throw new CryptographicUnexpectedOperationException (
                                        Locale.GetText ("DSA requires SHA1"));
-                       }
                }
 
                public override void SetKey (AsymmetricAlgorithm key)
@@ -71,12 +68,8 @@ namespace System.Security.Cryptography {
                                // a DSA keypair
                                dsa = (DSA) key;
                        }
-#if NET_2_0
                        else
                                throw new ArgumentNullException ("key");
-#else
-                       // null is accepted in 1.0/1.1
-#endif
                }
 
                public override bool VerifySignature (byte[] rgbHash, byte[] rgbSignature)