Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Rc2CbcParameters.cs
Go to the documentation of this file.
2
4
5internal struct Rc2CbcParameters
6{
7 internal int Rc2Version;
8
10
11 private static readonly byte[] s_rc2EkbEncoding = new byte[256]
12 {
13 189, 86, 234, 242, 162, 241, 172, 42, 176, 147,
14 209, 156, 27, 51, 253, 208, 48, 4, 182, 220,
15 125, 223, 50, 75, 247, 203, 69, 155, 49, 187,
16 33, 90, 65, 159, 225, 217, 74, 77, 158, 218,
17 160, 104, 44, 195, 39, 95, 128, 54, 62, 238,
18 251, 149, 26, 254, 206, 168, 52, 169, 19, 240,
19 166, 63, 216, 12, 120, 36, 175, 35, 82, 193,
20 103, 23, 245, 102, 144, 231, 232, 7, 184, 96,
21 72, 230, 30, 83, 243, 146, 164, 114, 140, 8,
22 21, 110, 134, 0, 132, 250, 244, 127, 138, 66,
23 25, 246, 219, 205, 20, 141, 80, 18, 186, 60,
24 6, 78, 236, 179, 53, 17, 161, 136, 142, 43,
25 148, 153, 183, 113, 116, 211, 228, 191, 58, 222,
26 150, 14, 188, 10, 237, 119, 252, 55, 107, 3,
27 121, 137, 98, 198, 215, 192, 210, 124, 106, 139,
28 34, 163, 91, 5, 93, 2, 117, 213, 97, 227,
29 24, 143, 85, 81, 173, 31, 11, 94, 133, 229,
30 194, 87, 99, 202, 61, 108, 180, 197, 204, 112,
31 178, 145, 89, 13, 71, 32, 200, 79, 88, 224,
32 1, 226, 22, 56, 196, 111, 59, 15, 101, 70,
33 190, 126, 45, 123, 130, 249, 64, 181, 29, 115,
34 248, 235, 38, 199, 135, 151, 37, 84, 177, 40,
35 170, 152, 157, 165, 100, 109, 122, 212, 16, 129,
36 68, 239, 73, 214, 174, 46, 221, 118, 92, 47,
37 167, 28, 201, 9, 105, 154, 131, 207, 41, 57,
38 185, 233, 76, 255, 67, 171
39 };
40
42 {
43 return Decode(Asn1Tag.Sequence, encoded, ruleSet);
44 }
45
47 {
48 try
49 {
51 DecodeCore(ref reader, expectedTag, encoded, out var decoded);
52 reader.ThrowIfNotEmpty();
53 return decoded;
54 }
55 catch (AsnContentException inner)
56 {
58 }
59 }
60
61 private static void DecodeCore(ref System.Formats.Asn1.AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory<byte> rebind, out System.Security.Cryptography.Asn1.Rc2CbcParameters decoded)
62 {
64 System.Formats.Asn1.AsnValueReader asnValueReader = reader.ReadSequence(expectedTag);
65 ReadOnlySpan<byte> span = rebind.Span;
66 if (!asnValueReader.TryReadInt32(out decoded.Rc2Version))
67 {
68 asnValueReader.ThrowIfNotEmpty();
69 }
70 if (asnValueReader.TryReadPrimitiveOctetString(out var value))
71 {
72 decoded.Iv = (span.Overlaps(value, out var elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
73 }
74 else
75 {
76 decoded.Iv = asnValueReader.ReadOctetString();
77 }
78 asnValueReader.ThrowIfNotEmpty();
79 }
80
81 internal int GetEffectiveKeyBits()
82 {
83 if (Rc2Version > 255)
84 {
85 return Rc2Version;
86 }
88 }
89}
int IList. IndexOf(object value)
Definition Array.cs:1228
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static readonly Asn1Tag Sequence
Definition Asn1Tag.cs:29
bool TryReadInt32(out int value, Asn1Tag? expectedTag=null)
bool TryReadPrimitiveOctetString(out ReadOnlySpan< byte > value, Asn1Tag? expectedTag=null)
byte[] ReadOctetString(Asn1Tag? expectedTag=null)
AsnValueReader ReadSequence(Asn1Tag? expectedTag=null)
unsafe ReadOnlySpan< T > Span
ReadOnlyMemory< T > Slice(int start)
static void DecodeCore(ref System.Formats.Asn1.AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out System.Security.Cryptography.Asn1.Rc2CbcParameters decoded)
static System.Security.Cryptography.Asn1.Rc2CbcParameters Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)
static void DecodeCore(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out Rc2CbcParameters decoded)
static Rc2CbcParameters Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)
static System.Security.Cryptography.Asn1.Rc2CbcParameters Decode(Asn1Tag expectedTag, ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)