Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TimeAsn.cs
Go to the documentation of this file.
2
4
5internal struct TimeAsn
6{
8
10
11 internal void Encode(AsnWriter writer)
12 {
13 bool flag = false;
14 if (UtcTime.HasValue)
15 {
16 if (flag)
17 {
18 throw new CryptographicException();
19 }
20 writer.WriteUtcTime(UtcTime.Value);
21 flag = true;
22 }
23 if (GeneralTime.HasValue)
24 {
25 if (flag)
26 {
27 throw new CryptographicException();
28 }
29 writer.WriteGeneralizedTime(GeneralTime.Value, omitFractionalSeconds: true);
30 flag = true;
31 }
32 if (!flag)
33 {
34 throw new CryptographicException();
35 }
36 }
37
38 internal static void Decode(ref System.Formats.Asn1.AsnValueReader reader, ReadOnlyMemory<byte> rebind, out TimeAsn decoded)
39 {
40 try
41 {
42 DecodeCore(ref reader, rebind, out decoded);
43 }
44 catch (AsnContentException inner)
45 {
47 }
48 }
49
50 private static void DecodeCore(ref System.Formats.Asn1.AsnValueReader reader, ReadOnlyMemory<byte> rebind, out TimeAsn decoded)
51 {
52 decoded = default(TimeAsn);
53 Asn1Tag asn1Tag = reader.PeekTag();
55 {
56 decoded.UtcTime = reader.ReadUtcTime();
57 return;
58 }
60 {
61 decoded.GeneralTime = reader.ReadGeneralizedTime();
62 if (decoded.GeneralTime.Value.Ticks % 10000000 == 0L)
63 {
64 return;
65 }
67 }
68 throw new CryptographicException();
69 }
70
71 public TimeAsn(DateTimeOffset dateTimeOffset)
72 {
73 DateTime utcDateTime = dateTimeOffset.UtcDateTime;
74 if (utcDateTime.Year >= 1950 && utcDateTime.Year < 2050)
75 {
76 UtcTime = utcDateTime;
77 GeneralTime = null;
78 }
79 else
80 {
81 UtcTime = null;
82 GeneralTime = utcDateTime;
83 }
84 }
85}
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static readonly Asn1Tag UtcTime
Definition Asn1Tag.cs:33
static readonly Asn1Tag GeneralizedTime
Definition Asn1Tag.cs:35
bool HasSameClassAndValue(Asn1Tag other)
Definition Asn1Tag.cs:251
static void DecodeCore(ref System.Formats.Asn1.AsnValueReader reader, ReadOnlyMemory< byte > rebind, out TimeAsn decoded)
Definition TimeAsn.cs:50
static void Decode(ref System.Formats.Asn1.AsnValueReader reader, ReadOnlyMemory< byte > rebind, out TimeAsn decoded)
Definition TimeAsn.cs:38