2004-05-06 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / RC2.cs
1 //
2 // System.Security.Cryptography.RC2.cs
3 //
4 // Authors: 
5 //      Andrew Birkett (andy@nobugs.org)
6 //      Sebastien Pouliot (sebastien@ximian.com)
7 //
8 // (C) 2004 Novell (http://www.novell.com)
9 //          
10
11 using System;
12
13 namespace System.Security.Cryptography {
14
15         // References:
16         // a.   IETF RFC2286: A Description of the RC2(r) Encryption Algorithm
17         //      http://www.ietf.org/rfc/rfc2268.txt
18
19         public abstract class RC2 : SymmetricAlgorithm {
20
21                 public static new RC2 Create () 
22                 {
23                         return Create ("System.Security.Cryptography.RC2");
24                 }
25                 
26                 public static new RC2 Create (string algName) 
27                 {
28                         return (RC2) CryptoConfig.CreateFromName (algName);
29                 }
30
31                 protected int EffectiveKeySizeValue;
32
33                 public virtual int EffectiveKeySize {
34                         get {
35                                 if (EffectiveKeySizeValue == 0)
36                                         return KeySizeValue;
37                                 else
38                                         return EffectiveKeySizeValue;
39                         }
40                         set {
41                                 EffectiveKeySizeValue = value; 
42                         }
43                 }
44
45                 public override int KeySize {
46                         get { return base.KeySize; }
47                         set {
48                                 base.KeySize = value;
49                                 EffectiveKeySizeValue = value;
50                         }
51                 }
52                                 
53                 public RC2 () 
54                 {
55                         KeySizeValue = 128;
56                         BlockSizeValue = 64;
57                         FeedbackSizeValue = 64;
58
59                         // The RFC allows keys of 1 to 128 bytes, but MS impl only supports
60                         // 40 to 128 bits, sigh.
61                         LegalKeySizesValue = new KeySizes [1];
62                         LegalKeySizesValue [0] = new KeySizes (40, 128, 8);
63
64                         LegalBlockSizesValue = new KeySizes [1];
65                         LegalBlockSizesValue [0] = new KeySizes (64, 64, 0);
66                 }
67         }
68 }