2 // RSAPKCS1SignatureDeformatter.cs - Handles PKCS#1 v.1.5 signature decryption.
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
12 namespace System.Security.Cryptography {
14 public class RSAPKCS1SignatureDeformatter : AsymmetricSignatureDeformatter {
17 private HashAlgorithm hash;
19 public RSAPKCS1SignatureDeformatter ()
24 public RSAPKCS1SignatureDeformatter (AsymmetricAlgorithm key)
29 public override void SetHashAlgorithm (string strName)
31 hash = HashAlgorithm.Create (strName);
34 public override void SetKey (AsymmetricAlgorithm key)
41 throw new InvalidCastException ();
43 // here null is accepted!
46 public override bool VerifySignature (byte[] rgbHash, byte[] rgbSignature)
48 if ((rsa == null) || (hash == null))
49 throw new CryptographicUnexpectedOperationException ();
50 if ((rgbHash == null) || (rgbSignature == null))
51 throw new ArgumentNullException ();
53 string oid = CryptoConfig.MapNameToOID (hash.ToString ());
54 return PKCS1.Verify_v15 (rsa, oid, rgbHash, rgbSignature);
57 public override bool VerifySignature (HashAlgorithm hash, byte[] rgbSignature)
60 throw new ArgumentNullException ();
62 return VerifySignature (hash.Hash, rgbSignature);