2002-11-20 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / AsymmetricSignatureDeformatter.cs
1 //
2 // System.Security.Cryptography AsymmetricSignatureDeformatter Class implementation
3 //
4 // Authors:
5 //   Thomas Neidhart (tome@sbox.tugraz.at)
6 //
7
8 using System;
9 using System.Security;
10
11 namespace System.Security.Cryptography {
12         
13         /// <summary>
14         /// Abstract base class for all asymmetric signature deformatter.
15         /// Available derived classes:
16         /// DSASignatureDeformatter, RSAPKCS1SignatureDeformatter
17         /// </summary>
18         public abstract class AsymmetricSignatureDeformatter {
19                 
20                 /// <summary>
21                 /// constructor, no idea why it is here (abstract class)  :-)
22                 /// just for compatibility with MS
23                 /// </summary>
24                 public AsymmetricSignatureDeformatter () {}
25                 
26                 /// <summary>
27                 /// Sets the hash algorithm used for verifying a signature
28                 /// </summary>
29                 public abstract void SetHashAlgorithm (string strName);         
30                 
31                 /// <summary>
32                 /// set the keypair
33                 /// </summary>
34                 public abstract void SetKey (AsymmetricAlgorithm key);
35                 
36                 /// <summary>
37                 /// Verifies the given Signature
38                 /// </summary>
39                 public abstract bool VerifySignature (byte[] rgbHash, byte[] rgbSignature);
40
41                 /// <summary>
42                 /// Verifies the given Signature with the given hash algorithm
43                 /// </summary>
44                 public virtual bool VerifySignature (HashAlgorithm hash, byte[] rgbSignature) 
45                 {
46                         if (hash == null)
47                                 throw new ArgumentNullException ("hash");
48                         return VerifySignature (hash.Hash, rgbSignature);
49                 }
50                 
51         } // AsymmetricSignatureDeformatter
52         
53 } // System.Security.Cryptography
54