RC2.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // System.Security.Cryptography.RC2.cs
  3. //
  4. // Authors: Andrew Birkett ([email protected])
  5. //
  6. using System;
  7. namespace System.Security.Cryptography {
  8. public abstract class RC2 : SymmetricAlgorithm {
  9. public static new RC2 Create ()
  10. {
  11. return Create ("System.Security.Cryptography.RC2");
  12. }
  13. public static new RC2 Create (string algName)
  14. {
  15. return (RC2) CryptoConfig.CreateFromName (algName);
  16. }
  17. protected int EffectiveKeySizeValue;
  18. public virtual int EffectiveKeySize {
  19. get {
  20. if (EffectiveKeySizeValue == 0)
  21. return KeySizeValue;
  22. else
  23. return EffectiveKeySizeValue;
  24. }
  25. set { EffectiveKeySizeValue = value; }
  26. }
  27. // Overridden, which makes me suspect it changes effective keysize too?
  28. public override int KeySize {
  29. get { return KeySizeValue; }
  30. set { KeySizeValue = value; }
  31. }
  32. public RC2 ()
  33. {
  34. KeySizeValue = 128;
  35. BlockSizeValue = 64;
  36. FeedbackSizeValue = 64;
  37. // The RFC allows keys of 1 to 128 bytes, but MS impl only supports
  38. // 40 to 128 bits, sigh.
  39. LegalKeySizesValue = new KeySizes[1];
  40. LegalKeySizesValue[0] = new KeySizes(40, 128, 8);
  41. LegalBlockSizesValue = new KeySizes[1];
  42. LegalBlockSizesValue[0] = new KeySizes(64, 64, 0);
  43. }
  44. }
  45. }