Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GeneralNameAsn.cs
Go to the documentation of this file.
2
4
5internal struct GeneralNameAsn
6{
8
9 internal string Rfc822Name;
10
11 internal string DnsName;
12
14
16
18
19 internal string Uri;
20
22
23 internal string RegisteredId;
24
25 internal void Encode(AsnWriter writer)
26 {
27 bool flag = false;
28 if (OtherName.HasValue)
29 {
30 if (flag)
31 {
32 throw new CryptographicException();
33 }
34 OtherName.Value.Encode(writer, new Asn1Tag(TagClass.ContextSpecific, 0));
35 flag = true;
36 }
37 if (Rfc822Name != null)
38 {
39 if (flag)
40 {
41 throw new CryptographicException();
42 }
43 writer.WriteCharacterString(UniversalTagNumber.IA5String, Rfc822Name, new Asn1Tag(TagClass.ContextSpecific, 1));
44 flag = true;
45 }
46 if (DnsName != null)
47 {
48 if (flag)
49 {
50 throw new CryptographicException();
51 }
52 writer.WriteCharacterString(UniversalTagNumber.IA5String, DnsName, new Asn1Tag(TagClass.ContextSpecific, 2));
53 flag = true;
54 }
55 if (X400Address.HasValue)
56 {
57 if (flag)
58 {
59 throw new CryptographicException();
60 }
61 if (!Asn1Tag.TryDecode(X400Address.Value.Span, out var tag, out var _) || !tag.HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 3)))
62 {
63 throw new CryptographicException();
64 }
65 try
66 {
67 writer.WriteEncodedValue(X400Address.Value.Span);
68 }
69 catch (ArgumentException inner)
70 {
72 }
73 flag = true;
74 }
75 if (DirectoryName.HasValue)
76 {
77 if (flag)
78 {
79 throw new CryptographicException();
80 }
81 writer.PushSequence(new Asn1Tag(TagClass.ContextSpecific, 4));
82 try
83 {
84 writer.WriteEncodedValue(DirectoryName.Value.Span);
85 }
86 catch (ArgumentException inner2)
87 {
89 }
90 writer.PopSequence(new Asn1Tag(TagClass.ContextSpecific, 4));
91 flag = true;
92 }
93 if (EdiPartyName.HasValue)
94 {
95 if (flag)
96 {
97 throw new CryptographicException();
98 }
99 EdiPartyName.Value.Encode(writer, new Asn1Tag(TagClass.ContextSpecific, 5));
100 flag = true;
101 }
102 if (Uri != null)
103 {
104 if (flag)
105 {
106 throw new CryptographicException();
107 }
108 writer.WriteCharacterString(UniversalTagNumber.IA5String, Uri, new Asn1Tag(TagClass.ContextSpecific, 6));
109 flag = true;
110 }
111 if (IPAddress.HasValue)
112 {
113 if (flag)
114 {
115 throw new CryptographicException();
116 }
117 writer.WriteOctetString(IPAddress.Value.Span, new Asn1Tag(TagClass.ContextSpecific, 7));
118 flag = true;
119 }
120 if (RegisteredId != null)
121 {
122 if (flag)
123 {
124 throw new CryptographicException();
125 }
126 try
127 {
128 writer.WriteObjectIdentifier(RegisteredId, new Asn1Tag(TagClass.ContextSpecific, 8));
129 }
130 catch (ArgumentException inner3)
131 {
133 }
134 flag = true;
135 }
136 if (!flag)
137 {
138 throw new CryptographicException();
139 }
140 }
141}
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static bool TryDecode(ReadOnlySpan< byte > source, out Asn1Tag tag, out int bytesConsumed)
Definition Asn1Tag.cs:87
unsafe ReadOnlySpan< T > Span
void Encode(AsnWriter writer, Asn1Tag tag)