206 lines
6.0 KiB
C#
206 lines
6.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509
|
|
{
|
|
// Token: 0x02001904 RID: 6404
|
|
[Token(Token = "0x2001904")]
|
|
public class X509CertificateParser
|
|
{
|
|
// Token: 0x060096D7 RID: 38615 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x60096D7")]
|
|
[Address(RVA = "0x162B2F0", Offset = "0x162A0F0", VA = "0x18162B2F0")]
|
|
private X509Certificate ReadDerCertificate(Asn1InputStream dIn)
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x060096D8 RID: 38616 RVA: 0x001F0DBC File Offset: 0x001EEFBC
|
|
[Token(Token = "0x60096D8")]
|
|
[Address(RVA = "0x162AC10", Offset = "0x1629A10", VA = "0x18162AC10")]
|
|
private X509Certificate GetCertificate()
|
|
{
|
|
if (this.sData != (ulong)0L)
|
|
{
|
|
Asn1Set asn1Set = this.sData;
|
|
Asn1Encodable asn1Encodable;
|
|
if (this.sDataObjectCount < asn1Encodable)
|
|
{
|
|
int num = this.sDataObjectCount;
|
|
Asn1Set asn1Set2 = this.sData;
|
|
int num2 = num + 1;
|
|
this.sDataObjectCount = num2;
|
|
IEnumerator enumerator = asn1Set2.GetEnumerator();
|
|
while (enumerator == 0)
|
|
{
|
|
}
|
|
while (enumerator == 0)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060096D9 RID: 38617 RVA: 0x001F0E1C File Offset: 0x001EF01C
|
|
[Token(Token = "0x60096D9")]
|
|
[Address(RVA = "0x162B510", Offset = "0x162A310", VA = "0x18162B510")]
|
|
private X509Certificate ReadPemCertificate(Stream inStream)
|
|
{
|
|
Asn1Sequence asn1Sequence = X509CertificateParser.PemCertParser.ReadPemObject(inStream);
|
|
if (asn1Sequence == 0)
|
|
{
|
|
}
|
|
X509CertificateStructure instance = X509CertificateStructure.GetInstance(asn1Sequence);
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060096DA RID: 38618 RVA: 0x001F0E48 File Offset: 0x001EF048
|
|
[Token(Token = "0x60096DA")]
|
|
[Address(RVA = "0x162ABB0", Offset = "0x16299B0", VA = "0x18162ABB0", Slot = "4")]
|
|
protected virtual X509Certificate CreateX509Certificate(X509CertificateStructure c)
|
|
{
|
|
return new X509Certificate(c);
|
|
}
|
|
|
|
// Token: 0x060096DB RID: 38619 RVA: 0x001F0E5C File Offset: 0x001EF05C
|
|
[Token(Token = "0x60096DB")]
|
|
[Address(RVA = "0x162AD30", Offset = "0x1629B30", VA = "0x18162AD30")]
|
|
public X509Certificate ReadCertificate(byte[] input)
|
|
{
|
|
int num;
|
|
MemoryStream memoryStream = new MemoryStream(input, num != 0);
|
|
num = 0;
|
|
return this.ReadCertificate(memoryStream);
|
|
}
|
|
|
|
// Token: 0x060096DC RID: 38620 RVA: 0x001F0E7C File Offset: 0x001EF07C
|
|
[Token(Token = "0x60096DC")]
|
|
[Address(RVA = "0x162B040", Offset = "0x1629E40", VA = "0x18162B040")]
|
|
public ICollection ReadCertificates(byte[] input)
|
|
{
|
|
MemoryStream memoryStream;
|
|
do
|
|
{
|
|
int num;
|
|
memoryStream = new MemoryStream(input, num != 0);
|
|
num = 0;
|
|
IList list = Platform.CreateArrayList();
|
|
int num2 = 0;
|
|
if (this.ReadCertificate(memoryStream) == 0)
|
|
{
|
|
break;
|
|
}
|
|
int num3 = 0;
|
|
if (num3 < num2)
|
|
{
|
|
num3 += num3;
|
|
num3++;
|
|
}
|
|
}
|
|
while (this.ReadCertificate(memoryStream) != 0);
|
|
memoryStream += memoryStream;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060096DD RID: 38621 RVA: 0x001F0ED4 File Offset: 0x001EF0D4
|
|
[Token(Token = "0x60096DD")]
|
|
[Address(RVA = "0x162ADA0", Offset = "0x1629BA0", VA = "0x18162ADA0")]
|
|
public X509Certificate ReadCertificate(Stream inStream)
|
|
{
|
|
if (inStream != 0)
|
|
{
|
|
inStream.Dispose();
|
|
Stream stream = this.currentStream;
|
|
int num = 0;
|
|
if (stream == 0 || stream != inStream)
|
|
{
|
|
this.sDataObjectCount = num;
|
|
this.sData = num;
|
|
this.currentStream = inStream;
|
|
}
|
|
string text;
|
|
if (this.sData == 0)
|
|
{
|
|
PushbackStream pushbackStream = new PushbackStream(inStream);
|
|
int num2;
|
|
pushbackStream.WriteByte((byte)num2);
|
|
if (num2 == 48)
|
|
{
|
|
Asn1InputStream asn1InputStream = new Asn1InputStream(pushbackStream);
|
|
X509Certificate x509Certificate = this.ReadDerCertificate(asn1InputStream);
|
|
}
|
|
Asn1Sequence asn1Sequence = X509CertificateParser.PemCertParser.ReadPemObject(pushbackStream);
|
|
if (asn1Sequence != 0)
|
|
{
|
|
X509CertificateStructure instance = X509CertificateStructure.GetInstance(asn1Sequence);
|
|
text = this.ToString();
|
|
}
|
|
}
|
|
int num3 = this.sDataObjectCount;
|
|
this.sData = text;
|
|
this.sDataObjectCount = text;
|
|
return this.GetCertificate();
|
|
}
|
|
ArgumentNullException ex = new ArgumentNullException("inStream");
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060096DE RID: 38622 RVA: 0x001F0FC0 File Offset: 0x001EF1C0
|
|
[Token(Token = "0x60096DE")]
|
|
[Address(RVA = "0x162B1B0", Offset = "0x1629FB0", VA = "0x18162B1B0")]
|
|
public ICollection ReadCertificates(Stream inStream)
|
|
{
|
|
do
|
|
{
|
|
IList list = Platform.CreateArrayList();
|
|
int num = 0;
|
|
if (this.ReadCertificate(inStream) == 0)
|
|
{
|
|
break;
|
|
}
|
|
int num2 = 0;
|
|
if (num2 < num)
|
|
{
|
|
num2 += num2;
|
|
num2++;
|
|
}
|
|
}
|
|
while (this.ReadCertificate(inStream) != 0);
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x060096DF RID: 38623 RVA: 0x001F1000 File Offset: 0x001EF200
|
|
[Token(Token = "0x60096DF")]
|
|
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
|
|
public X509CertificateParser()
|
|
{
|
|
}
|
|
|
|
// Token: 0x04006689 RID: 26249
|
|
[Token(Token = "0x4006689")]
|
|
private static readonly PemParser PemCertParser = new PemParser("CERTIFICATE");
|
|
|
|
// Token: 0x0400668A RID: 26250
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400668A")]
|
|
private Asn1Set sData;
|
|
|
|
// Token: 0x0400668B RID: 26251
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400668B")]
|
|
private int sDataObjectCount;
|
|
|
|
// Token: 0x0400668C RID: 26252
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x400668C")]
|
|
private Stream currentStream;
|
|
}
|
|
}
|