Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RC2CryptoServiceProvider.cs
Go to the documentation of this file.
4
6
7[Obsolete("Derived cryptographic types are obsolete. Use the Create method on the base type instead.", DiagnosticId = "SYSLIB0021", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
8[EditorBrowsable(EditorBrowsableState.Never)]
9public sealed class RC2CryptoServiceProvider : RC2
10{
11 private bool _use40bitSalt;
12
13 private static readonly KeySizes[] s_legalKeySizes = new KeySizes[1]
14 {
15 new KeySizes(40, 128, 8)
16 };
17
18 public override int EffectiveKeySize
19 {
20 get
21 {
22 return KeySizeValue;
23 }
24 set
25 {
26 if (value != KeySizeValue)
27 {
29 }
30 }
31 }
32
33 public bool UseSalt
34 {
35 get
36 {
37 return _use40bitSalt;
38 }
39 [SupportedOSPlatform("windows")]
40 set
41 {
43 }
44 }
45
47 {
48 LegalKeySizesValue = s_legalKeySizes.CloneKeySizesArray();
50 }
51
52 public override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
53 {
54 return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: true);
55 }
56
57 public override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)
58 {
59 return CreateTransform(rgbKey, rgbIV?.CloneByteArray(), encrypting: false);
60 }
61
62 public override void GenerateKey()
63 {
65 }
66
67 public override void GenerateIV()
68 {
70 }
71
72 private ICryptoTransform CreateTransform(byte[] rgbKey, byte[] rgbIV, bool encrypting)
73 {
74 long num = (long)rgbKey.Length * 8L;
75 if (num > int.MaxValue || !((int)num).IsLegalSize(LegalKeySizes))
76 {
78 }
79 if (rgbIV == null)
80 {
81 if (Mode.UsesIv())
82 {
84 }
85 }
86 else if (rgbIV.Length < 8)
87 {
89 }
90 int effectiveKeyLength = (int)((EffectiveKeySizeValue == 0) ? num : EffectiveKeySize);
91 Internal.Cryptography.BasicSymmetricCipher cipher = new BasicSymmetricCipherCsp(26114, Mode, BlockSize / 8, rgbKey, effectiveKeyLength, !UseSalt, rgbIV, encrypting, 0, 0);
93 }
94}
static UniversalCryptoTransform Create(PaddingMode paddingMode, BasicSymmetricCipher cipher, bool encrypting)
static string Cryptography_RC2_EKSKS2
Definition SR.cs:134
static string Cryptography_InvalidKeySize
Definition SR.cs:92
static string Cryptography_InvalidIVSize
Definition SR.cs:102
Definition SR.cs:7
override ICryptoTransform CreateEncryptor(byte[] rgbKey, byte[]? rgbIV)
ICryptoTransform CreateTransform(byte[] rgbKey, byte[] rgbIV, bool encrypting)
override ICryptoTransform CreateDecryptor(byte[] rgbKey, byte[]? rgbIV)