PKCS1MaskGenerationMethod.cs 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // PKCS1MaskGenerationMethod.cs: Handles PKCS#1 mask generation.
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. using System;
  10. using System.Security.Cryptography;
  11. namespace System.Security.Cryptography {
  12. // References:
  13. // a. PKCS#1: RSA Cryptography Standard
  14. // http://www.rsasecurity.com/rsalabs/pkcs/pkcs-1/index.html
  15. public class PKCS1MaskGenerationMethod : MaskGenerationMethod {
  16. private string hashName;
  17. public PKCS1MaskGenerationMethod()
  18. {
  19. hashName = "SHA1";
  20. }
  21. public string HashName
  22. {
  23. get { return hashName; }
  24. set {
  25. if (value == null)
  26. hashName = "SHA1";
  27. else
  28. hashName = value;
  29. }
  30. }
  31. public override byte[] GenerateMask (byte[] mgfSeed, int maskLen)
  32. {
  33. HashAlgorithm hash = HashAlgorithm.Create (hashName);
  34. return PKCS1.MGF1 (hash, mgfSeed, maskLen);
  35. }
  36. }
  37. }