2002-11-15 Sebastien Pouliot <spouliot@videotron.ca>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / RSAPKCS1SignatureDeformatter.cs
1 //
2 // RSAPKCS1SignatureDeformatter.cs - Handles PKCS#1 v.1.5 signature decryption.
3 //
4 // Author:
5 //      Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
8 //
9
10 using System;
11
12 namespace System.Security.Cryptography { 
13
14 public class RSAPKCS1SignatureDeformatter : AsymmetricSignatureDeformatter {
15
16         private RSA rsa;
17         private HashAlgorithm hash;
18
19         public RSAPKCS1SignatureDeformatter () 
20         {
21                 rsa = null;
22         }
23
24         public RSAPKCS1SignatureDeformatter (AsymmetricAlgorithm key) 
25         {
26                 SetKey (key);
27         }
28
29         public override void SetHashAlgorithm (string strName) 
30         {
31                 hash = HashAlgorithm.Create (strName);
32         }
33
34         public override void SetKey (AsymmetricAlgorithm key) 
35         {
36                 if (key != null) {
37                         if (key is RSA) {
38                                 rsa = (RSA)key;
39                         }
40                         else
41                                 throw new InvalidCastException ();
42                 }
43                 // here null is accepted!
44         }
45
46         [MonoTODO()]
47         public override bool VerifySignature (byte[] rgbHash, byte[] rgbSignature) 
48         {
49                 if ((rsa == null) || (hash == null))
50                         throw new CryptographicUnexpectedOperationException ();
51                 if ((rgbHash == null) || (rgbSignature == null))
52                         throw new ArgumentNullException ();
53                 // TODO
54                 return false;
55         }
56
57         [MonoTODO()]
58         public override bool VerifySignature (HashAlgorithm hash, byte[] rgbSignature) 
59         {
60                 if ((hash == null) || (rgbSignature == null))
61                         throw new ArgumentNullException ();
62                 if ((rsa == null) || (hash == null))
63                         throw new CryptographicUnexpectedOperationException ();
64                 // TODO
65                 return false;
66         }
67 }
68
69 }