Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RSAPrivateKeyAsn.cs
Go to the documentation of this file.
3
5
6internal struct RSAPrivateKeyAsn
7{
8 internal int Version;
9
11
13
15
17
19
21
23
25
27 {
28 return Decode(Asn1Tag.Sequence, encoded, ruleSet);
29 }
30
31 internal static RSAPrivateKeyAsn Decode(Asn1Tag expectedTag, ReadOnlyMemory<byte> encoded, AsnEncodingRules ruleSet)
32 {
33 try
34 {
35 AsnValueReader reader = new AsnValueReader(encoded.Span, ruleSet);
36 DecodeCore(ref reader, expectedTag, encoded, out var decoded);
37 reader.ThrowIfNotEmpty();
38 return decoded;
39 }
40 catch (AsnContentException inner)
41 {
43 }
44 }
45
46 private static void DecodeCore(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory<byte> rebind, out RSAPrivateKeyAsn decoded)
47 {
48 decoded = default(RSAPrivateKeyAsn);
49 AsnValueReader asnValueReader = reader.ReadSequence(expectedTag);
50 if (!asnValueReader.TryReadInt32(out decoded.Version))
51 {
52 asnValueReader.ThrowIfNotEmpty();
53 }
54 decoded.Modulus = asnValueReader.ReadInteger();
55 decoded.PublicExponent = asnValueReader.ReadInteger();
56 decoded.PrivateExponent = asnValueReader.ReadInteger();
57 decoded.Prime1 = asnValueReader.ReadInteger();
58 decoded.Prime2 = asnValueReader.ReadInteger();
59 decoded.Exponent1 = asnValueReader.ReadInteger();
60 decoded.Exponent2 = asnValueReader.ReadInteger();
61 decoded.Coefficient = asnValueReader.ReadInteger();
62 asnValueReader.ThrowIfNotEmpty();
63 }
64}
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)
BigInteger ReadInteger(Asn1Tag? expectedTag=null)
AsnValueReader ReadSequence(Asn1Tag? expectedTag=null)
unsafe ReadOnlySpan< T > Span
static void DecodeCore(ref AsnValueReader reader, Asn1Tag expectedTag, ReadOnlyMemory< byte > rebind, out RSAPrivateKeyAsn decoded)
static RSAPrivateKeyAsn Decode(Asn1Tag expectedTag, ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)
static RSAPrivateKeyAsn Decode(ReadOnlyMemory< byte > encoded, AsnEncodingRules ruleSet)