365 lines
11 KiB
C#
365 lines
11 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.OpenSsl;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security.Certificates;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
|
|
using Cpp2IlInjected;
|
|
using Pathfinding;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Pkix
|
|
{
|
|
// Token: 0x02001A57 RID: 6743
|
|
[Token(Token = "0x2001A57")]
|
|
public class PkixCertPath
|
|
{
|
|
// Token: 0x06009ED6 RID: 40662 RVA: 0x0020AFE0 File Offset: 0x002091E0
|
|
[Token(Token = "0x6009ED6")]
|
|
[Address(RVA = "0x654260", Offset = "0x653260", VA = "0x180654260")]
|
|
private static IList SortCerts(IList certs)
|
|
{
|
|
IList list2;
|
|
int num2;
|
|
for (;;)
|
|
{
|
|
int num = 0;
|
|
if ((uint)1 == (uint)num)
|
|
{
|
|
goto IL_7B;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
bool flag;
|
|
if (flag)
|
|
{
|
|
}
|
|
IList list = Platform.CreateArrayList(flag ? 1 : 0);
|
|
list2 = Platform.CreateArrayList(certs);
|
|
num2 = 0;
|
|
if (num2 >= list2)
|
|
{
|
|
goto IL_58;
|
|
}
|
|
if (list2 != 0)
|
|
{
|
|
bool flag2;
|
|
while (!flag2)
|
|
{
|
|
}
|
|
}
|
|
if (-1 != 0)
|
|
{
|
|
}
|
|
if (list2 == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (18446744073709551615UL != (ulong)(-1L))
|
|
{
|
|
}
|
|
if ((ulong)1L == 0UL)
|
|
{
|
|
}
|
|
num2++;
|
|
IL_58:
|
|
int num3 = 0;
|
|
if (0 != -1)
|
|
{
|
|
int num4 = 0;
|
|
bool flag3;
|
|
if (num4 < -1 && !flag3)
|
|
{
|
|
num4++;
|
|
}
|
|
num3++;
|
|
}
|
|
return list2;
|
|
IL_7B:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009ED7 RID: 40663 RVA: 0x0020B070 File Offset: 0x00209270
|
|
[Token(Token = "0x6009ED7")]
|
|
[Address(RVA = "0x654B90", Offset = "0x653B90", VA = "0x180654B90")]
|
|
public PkixCertPath(ICollection certificates)
|
|
{
|
|
IList list = PkixCertPath.SortCerts(Platform.CreateArrayList(certificates));
|
|
this.certificates = list;
|
|
}
|
|
|
|
// Token: 0x06009ED8 RID: 40664 RVA: 0x0020B098 File Offset: 0x00209298
|
|
[Token(Token = "0x6009ED8")]
|
|
[Address(RVA = "0x654C30", Offset = "0x653C30", VA = "0x180654C30")]
|
|
public PkixCertPath(Stream inStream)
|
|
{
|
|
}
|
|
|
|
// Token: 0x06009ED9 RID: 40665 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6009ED9")]
|
|
[Address(RVA = "0x654C80", Offset = "0x653C80", VA = "0x180654C80")]
|
|
public PkixCertPath(Stream inStream, string encoding)
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x17001972 RID: 6514
|
|
// (get) Token: 0x06009EDA RID: 40666 RVA: 0x0020B0A8 File Offset: 0x002092A8
|
|
[Token(Token = "0x17001972")]
|
|
public virtual IEnumerable Encodings
|
|
{
|
|
[Token(Token = "0x6009EDA")]
|
|
[Address(RVA = "0x655350", Offset = "0x654350", VA = "0x180655350", Slot = "4")]
|
|
get
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009EDA)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Collections.IEnumerable BestHTTP.SecureProtocol.Org.BouncyCastle.Pkix.PkixCertPath::get_Encodings()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
Block_0:
|
|
stloc:EnumerableProxy(var_0_0A, newobj:EnumerableProxy(EnumerableProxy::.ctor, ldsfld:IList[exp:IEnumerable](PkixCertPath::certPathEncodings)))
|
|
}
|
|
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1852
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 355
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
|
|
--- End of inner exception stack trace ---
|
|
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
|
|
at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1663
|
|
*/;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009EDB RID: 40667 RVA: 0x0020B0C0 File Offset: 0x002092C0
|
|
[Token(Token = "0x6009EDB")]
|
|
[Address(RVA = "0x6536A0", Offset = "0x6526A0", VA = "0x1806536A0", Slot = "0")]
|
|
public override bool Equals(object obj)
|
|
{
|
|
while (this != obj)
|
|
{
|
|
byte[] array;
|
|
if (obj != 0 && obj != 0 && array == null)
|
|
{
|
|
if (array != 0)
|
|
{
|
|
if (object.Equals(array, array))
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Token: 0x06009EDC RID: 40668 RVA: 0x0020B0F8 File Offset: 0x002092F8
|
|
[Token(Token = "0x6009EDC")]
|
|
[Address(RVA = "0x654220", Offset = "0x653220", VA = "0x180654220", Slot = "2")]
|
|
public override int GetHashCode()
|
|
{
|
|
byte[] array;
|
|
return ((IPathModifier)array).Order;
|
|
}
|
|
|
|
// Token: 0x06009EDD RID: 40669 RVA: 0x0020B114 File Offset: 0x00209314
|
|
[Token(Token = "0x6009EDD")]
|
|
[Address(RVA = "0x653860", Offset = "0x652860", VA = "0x180653860", Slot = "5")]
|
|
public virtual byte[] GetEncoded()
|
|
{
|
|
int num;
|
|
byte[] array;
|
|
do
|
|
{
|
|
num = 0;
|
|
string text = this.ToString();
|
|
if (text != 0)
|
|
{
|
|
while (text == 0)
|
|
{
|
|
}
|
|
while (text == 0)
|
|
{
|
|
}
|
|
if (text == 0)
|
|
{
|
|
goto IL_2F;
|
|
}
|
|
}
|
|
if (array != 0)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
if (num != -1)
|
|
{
|
|
return array;
|
|
}
|
|
throw new NullReferenceException();
|
|
IL_2F:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009EDE RID: 40670 RVA: 0x0020B158 File Offset: 0x00209358
|
|
[Token(Token = "0x6009EDE")]
|
|
[Address(RVA = "0x653A20", Offset = "0x652A20", VA = "0x180653A20", Slot = "6")]
|
|
public virtual byte[] GetEncoded(string encoding)
|
|
{
|
|
int num3;
|
|
int num4;
|
|
Asn1EncodableVector asn1EncodableVector;
|
|
Asn1Encodable[] array;
|
|
int num5;
|
|
Asn1Encodable[] array2;
|
|
for (;;)
|
|
{
|
|
if (!Platform.EqualsIgnoreCase(encoding, "PkiPath"))
|
|
{
|
|
if (!Platform.EqualsIgnoreCase(encoding, "PKCS7"))
|
|
{
|
|
if (!Platform.EqualsIgnoreCase(encoding, "PEM"))
|
|
{
|
|
goto IL_1AA;
|
|
}
|
|
PemWriter pemWriter = new PemWriter(new StreamWriter(new MemoryStream()));
|
|
int num = 0;
|
|
IList list = this.certificates;
|
|
if (num != pemWriter)
|
|
{
|
|
IList list2 = this.certificates;
|
|
pemWriter.WriteObject(pemWriter);
|
|
num++;
|
|
}
|
|
TextWriter writer = pemWriter.writer;
|
|
}
|
|
int num2;
|
|
ContentInfo contentInfo = new ContentInfo(PkcsObjectIdentifiers.Data, num2);
|
|
num3 = 0;
|
|
num2 = 0;
|
|
num4 = 0;
|
|
IList list3 = this.certificates;
|
|
if (num4 == asn1EncodableVector)
|
|
{
|
|
goto IL_E4;
|
|
}
|
|
array = new Asn1Encodable[1];
|
|
IList list4 = this.certificates;
|
|
if (num4 < list3)
|
|
{
|
|
num4 += num4;
|
|
num4++;
|
|
}
|
|
if (array == 0)
|
|
{
|
|
num4 += num4;
|
|
}
|
|
if (array != 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
IList list5 = this.certificates;
|
|
num5 = 0;
|
|
array2 = new Asn1Encodable[1];
|
|
IList list6 = this.certificates;
|
|
if (num5 < list5)
|
|
{
|
|
num5 += num5;
|
|
num5++;
|
|
}
|
|
if (num5 == 0)
|
|
{
|
|
num5 += num5;
|
|
num5 += 19;
|
|
}
|
|
if (num5 != 0)
|
|
{
|
|
goto Block_10;
|
|
}
|
|
}
|
|
}
|
|
Asn1Object asn1Object;
|
|
if (asn1Object != 0)
|
|
{
|
|
}
|
|
array[0] = asn1Object;
|
|
asn1EncodableVector.Add(array);
|
|
num4++;
|
|
IL_E4:
|
|
DerInteger derInteger = new DerInteger(1);
|
|
DerSet derSet = new DerSet();
|
|
DerSet derSet2 = new DerSet(asn1EncodableVector);
|
|
DerSet derSet3 = new DerSet();
|
|
SignedData signedData = new SignedData(derInteger, derSet, num3, derSet2, num4, derSet3);
|
|
ContentInfo contentInfo2 = new ContentInfo(PkcsObjectIdentifiers.SignedData, signedData);
|
|
return this.ToDerEncoded(contentInfo2);
|
|
Block_10:
|
|
Asn1Object asn1Object2 = this.ToAsn1Object(num5);
|
|
if (asn1Object2 != 0)
|
|
{
|
|
}
|
|
array2[0] = asn1Object2;
|
|
Asn1EncodableVector asn1EncodableVector2;
|
|
asn1EncodableVector2.Add(array2);
|
|
DerSequence derSequence = new DerSequence(asn1EncodableVector2);
|
|
throw new NullReferenceException();
|
|
IL_1AA:
|
|
string text;
|
|
CertificateEncodingException ex = new CertificateEncodingException(text);
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x17001973 RID: 6515
|
|
// (get) Token: 0x06009EDF RID: 40671 RVA: 0x0020B344 File Offset: 0x00209544
|
|
[Token(Token = "0x17001973")]
|
|
public virtual IList Certificates
|
|
{
|
|
[Token(Token = "0x6009EDF")]
|
|
[Address(RVA = "0x655340", Offset = "0x654340", VA = "0x180655340", Slot = "7")]
|
|
get
|
|
{
|
|
return CollectionUtilities.ReadOnly(this.certificates);
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009EE0 RID: 40672 RVA: 0x0020B35C File Offset: 0x0020955C
|
|
[Token(Token = "0x6009EE0")]
|
|
[Address(RVA = "0x654970", Offset = "0x653970", VA = "0x180654970")]
|
|
private Asn1Object ToAsn1Object(X509Certificate cert)
|
|
{
|
|
AsymmetricKeyParameter publicKey = cert.GetPublicKey();
|
|
Asn1Object asn1Object;
|
|
return asn1Object;
|
|
}
|
|
|
|
// Token: 0x06009EE1 RID: 40673 RVA: 0x0020B378 File Offset: 0x00209578
|
|
[Token(Token = "0x6009EE1")]
|
|
[Address(RVA = "0x654A20", Offset = "0x653A20", VA = "0x180654A20")]
|
|
private byte[] ToDerEncoded(Asn1Encodable obj)
|
|
{
|
|
return obj.GetEncoded("DER");
|
|
}
|
|
|
|
// Token: 0x04006A93 RID: 27283
|
|
[Token(Token = "0x4006A93")]
|
|
internal static readonly IList certPathEncodings = CollectionUtilities.ReadOnly(Platform.CreateArrayList());
|
|
|
|
// Token: 0x04006A94 RID: 27284
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4006A94")]
|
|
private readonly IList certificates;
|
|
}
|
|
}
|