Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SpecifiedECDomain.cs
Go to the documentation of this file.
2
4
5internal struct SpecifiedECDomain
6{
7 internal int Version;
8
10
12
14
16
18
19 internal string Hash;
20
21 internal void Encode(AsnWriter writer)
22 {
24 }
25
26 internal void Encode(AsnWriter writer, Asn1Tag tag)
27 {
28 writer.PushSequence(tag);
29 writer.WriteInteger((long)Version, (Asn1Tag?)null);
32 writer.WriteOctetString(Base.Span);
33 writer.WriteInteger(Order.Span);
34 if (Cofactor.HasValue)
35 {
36 writer.WriteInteger(Cofactor.Value.Span);
37 }
38 if (Hash != null)
39 {
40 try
41 {
42 writer.WriteObjectIdentifier(Hash);
43 }
44 catch (ArgumentException inner)
45 {
47 }
48 }
49 writer.PopSequence(tag);
50 }
51
53 {
54 Decode(ref reader, Asn1Tag.Sequence, rebind, out decoded);
55 }
56
57 internal static void Decode(ref System.Formats.Asn1.AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory<byte> rebind, out System.Security.Cryptography.Asn1.SpecifiedECDomain decoded)
58 {
59 try
60 {
61 DecodeCore(ref reader, expectedTag, rebind, out decoded);
62 }
63 catch (AsnContentException inner)
64 {
66 }
67 }
68
70 {
72 System.Formats.Asn1.AsnValueReader reader2 = reader.ReadSequence(expectedTag);
73 ReadOnlySpan<byte> span = rebind.Span;
74 if (!reader2.TryReadInt32(out decoded.Version))
75 {
76 reader2.ThrowIfNotEmpty();
77 }
78 System.Security.Cryptography.Asn1.FieldID.Decode(ref reader2, rebind, out decoded.FieldID);
79 System.Security.Cryptography.Asn1.CurveAsn.Decode(ref reader2, rebind, out decoded.Curve);
80 int elementOffset;
81 if (reader2.TryReadPrimitiveOctetString(out var value))
82 {
83 decoded.Base = (span.Overlaps(value, out elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
84 }
85 else
86 {
87 decoded.Base = reader2.ReadOctetString();
88 }
89 value = reader2.ReadIntegerBytes();
90 decoded.Order = (span.Overlaps(value, out elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
91 if (reader2.HasData && reader2.PeekTag().HasSameClassAndValue(Asn1Tag.Integer))
92 {
93 value = reader2.ReadIntegerBytes();
94 decoded.Cofactor = (span.Overlaps(value, out elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
95 }
97 {
98 decoded.Hash = reader2.ReadObjectIdentifier();
99 }
100 reader2.ThrowIfNotEmpty();
101 }
102}
static string Cryptography_Der_Invalid_Encoding
Definition SR.cs:50
Definition SR.cs:7
static readonly Asn1Tag Integer
Definition Asn1Tag.cs:13
static readonly Asn1Tag Sequence
Definition Asn1Tag.cs:29
static readonly Asn1Tag ObjectIdentifier
Definition Asn1Tag.cs:25
bool HasSameClassAndValue(Asn1Tag other)
Definition Asn1Tag.cs:251
ReadOnlySpan< byte > ReadIntegerBytes(Asn1Tag? expectedTag=null)
string ReadObjectIdentifier(Asn1Tag? expectedTag=null)
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 Decode(ref AsnValueReader reader, ReadOnlyMemory< byte > rebind, out CurveAsn decoded)
Definition CurveAsn.cs:30
static void Decode(ref AsnValueReader reader, ReadOnlyMemory< byte > rebind, out FieldID decoded)
Definition FieldID.cs:38
System.Security.Cryptography.Asn1.FieldID FieldID
static void Decode(ref AsnValueReader reader, ReadOnlyMemory< byte > rebind, out SpecifiedECDomain decoded)
static void DecodeCore(ref System.Formats.Asn1.AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out System.Security.Cryptography.Asn1.SpecifiedECDomain decoded)
static void DecodeCore(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out SpecifiedECDomain decoded)
System.Security.Cryptography.Asn1.CurveAsn Curve
static void Decode(ref System.Formats.Asn1.AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out System.Security.Cryptography.Asn1.SpecifiedECDomain decoded)
static void Decode(ref System.Formats.Asn1.AsnValueReader reader, ReadOnlyMemory< byte > rebind, out System.Security.Cryptography.Asn1.SpecifiedECDomain decoded)