Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DES.cs
Go to the documentation of this file.
6
8
9[UnsupportedOSPlatform("browser")]
10[EditorBrowsable(EditorBrowsableState.Never)]
11public abstract class DES : SymmetricAlgorithm
12{
13 private static readonly KeySizes[] s_legalBlockSizes = new KeySizes[1]
14 {
15 new KeySizes(64, 64, 0)
16 };
17
18 private static readonly KeySizes[] s_legalKeySizes = new KeySizes[1]
19 {
20 new KeySizes(64, 64, 0)
21 };
22
23 public override byte[] Key
24 {
25 get
26 {
27 byte[] key = base.Key;
28 while (IsWeakKey(key) || IsSemiWeakKey(key))
29 {
31 key = base.Key;
32 }
33 return key;
34 }
35 set
36 {
37 if (value == null)
38 {
39 throw new ArgumentNullException("value");
40 }
41 if (!(value.Length * 8).IsLegalSize(s_legalKeySizes))
42 {
44 }
45 if (IsWeakKey(value))
46 {
48 }
50 {
52 }
53 base.Key = value;
54 }
55 }
56
57 protected DES()
58 {
59 LegalBlockSizesValue = s_legalBlockSizes.CloneKeySizesArray();
60 LegalKeySizesValue = s_legalKeySizes.CloneKeySizesArray();
61 KeySizeValue = 64;
62 BlockSizeValue = 64;
64 }
65
66 public new static DES Create()
67 {
68 return new DesImplementation();
69 }
70
71 [RequiresUnreferencedCode("The default algorithm implementations might be removed, use strong type references like 'RSA.Create()' instead.")]
72 public new static DES? Create(string algName)
73 {
74 return (DES)CryptoConfig.CreateFromName(algName);
75 }
76
77 public static bool IsWeakKey(byte[] rgbKey)
78 {
79 if (!IsLegalKeySize(rgbKey))
80 {
82 }
83 byte[] array = rgbKey.FixupKeyParity();
85 if (num == 72340172838076673L || num == 18374403900871474942uL || num == 2242545357694045710L || num == 16204198716015505905uL)
86 {
87 return true;
88 }
89 return false;
90 }
91
92 public static bool IsSemiWeakKey(byte[] rgbKey)
93 {
94 if (!IsLegalKeySize(rgbKey))
95 {
97 }
98 byte[] array = rgbKey.FixupKeyParity();
100 if (num == 143554428589179390L || num == 18303189645120372225uL || num == 2296870857142767345L || num == 16149873216566784270uL || num == 135110050437988849L || num == 16141428838415593729uL || num == 2305315235293957886L || num == 18311634023271562766uL || num == 80784550989267214L || num == 2234100979542855169L || num == 16212643094166696446uL || num == 18365959522720284401uL)
101 {
102 return true;
103 }
104 return false;
105 }
106
107 private static bool IsLegalKeySize(byte[] rgbKey)
108 {
109 if (rgbKey != null && rgbKey.Length == 8)
110 {
111 return true;
112 }
113 return false;
114 }
115}
static ulong ReadUInt64BigEndian(ReadOnlySpan< byte > source)
static string Cryptography_InvalidKey_SemiWeak
Definition SR.cs:94
static string Cryptography_InvalidKey_Weak
Definition SR.cs:96
static string Cryptography_InvalidKeySize
Definition SR.cs:92
Definition SR.cs:7
static ? object CreateFromName(string name, params object?[]? args)
static new DES Create()
Definition DES.cs:66
static bool IsLegalKeySize(byte[] rgbKey)
Definition DES.cs:107
override byte[] Key
Definition DES.cs:24
static readonly KeySizes[] s_legalBlockSizes
Definition DES.cs:13
static readonly KeySizes[] s_legalKeySizes
Definition DES.cs:18
static bool IsWeakKey(byte[] rgbKey)
Definition DES.cs:77
static new? DES Create(string algName)
Definition DES.cs:72
static bool IsSemiWeakKey(byte[] rgbKey)
Definition DES.cs:92