Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ DecodeCore() [2/2]

static void System.Security.Cryptography.Asn1.ECPrivateKey.DecodeCore ( ref System::Formats::Asn1::AsnValueReader reader,
Asn1Tag expectedTag,
ReadOnlyMemory< byte > rebind,
out System::Security::Cryptography::Asn1::ECPrivateKey decoded )
inlinestaticprivate

Definition at line 35 of file ECPrivateKey.cs.

36 {
37 decoded = default(System.Security.Cryptography.Asn1.ECPrivateKey);
38 System.Formats.Asn1.AsnValueReader asnValueReader = reader.ReadSequence(expectedTag);
39 ReadOnlySpan<byte> span = rebind.Span;
40 if (!asnValueReader.TryReadInt32(out decoded.Version))
41 {
42 asnValueReader.ThrowIfNotEmpty();
43 }
44 int elementOffset;
45 if (asnValueReader.TryReadPrimitiveOctetString(out var value))
46 {
47 decoded.PrivateKey = (span.Overlaps(value, out elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
48 }
49 else
50 {
51 decoded.PrivateKey = asnValueReader.ReadOctetString();
52 }
54 if (asnValueReader.HasData && asnValueReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 0)))
55 {
56 reader2 = asnValueReader.ReadSequence(new Asn1Tag(TagClass.ContextSpecific, 0));
57 System.Security.Cryptography.Asn1.ECDomainParameters.Decode(ref reader2, rebind, out var decoded2);
58 decoded.Parameters = decoded2;
59 reader2.ThrowIfNotEmpty();
60 }
61 if (asnValueReader.HasData && asnValueReader.PeekTag().HasSameClassAndValue(new Asn1Tag(TagClass.ContextSpecific, 1)))
62 {
63 reader2 = asnValueReader.ReadSequence(new Asn1Tag(TagClass.ContextSpecific, 1));
64 if (reader2.TryReadPrimitiveBitString(out var unusedBitCount, out value))
65 {
66 decoded.PublicKey = (span.Overlaps(value, out elementOffset) ? rebind.Slice(elementOffset, value.Length) : ((ReadOnlyMemory<byte>)value.ToArray()));
67 }
68 else
69 {
70 decoded.PublicKey = reader2.ReadBitString(out unusedBitCount);
71 }
72 reader2.ThrowIfNotEmpty();
73 }
74 asnValueReader.ThrowIfNotEmpty();
75 }
bool HasSameClassAndValue(Asn1Tag other)
Definition Asn1Tag.cs:251
bool TryReadInt32(out int value, Asn1Tag? expectedTag=null)
bool TryReadPrimitiveOctetString(out ReadOnlySpan< byte > value, Asn1Tag? expectedTag=null)
byte[] ReadOctetString(Asn1Tag? expectedTag=null)
byte[] ReadBitString(out int unusedBitCount, Asn1Tag? expectedTag=null)
AsnValueReader ReadSequence(Asn1Tag? expectedTag=null)
unsafe ReadOnlySpan< T > Span
ReadOnlyMemory< T > Slice(int start)
static ECDomainParameters Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)

References System.Security.Cryptography.Asn1.ECDomainParameters.Decode(), System.Formats.Asn1.AsnValueReader.HasData, System.Formats.Asn1.Asn1Tag.HasSameClassAndValue(), System.Formats.Asn1.AsnValueReader.PeekTag(), System.Formats.Asn1.AsnValueReader.ReadBitString(), System.Formats.Asn1.AsnValueReader.ReadOctetString(), System.Formats.Asn1.AsnValueReader.ReadSequence(), System.ReadOnlyMemory< T >.Slice(), System.ReadOnlyMemory< T >.Span, System.Formats.Asn1.AsnValueReader.ThrowIfNotEmpty(), System.Formats.Asn1.AsnValueReader.TryReadInt32(), System.Formats.Asn1.AsnValueReader.TryReadPrimitiveBitString(), System.Formats.Asn1.AsnValueReader.TryReadPrimitiveOctetString(), and System.value.