using System; using System.Collections; using System.IO; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.IO; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO; using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms { // Token: 0x02001D47 RID: 7495 [Token(Token = "0x2001D47")] public class CmsSignedDataParser : CmsContentInfoParser { // Token: 0x0600BDC0 RID: 48576 RVA: 0x002B2B30 File Offset: 0x002B0D30 [Token(Token = "0x600BDC0")] [Address(RVA = "0x166A310", Offset = "0x1669110", VA = "0x18166A310")] public CmsSignedDataParser(byte[] sigBlock) { int num; MemoryStream memoryStream = new MemoryStream(sigBlock, num != 0); num = 0; } // Token: 0x0600BDC1 RID: 48577 RVA: 0x002B2B4C File Offset: 0x002B0D4C [Token(Token = "0x600BDC1")] [Address(RVA = "0x1669E50", Offset = "0x1668C50", VA = "0x181669E50")] public CmsSignedDataParser(CmsTypedStream signedContent, byte[] sigBlock) { int num; MemoryStream memoryStream = new MemoryStream(sigBlock, num != 0); num = 0; } // Token: 0x0600BDC2 RID: 48578 RVA: 0x002B2B64 File Offset: 0x002B0D64 [Token(Token = "0x600BDC2")] [Address(RVA = "0x166A300", Offset = "0x1669100", VA = "0x18166A300")] public CmsSignedDataParser(Stream sigData) { } // Token: 0x0600BDC3 RID: 48579 RVA: 0x002B2B74 File Offset: 0x002B0D74 [Token(Token = "0x600BDC3")] [Address(RVA = "0x1669ED0", Offset = "0x1668CD0", VA = "0x181669ED0")] public CmsSignedDataParser(CmsTypedStream signedContent, Stream sigData) : base(sigData) { this._signedContent = signedContent; IAsn1Convertible content = this.contentInfo.GetContent(16); SignedDataParser signedDataParser; this._signedData = signedDataParser; IDictionary dictionary = Platform.CreateHashtable(); this._digests = dictionary; HashSet hashSet = new HashSet(); this._digestOids = hashSet; if (this._signedData.GetDigestAlgorithms() != 0) { AlgorithmIdentifier algorithmIdentifier; Asn1Object asn1Object = algorithmIdentifier.ToAsn1Object(); CmsSignedHelper helper = CmsSignedDataParser.Helper; IDictionary digests = this._digests; string text; if (text == 0) { IDictionary digests2 = this._digests; IDigest digestInstance = CmsSignedDataParser.Helper.GetDigestInstance(text); ISet digestOids = this._digestOids; } } ContentInfoParser encapContentInfo = this._signedData.GetEncapContentInfo(); IAsn1Convertible content2 = encapContentInfo.GetContent(4); if (content2 != 0) { if (content2 == 0) { throw new NullReferenceException(); } DerObjectIdentifier contentType = encapContentInfo.contentType; if (this._signedContent == (ulong)0L) { goto IL_DF; } CmsTypedStream cmsTypedStream; cmsTypedStream.Drain(); } CmsTypedStream signedContent2 = this._signedContent; if (signedContent2 == 0) { DerObjectIdentifier contentType2 = encapContentInfo.contentType; } IL_DF: DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(signedContent2._oid); this._signedContentType = derObjectIdentifier; } // Token: 0x17001D69 RID: 7529 // (get) Token: 0x0600BDC4 RID: 48580 RVA: 0x002B2CD8 File Offset: 0x002B0ED8 [Token(Token = "0x17001D69")] public int Version { [Token(Token = "0x600BDC4")] [Address(RVA = "0x166A3E0", Offset = "0x16691E0", VA = "0x18166A3E0")] get { return this._signedData._version.Value.IntValue; } } // Token: 0x17001D6A RID: 7530 // (get) Token: 0x0600BDC5 RID: 48581 RVA: 0x002B2D00 File Offset: 0x002B0F00 [Token(Token = "0x17001D6A")] public ISet DigestOids { [Token(Token = "0x600BDC5")] [Address(RVA = "0x166A380", Offset = "0x1669180", VA = "0x18166A380")] get { /* An exception occurred when decompiling this method (0600BDC5) ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections.ISet BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.CmsSignedDataParser::get_DigestOids() ---> System.Exception: Basic block has to end with unconditional control flow. { Block_0: stloc:HashSet(var_0_0B, newobj:HashSet(HashSet::.ctor, ldfld:ISet[exp:IEnumerable](CmsSignedDataParser::_digestOids, ldloc:CmsSignedDataParser(this)))) } 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: 0x0600BDC6 RID: 48582 RVA: 0x002B2D18 File Offset: 0x002B0F18 [Token(Token = "0x600BDC6")] [Address(RVA = "0x1669330", Offset = "0x1668130", VA = "0x181669330")] public SignerInformationStore GetSignerInfos() { int num = 0; SignerInformationStore signerInfoStore = this._signerInfoStore; if (signerInfoStore == 0) { this.PopulateCertCrlSets(); IList list = Platform.CreateArrayList(); IDictionary dictionary = Platform.CreateHashtable(); IDictionary digests = this._digests; if (dictionary != 0) { IDictionary digests2 = this._digests; } byte[] array; if (array != 0) { } if (num != 0) { throw new NullReferenceException(); } if (this._signedData.GetSignerInfos() != 0) { CmsSignedHelper helper = CmsSignedDataParser.Helper; SignerInfo signerInfo; Asn1Object asn1Object = signerInfo.digAlgorithm.ToAsn1Object(); DerObjectIdentifier signedContentType = this._signedContentType; BaseDigestCalculator baseDigestCalculator; string text; baseDigestCalculator.digest = text; int num2; SignerInformation signerInformation = new SignerInformation(signerInfo, signedContentType, num2, baseDigestCalculator); num2 = 0; } SignerInformationStore signerInformationStore; this._signerInfoStore = signerInformationStore; } return signerInfoStore; } // Token: 0x0600BDC7 RID: 48583 RVA: 0x002B2E18 File Offset: 0x002B1018 [Token(Token = "0x600BDC7")] [Address(RVA = "0x1668EF0", Offset = "0x1667CF0", VA = "0x181668EF0")] public IX509Store GetAttributeCertificates(string type) { IX509Store attributeStore = this._attributeStore; if (attributeStore == 0) { this.PopulateCertCrlSets(); CmsSignedHelper helper = CmsSignedDataParser.Helper; Asn1Set certSet = this._certSet; IX509Store ix509Store = helper.CreateAttributeStore(type, certSet); this._attributeStore = ix509Store; } return attributeStore; } // Token: 0x0600BDC8 RID: 48584 RVA: 0x002B2E5C File Offset: 0x002B105C [Token(Token = "0x600BDC8")] [Address(RVA = "0x1668F90", Offset = "0x1667D90", VA = "0x181668F90")] public IX509Store GetCertificates(string type) { IX509Store certificateStore = this._certificateStore; if (certificateStore == 0) { this.PopulateCertCrlSets(); CmsSignedHelper helper = CmsSignedDataParser.Helper; Asn1Set certSet = this._certSet; IX509Store ix509Store = helper.CreateCertificateStore(type, certSet); this._certificateStore = ix509Store; } return certificateStore; } // Token: 0x0600BDC9 RID: 48585 RVA: 0x002B2EA0 File Offset: 0x002B10A0 [Token(Token = "0x600BDC9")] [Address(RVA = "0x1669030", Offset = "0x1667E30", VA = "0x181669030")] public IX509Store GetCrls(string type) { IX509Store crlStore = this._crlStore; if (crlStore == 0) { this.PopulateCertCrlSets(); CmsSignedHelper helper = CmsSignedDataParser.Helper; Asn1Set crlSet = this._crlSet; IX509Store ix509Store = helper.CreateCrlStore(type, crlSet); this._crlStore = ix509Store; } return crlStore; } // Token: 0x0600BDCA RID: 48586 RVA: 0x002B2EE4 File Offset: 0x002B10E4 [Token(Token = "0x600BDCA")] [Address(RVA = "0x1669790", Offset = "0x1668590", VA = "0x181669790")] private void PopulateCertCrlSets() { if (!this._isCertCrlParsed) { this._isCertCrlParsed = true; if (this._signedData.GetCertificates() == 0) { } Asn1Set asn1Set; this._certSet = asn1Set; if (this._signedData.GetCrls() != 0) { } Asn1Set asn1Set2; this._crlSet = asn1Set2; } } // Token: 0x17001D6B RID: 7531 // (get) Token: 0x0600BDCB RID: 48587 RVA: 0x002B2F38 File Offset: 0x002B1138 [Token(Token = "0x17001D6B")] public DerObjectIdentifier SignedContentType { [Token(Token = "0x600BDCB")] [Address(RVA = "0x3F63E0", Offset = "0x3F51E0", VA = "0x1803F63E0")] get { return this._signedContentType; } } // Token: 0x0600BDCC RID: 48588 RVA: 0x002B2F4C File Offset: 0x002B114C [Token(Token = "0x600BDCC")] [Address(RVA = "0x16690D0", Offset = "0x1667ED0", VA = "0x1816690D0")] public CmsTypedStream GetSignedContent() { int num; CmsTypedStream signedContent; DigestStream digestStream; do { num = 0; signedContent = this._signedContent; if (signedContent == 0) { return signedContent; } Stream @in = signedContent._in; IDictionary digests = this._digests; if (signedContent != 0) { if (num < signedContent) { num += num; num++; } if (num == 0) { num++; num += 19; } if (num == 0) { goto IL_6F; } int num2; digestStream = new DigestStream(@in, num, num2); num2 = 0; } if (digestStream != 0) { } } while (num != 0); CmsTypedStream cmsTypedStream = new CmsTypedStream(this._signedContent._oid, digestStream); return signedContent; IL_6F: throw new NullReferenceException(); } // Token: 0x0600BDCD RID: 48589 RVA: 0x002B2FD0 File Offset: 0x002B11D0 [Token(Token = "0x600BDCD")] [Address(RVA = "0x1669AF0", Offset = "0x16688F0", VA = "0x181669AF0")] public static Stream ReplaceSigners(Stream original, SignerInformationStore signerInformationStore, Stream outStr) { CmsSignedDataStreamGenerator cmsSignedDataStreamGenerator = new CmsSignedDataStreamGenerator(); int num; CmsSignedDataParser cmsSignedDataParser = new CmsSignedDataParser(num, original); num = 0; cmsSignedDataStreamGenerator.AddSigners(signerInformationStore); CmsTypedStream signedContent = cmsSignedDataParser.GetSignedContent(); DerObjectIdentifier signedContentType = cmsSignedDataParser._signedContentType; bool flag = signedContent != 0; string identifier = signedContentType.identifier; int num2 = 0; Stream stream = cmsSignedDataStreamGenerator.Open(outStr, identifier, flag, num2); if (flag) { Streams.PipeAll(signedContent._in, stream); } IX509Store ix509Store; if (cmsSignedDataParser._attributeStore == 0) { cmsSignedDataParser.PopulateCertCrlSets(); CmsSignedHelper helper = CmsSignedDataParser.Helper; Asn1Set certSet = cmsSignedDataParser._certSet; ix509Store = helper.CreateAttributeStore("Collection", certSet); cmsSignedDataParser._attributeStore = ix509Store; } cmsSignedDataStreamGenerator.AddAttributeCertificates(ix509Store); IX509Store ix509Store2; if (cmsSignedDataParser._certificateStore == 0) { cmsSignedDataParser.PopulateCertCrlSets(); CmsSignedHelper helper2 = CmsSignedDataParser.Helper; Asn1Set certSet2 = cmsSignedDataParser._certSet; ix509Store2 = helper2.CreateCertificateStore("Collection", certSet2); cmsSignedDataParser._certificateStore = ix509Store2; } cmsSignedDataStreamGenerator.AddCertificates(ix509Store2); IX509Store ix509Store3; if (cmsSignedDataParser._crlStore == 0) { cmsSignedDataParser.PopulateCertCrlSets(); CmsSignedHelper helper3 = CmsSignedDataParser.Helper; Asn1Set crlSet = cmsSignedDataParser._crlSet; ix509Store3 = helper3.CreateCrlStore("Collection", crlSet); cmsSignedDataParser._crlStore = ix509Store3; } cmsSignedDataStreamGenerator.AddCrls(ix509Store3); Platform.Dispose(stream); return outStr; } // Token: 0x0600BDCE RID: 48590 RVA: 0x002B3104 File Offset: 0x002B1304 [Token(Token = "0x600BDCE")] [Address(RVA = "0x1669910", Offset = "0x1668710", VA = "0x181669910")] public static Stream ReplaceCertificatesAndCrls(Stream original, IX509Store x509Certs, IX509Store x509Crls, IX509Store x509AttrCerts, Stream outStr) { CmsSignedDataStreamGenerator cmsSignedDataStreamGenerator = new CmsSignedDataStreamGenerator(); int num; CmsSignedDataParser cmsSignedDataParser = new CmsSignedDataParser(num, original); num = 0; HashSet hashSet = new HashSet(cmsSignedDataParser._digestOids); cmsSignedDataStreamGenerator.AddDigests(hashSet); CmsTypedStream signedContent = cmsSignedDataParser.GetSignedContent(); DerObjectIdentifier signedContentType = cmsSignedDataParser._signedContentType; bool flag = signedContent != 0; Stream stream; Streams.PipeAll(signedContent._in, stream); if (x509AttrCerts != 0) { cmsSignedDataStreamGenerator.AddAttributeCertificates(x509AttrCerts); } if (x509Certs != 0) { cmsSignedDataStreamGenerator.AddCertificates(x509Certs); } if (x509Crls != 0) { cmsSignedDataStreamGenerator.AddCrls(x509Crls); } SignerInformationStore signerInfos = cmsSignedDataParser.GetSignerInfos(); cmsSignedDataStreamGenerator.AddSigners(signerInfos); throw new NullReferenceException(); } // Token: 0x0600BDCF RID: 48591 RVA: 0x002B3198 File Offset: 0x002B1398 [Token(Token = "0x600BDCF")] [Address(RVA = "0x1668E90", Offset = "0x1667C90", VA = "0x181668E90")] private static Asn1Set GetAsn1Set(Asn1SetParser asn1SetParser) { if (asn1SetParser == 0) { } return Asn1Set.GetInstance(0); } // Token: 0x040078C6 RID: 30918 [Token(Token = "0x40078C6")] private static readonly CmsSignedHelper Helper = CmsSignedHelper.Instance; // Token: 0x040078C7 RID: 30919 [FieldOffset(Offset = "0x20")] [Token(Token = "0x40078C7")] private SignedDataParser _signedData; // Token: 0x040078C8 RID: 30920 [FieldOffset(Offset = "0x28")] [Token(Token = "0x40078C8")] private DerObjectIdentifier _signedContentType; // Token: 0x040078C9 RID: 30921 [FieldOffset(Offset = "0x30")] [Token(Token = "0x40078C9")] private CmsTypedStream _signedContent; // Token: 0x040078CA RID: 30922 [FieldOffset(Offset = "0x38")] [Token(Token = "0x40078CA")] private IDictionary _digests; // Token: 0x040078CB RID: 30923 [FieldOffset(Offset = "0x40")] [Token(Token = "0x40078CB")] private ISet _digestOids; // Token: 0x040078CC RID: 30924 [FieldOffset(Offset = "0x48")] [Token(Token = "0x40078CC")] private SignerInformationStore _signerInfoStore; // Token: 0x040078CD RID: 30925 [FieldOffset(Offset = "0x50")] [Token(Token = "0x40078CD")] private Asn1Set _certSet; // Token: 0x040078CE RID: 30926 [FieldOffset(Offset = "0x58")] [Token(Token = "0x40078CE")] private Asn1Set _crlSet; // Token: 0x040078CF RID: 30927 [FieldOffset(Offset = "0x60")] [Token(Token = "0x40078CF")] private bool _isCertCrlParsed; // Token: 0x040078D0 RID: 30928 [FieldOffset(Offset = "0x68")] [Token(Token = "0x40078D0")] private IX509Store _attributeStore; // Token: 0x040078D1 RID: 30929 [FieldOffset(Offset = "0x70")] [Token(Token = "0x40078D1")] private IX509Store _certificateStore; // Token: 0x040078D2 RID: 30930 [FieldOffset(Offset = "0x78")] [Token(Token = "0x40078D2")] private IX509Store _crlStore; } }