366 lines
15 KiB
C#
366 lines
15 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Runtime.InteropServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms
|
|
{
|
|
// Token: 0x02001771 RID: 6001
|
|
[Token(Token = "0x2001771")]
|
|
[StructLayout(3)]
|
|
internal class CmsSignedHelper
|
|
{
|
|
// Token: 0x0600A236 RID: 41526 RVA: 0x0025C174 File Offset: 0x0025A374
|
|
[Token(Token = "0x600A236")]
|
|
[Address(RVA = "0x1C829A0", Offset = "0x1C813A0", VA = "0x181C829A0")]
|
|
private static void AddEntries(DerObjectIdentifier oid, string digest, string encryption)
|
|
{
|
|
IDictionary dictionary = CmsSignedHelper.digestAlgs;
|
|
IDictionary dictionary2 = CmsSignedHelper.encryptionAlgs;
|
|
}
|
|
|
|
// Token: 0x0600A237 RID: 41527 RVA: 0x0025C194 File Offset: 0x0025A394
|
|
[Token(Token = "0x600A237")]
|
|
[Address(RVA = "0x1C83CC0", Offset = "0x1C826C0", VA = "0x181C83CC0")]
|
|
static CmsSignedHelper()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A237)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.CmsSignedHelper::.cctor()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_4D1:
|
|
stelem:string([mscorlib]System.String, ldloc:string[](var_77_4C7), ldc.i4:int32(0), ldstr:string("SHA-512"))
|
|
stloc:ISet(var_78_4E3, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:ISet(var_79_4EA, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:ISet(var_80_4F1, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:ISet(var_81_4F8, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:ISet(var_82_4FF, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:ISet(var_83_506, ldsfld:ISet(CmsSignedHelper::noParams))
|
|
stloc:IDictionary(var_84_50D, ldsfld:IDictionary(CmsSignedHelper::ecAlgorithms))
|
|
}
|
|
|
|
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: 0x0600A238 RID: 41528 RVA: 0x0025C6B0 File Offset: 0x0025A8B0
|
|
[Token(Token = "0x600A238")]
|
|
[Address(RVA = "0x1C83100", Offset = "0x1C81B00", VA = "0x181C83100")]
|
|
internal string GetDigestAlgName(string digestAlgOid)
|
|
{
|
|
IDictionary dictionary = CmsSignedHelper.digestAlgs;
|
|
return digestAlgOid;
|
|
}
|
|
|
|
// Token: 0x0600A239 RID: 41529 RVA: 0x0025C6CC File Offset: 0x0025A8CC
|
|
[Token(Token = "0x600A239")]
|
|
[Address(RVA = "0x1C833C0", Offset = "0x1C81DC0", VA = "0x181C833C0")]
|
|
internal AlgorithmIdentifier GetEncAlgorithmIdentifier(DerObjectIdentifier encOid, Asn1Encodable sigX509Parameters)
|
|
{
|
|
ISet set = CmsSignedHelper.noParams;
|
|
return new AlgorithmIdentifier(encOid, sigX509Parameters);
|
|
}
|
|
|
|
// Token: 0x0600A23A RID: 41530 RVA: 0x0025C6F4 File Offset: 0x0025A8F4
|
|
[Token(Token = "0x600A23A")]
|
|
[Address(RVA = "0x1C831B0", Offset = "0x1C81BB0", VA = "0x181C831B0")]
|
|
internal string[] GetDigestAliases(string algName)
|
|
{
|
|
IDictionary dictionary = CmsSignedHelper.digestAliases;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A23B RID: 41531 RVA: 0x0025C70C File Offset: 0x0025A90C
|
|
[Token(Token = "0x600A23B")]
|
|
[Address(RVA = "0x1C83BB0", Offset = "0x1C825B0", VA = "0x181C83BB0")]
|
|
internal string GetEncryptionAlgName(string encryptionAlgOid)
|
|
{
|
|
IDictionary dictionary = CmsSignedHelper.encryptionAlgs;
|
|
return encryptionAlgOid;
|
|
}
|
|
|
|
// Token: 0x0600A23C RID: 41532 RVA: 0x0025C728 File Offset: 0x0025A928
|
|
[Token(Token = "0x600A23C")]
|
|
[Address(RVA = "0x1C832B0", Offset = "0x1C81CB0", VA = "0x181C832B0")]
|
|
internal IDigest GetDigestInstance(string algorithm)
|
|
{
|
|
int num;
|
|
string[] array;
|
|
do
|
|
{
|
|
IDigest digest = DigestUtilities.GetDigest(algorithm);
|
|
num = 0;
|
|
}
|
|
while (num >= array.Length);
|
|
return DigestUtilities.GetDigest(array[num]);
|
|
}
|
|
|
|
// Token: 0x0600A23D RID: 41533 RVA: 0x0025C75C File Offset: 0x0025A95C
|
|
[Token(Token = "0x600A23D")]
|
|
[Address(RVA = "0x1C83C60", Offset = "0x1C82660", VA = "0x181C83C60")]
|
|
internal ISigner GetSignatureInstance(string algorithm)
|
|
{
|
|
return SignerUtilities.GetSigner(algorithm);
|
|
}
|
|
|
|
// Token: 0x0600A23E RID: 41534 RVA: 0x0025C770 File Offset: 0x0025A970
|
|
[Token(Token = "0x600A23E")]
|
|
[Address(RVA = "0x1C82A80", Offset = "0x1C81480", VA = "0x181C82A80")]
|
|
internal IX509Store CreateAttributeStore(string type, Asn1Set certSet)
|
|
{
|
|
IList list;
|
|
for (;;)
|
|
{
|
|
int num = 0;
|
|
list = Platform.CreateArrayList();
|
|
if (certSet == 0)
|
|
{
|
|
break;
|
|
}
|
|
IEnumerator enumerator = certSet.GetEnumerator();
|
|
if (enumerator != 0)
|
|
{
|
|
if (enumerator == 0)
|
|
{
|
|
}
|
|
if (enumerator == 0)
|
|
{
|
|
goto IL_91;
|
|
}
|
|
Asn1Sequence asn1Sequence;
|
|
if (new X509V2AttributeCertificate(asn1Sequence.GetEncoded()) != 0)
|
|
{
|
|
}
|
|
if (num != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
string text = "AttributeCertificate/" + type;
|
|
X509CollectionStoreParameters x509CollectionStoreParameters = new X509CollectionStoreParameters(list);
|
|
return X509StoreFactory.Create(text, x509CollectionStoreParameters);
|
|
IL_91:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A23F RID: 41535 RVA: 0x0025C814 File Offset: 0x0025AA14
|
|
[Token(Token = "0x600A23F")]
|
|
[Address(RVA = "0x1C82DE0", Offset = "0x1C817E0", VA = "0x181C82DE0")]
|
|
internal IX509Store CreateCertificateStore(string type, Asn1Set certSet)
|
|
{
|
|
IList list = Platform.CreateArrayList();
|
|
if (certSet != 0)
|
|
{
|
|
this.AddCertsFromSet(list, certSet);
|
|
}
|
|
string text = "Certificate/" + type;
|
|
X509CollectionStoreParameters x509CollectionStoreParameters = new X509CollectionStoreParameters(list);
|
|
return X509StoreFactory.Create(text, x509CollectionStoreParameters);
|
|
}
|
|
|
|
// Token: 0x0600A240 RID: 41536 RVA: 0x0025C860 File Offset: 0x0025AA60
|
|
[Token(Token = "0x600A240")]
|
|
[Address(RVA = "0x1C82F00", Offset = "0x1C81900", VA = "0x181C82F00")]
|
|
internal IX509Store CreateCrlStore(string type, Asn1Set crlSet)
|
|
{
|
|
IList list = Platform.CreateArrayList();
|
|
if (crlSet != 0)
|
|
{
|
|
this.AddCrlsFromSet(list, crlSet);
|
|
}
|
|
string text = "CRL/" + type;
|
|
X509CollectionStoreParameters x509CollectionStoreParameters = new X509CollectionStoreParameters(list);
|
|
return X509StoreFactory.Create(text, x509CollectionStoreParameters);
|
|
}
|
|
|
|
// Token: 0x0600A241 RID: 41537 RVA: 0x0025C8AC File Offset: 0x0025AAAC
|
|
[Token(Token = "0x600A241")]
|
|
[Address(RVA = "0x1C824D0", Offset = "0x1C80ED0", VA = "0x181C824D0")]
|
|
private void AddCertsFromSet(IList certs, Asn1Set certSet)
|
|
{
|
|
for (;;)
|
|
{
|
|
int num = 0;
|
|
X509CertificateParser x509CertificateParser = new X509CertificateParser();
|
|
IEnumerator enumerator = certSet.GetEnumerator();
|
|
if (enumerator != 0)
|
|
{
|
|
if (enumerator == 0)
|
|
{
|
|
}
|
|
if (enumerator == 0)
|
|
{
|
|
goto IL_49;
|
|
}
|
|
byte[] array;
|
|
if (x509CertificateParser.ReadCertificate(array) != 0)
|
|
{
|
|
}
|
|
if (num != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
IL_49:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A242 RID: 41538 RVA: 0x0025C908 File Offset: 0x0025AB08
|
|
[Token(Token = "0x600A242")]
|
|
[Address(RVA = "0x1C82750", Offset = "0x1C81150", VA = "0x181C82750")]
|
|
private void AddCrlsFromSet(IList crls, Asn1Set crlSet)
|
|
{
|
|
for (;;)
|
|
{
|
|
int num = 0;
|
|
X509CrlParser x509CrlParser = new X509CrlParser();
|
|
IEnumerator enumerator = crlSet.GetEnumerator();
|
|
if (enumerator != 0)
|
|
{
|
|
if (enumerator == 0)
|
|
{
|
|
}
|
|
if (enumerator == 0)
|
|
{
|
|
goto IL_43;
|
|
}
|
|
byte[] array;
|
|
if (x509CrlParser.ReadCrl(array) != 0)
|
|
{
|
|
}
|
|
if (num != -1)
|
|
{
|
|
}
|
|
if (num == 0)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
IL_43:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600A243 RID: 41539 RVA: 0x0025C960 File Offset: 0x0025AB60
|
|
[Token(Token = "0x600A243")]
|
|
[Address(RVA = "0x1C83020", Offset = "0x1C81A20", VA = "0x181C83020")]
|
|
internal AlgorithmIdentifier FixAlgID(AlgorithmIdentifier algId)
|
|
{
|
|
if (algId.ObjectID != 0)
|
|
{
|
|
return algId;
|
|
}
|
|
Asn1Object asn1Object = algId.ToAsn1Object();
|
|
AlgorithmIdentifier algorithmIdentifier;
|
|
return algorithmIdentifier;
|
|
}
|
|
|
|
// Token: 0x0600A244 RID: 41540 RVA: 0x0025C988 File Offset: 0x0025AB88
|
|
[Token(Token = "0x600A244")]
|
|
[Address(RVA = "0x1C834B0", Offset = "0x1C81EB0", VA = "0x181C834B0")]
|
|
internal string GetEncOid(AsymmetricKeyParameter key, string digestOID)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A244)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.String BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.CmsSignedHelper::GetEncOid(BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.AsymmetricKeyParameter,System.String)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_E8:
|
|
stloc:ArgumentException(var_21_F2, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("Unknown algorithm in CmsSignedGenerator.GetEncOid")))
|
|
}
|
|
|
|
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.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
|
|
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: 0x0600A245 RID: 41541 RVA: 0x0025CA88 File Offset: 0x0025AC88
|
|
[Token(Token = "0x600A245")]
|
|
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
|
|
public CmsSignedHelper()
|
|
{
|
|
}
|
|
|
|
// Token: 0x04006AC1 RID: 27329
|
|
[Token(Token = "0x4006AC1")]
|
|
internal static readonly CmsSignedHelper Instance;
|
|
|
|
// Token: 0x04006AC2 RID: 27330
|
|
[Token(Token = "0x4006AC2")]
|
|
private static readonly string EncryptionECDsaWithSha1;
|
|
|
|
// Token: 0x04006AC3 RID: 27331
|
|
[Token(Token = "0x4006AC3")]
|
|
private static readonly string EncryptionECDsaWithSha224;
|
|
|
|
// Token: 0x04006AC4 RID: 27332
|
|
[Token(Token = "0x4006AC4")]
|
|
private static readonly string EncryptionECDsaWithSha256;
|
|
|
|
// Token: 0x04006AC5 RID: 27333
|
|
[Token(Token = "0x4006AC5")]
|
|
private static readonly string EncryptionECDsaWithSha384;
|
|
|
|
// Token: 0x04006AC6 RID: 27334
|
|
[Token(Token = "0x4006AC6")]
|
|
private static readonly string EncryptionECDsaWithSha512;
|
|
|
|
// Token: 0x04006AC7 RID: 27335
|
|
[Token(Token = "0x4006AC7")]
|
|
private static readonly IDictionary encryptionAlgs;
|
|
|
|
// Token: 0x04006AC8 RID: 27336
|
|
[Token(Token = "0x4006AC8")]
|
|
private static readonly IDictionary digestAlgs;
|
|
|
|
// Token: 0x04006AC9 RID: 27337
|
|
[Token(Token = "0x4006AC9")]
|
|
private static readonly IDictionary digestAliases;
|
|
|
|
// Token: 0x04006ACA RID: 27338
|
|
[Token(Token = "0x4006ACA")]
|
|
private static readonly ISet noParams;
|
|
|
|
// Token: 0x04006ACB RID: 27339
|
|
[Token(Token = "0x4006ACB")]
|
|
private static readonly IDictionary ecAlgorithms;
|
|
}
|
|
}
|