AsymmetricSignatureFormatter.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // System.Security.Cryptography AsymmetricSignatureFormatter Class implementation
  3. //
  4. // Authors:
  5. // Thomas Neidhart ([email protected])
  6. //
  7. using System;
  8. using System.Security;
  9. namespace System.Security.Cryptography {
  10. /// <summary>
  11. /// Abstract base class for all asymmetric signature formatter.
  12. /// Available derived classes:
  13. /// DSASignatureFormatter, RSAPKCS1SignatureFormatter
  14. /// </summary>
  15. public abstract class AsymmetricSignatureFormatter {
  16. /// <summary>
  17. /// constructor, no idea why it is here (abstract class) :-)
  18. /// just for compatibility with MS
  19. /// </summary>
  20. public AsymmetricSignatureFormatter()
  21. {
  22. }
  23. /// <summary>
  24. /// Sets the hash algorithm used for verifying a signature
  25. /// </summary>
  26. public abstract void SetHashAlgorithm(string strName);
  27. /// <summary>
  28. /// set the private key
  29. /// </summary>
  30. public abstract void SetKey(AsymmetricAlgorithm key);
  31. /// <summary>
  32. /// Create a signature from the given data
  33. /// </summary>
  34. public abstract byte[] CreateSignature(byte[] rgbHash);
  35. /// <summary>
  36. /// Create a signature from data with the specified hash algorithm
  37. /// </summary>
  38. public virtual byte[] CreateSignature(HashAlgorithm hash)
  39. {
  40. if (hash == null)
  41. throw new ArgumentNullException ("hash");
  42. return CreateSignature (hash.Hash);
  43. }
  44. } // AsymmetricSignatureFormatter
  45. } // System.Security.Cryptography