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.Cms.Ecc; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters; using BestHTTP.SecureProtocol.Org.BouncyCastle.Math; using BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs; using BestHTTP.SecureProtocol.Org.BouncyCastle.Security; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms { // Token: 0x02001E3A RID: 7738 [Token(Token = "0x2001E3A")] public class KeyAgreeRecipientInformation : RecipientInformation { // Token: 0x0600C224 RID: 49700 RVA: 0x002BE47C File Offset: 0x002BC67C [Token(Token = "0x600C224")] [Address(RVA = "0x29317C0", Offset = "0x29307C0", VA = "0x1829317C0")] internal static void ReadRecipientInfo(IList infos, KeyAgreeRecipientInfo info, CmsSecureReadable secureReadable) { int num = 0; IEnumerator enumerator = info.recipientEncryptedKeys.GetEnumerator(); if (enumerator != 0) { if (num < enumerator) { num += num; num++; } ulong num2; enumerator += num2; if (enumerator == 0 || enumerator == 0) { throw new NullReferenceException(); } RecipientID recipientID = new RecipientID(); RecipientEncryptedKey recipientEncryptedKey; KeyAgreeRecipientIdentifier identifier = recipientEncryptedKey.identifier; if (identifier.issuerSerial == 0) { Stream octetStream = identifier.rKeyID.subjectKeyIdentifier.GetOctetStream(); } byte[] authorityKeyIdentifier = recipientID.authorityKeyIdentifier; recipientID.issuer = authorityKeyIdentifier; int basicConstraints = recipientID.basicConstraints; BigInteger bigInteger; recipientID.serialNumber = bigInteger; } KeyAgreeRecipientInformation keyAgreeRecipientInformation; if (keyAgreeRecipientInformation != 0) { } if (num == 0) { return; } throw new NullReferenceException(); } // Token: 0x0600C225 RID: 49701 RVA: 0x002BE560 File Offset: 0x002BC760 [Token(Token = "0x600C225")] [Address(RVA = "0x2931CA0", Offset = "0x2930CA0", VA = "0x182931CA0")] internal KeyAgreeRecipientInformation(KeyAgreeRecipientInfo info, RecipientID rid, Asn1OctetString encryptedKey, CmsSecureReadable secureReadable) { this.rid = rid; this.encryptedKey = encryptedKey; this.info = info; } // Token: 0x0600C226 RID: 49702 RVA: 0x002BE588 File Offset: 0x002BC788 [Token(Token = "0x600C226")] [Address(RVA = "0x2931260", Offset = "0x2930260", VA = "0x182931260")] private AsymmetricKeyParameter GetSenderPublicKey(AsymmetricKeyParameter receiverPrivateKey, OriginatorIdentifierOrKey originator) { OriginatorPublicKey originatorPublicKey = originator.OriginatorPublicKey; if (originatorPublicKey != 0) { return this.GetPublicKeyFromOriginatorPublicKey(receiverPrivateKey, originatorPublicKey); } OriginatorID originatorID = new OriginatorID(); IssuerAndSerialNumber issuerAndSerialNumber = originator.IssuerAndSerialNumber; if (issuerAndSerialNumber == 0) { throw new NullReferenceException(); } throw new NullReferenceException(); } // Token: 0x0600C227 RID: 49703 RVA: 0x002BE638 File Offset: 0x002BC838 [Token(Token = "0x600C227")] [Address(RVA = "0x29311A0", Offset = "0x29301A0", VA = "0x1829311A0")] private AsymmetricKeyParameter GetPublicKeyFromOriginatorPublicKey(AsymmetricKeyParameter receiverPrivateKey, OriginatorPublicKey originatorPublicKey) { bool hasPublicKey = PrivateKeyInfoFactory.CreatePrivateKeyInfo(receiverPrivateKey).HasPublicKey; byte[] octets = originatorPublicKey.mPublicKey.GetOctets(); SubjectPublicKeyInfo subjectPublicKeyInfo; return PublicKeyFactory.CreateKey(subjectPublicKeyInfo); } // Token: 0x0600C228 RID: 49704 RVA: 0x002BE66C File Offset: 0x002BC86C [Token(Token = "0x600C228")] [Address(RVA = "0x2931140", Offset = "0x2930140", VA = "0x182931140")] private AsymmetricKeyParameter GetPublicKeyFromOriginatorID(OriginatorID origID) { /* An exception occurred when decompiling this method (0600C228) ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.AsymmetricKeyParameter BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.KeyAgreeRecipientInformation::GetPublicKeyFromOriginatorID(BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.OriginatorID) ---> System.Exception: Basic block has to end with unconditional control flow. { Block_0: stloc:CmsException(var_0_0A, newobj:CmsException(CmsException::.ctor, ldstr:string("No support for 'originator' as IssuerAndSerialNumber or SubjectKeyIdentifier"))) } 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: 0x0600C229 RID: 49705 RVA: 0x002BE684 File Offset: 0x002BC884 [Token(Token = "0x600C229")] [Address(RVA = "0x2930C60", Offset = "0x292FC60", VA = "0x182930C60")] private KeyParameter CalculateAgreedWrapKey(string wrapAlg, AsymmetricKeyParameter senderPublicKey, AsymmetricKeyParameter receiverPrivateKey) { for (;;) { Asn1Object asn1Object = this.keyEncAlg.ToAsn1Object(); string ecmqvSha1Kdf = CmsEnvelopedGenerator.ECMqvSha1Kdf; bool flag; if (!flag) { break; } Stream octetStream = this.info.ukm.GetOctetStream(); Asn1Object asn1Object2; OriginatorPublicKey ephemeralPublicKey = MQVuserKeyingMaterial.GetInstance(asn1Object2).ephemeralPublicKey; AsymmetricKeyParameter publicKeyFromOriginatorPublicKey = this.GetPublicKeyFromOriginatorPublicKey(receiverPrivateKey, ephemeralPublicKey); if (publicKeyFromOriginatorPublicKey == 0) { } if (publicKeyFromOriginatorPublicKey != 0) { if (senderPublicKey == 0) { } if (senderPublicKey != 0) { if (receiverPrivateKey == 0) { } if (receiverPrivateKey != 0 && receiverPrivateKey != 0) { break; } } } } int num = 0; int defaultKeySize = GeneratorUtilities.GetDefaultKeySize(wrapAlg); num += defaultKeySize; byte[] array; return ParameterUtilities.CreateKeyParameter(wrapAlg, array); } // Token: 0x0600C22A RID: 49706 RVA: 0x002BE71C File Offset: 0x002BC91C [Token(Token = "0x600C22A")] [Address(RVA = "0x2931B70", Offset = "0x2930B70", VA = "0x182931B70")] private KeyParameter UnwrapSessionKey(string wrapAlg, KeyParameter agreedKey) { Stream octetStream = this.encryptedKey.GetOctetStream(); IWrapper wrapper = WrapperUtilities.GetWrapper(wrapAlg); Stream.ReadWriteTask activeReadWriteTask = octetStream._activeReadWriteTask; string contentAlgorithmName = base.GetContentAlgorithmName(); KeyParameter keyParameter; return keyParameter; } // Token: 0x0600C22B RID: 49707 RVA: 0x002BE754 File Offset: 0x002BC954 [Token(Token = "0x600C22B")] [Address(RVA = "0x29313C0", Offset = "0x29303C0", VA = "0x1829313C0")] internal KeyParameter GetSessionKey(AsymmetricKeyParameter receiverPrivateKey) { Asn1SequenceParser parser = Asn1Sequence.GetInstance(this.keyEncAlg.ObjectID).Parser; DerObjectIdentifier derObjectIdentifier; string identifier = derObjectIdentifier.identifier; OriginatorIdentifierOrKey originator = this.info.originator; OriginatorPublicKey originatorPublicKey = originator.OriginatorPublicKey; if (originatorPublicKey != 0) { AsymmetricKeyParameter publicKeyFromOriginatorPublicKey = this.GetPublicKeyFromOriginatorPublicKey(receiverPrivateKey, originatorPublicKey); KeyParameter keyParameter = this.CalculateAgreedWrapKey(identifier, publicKeyFromOriginatorPublicKey, receiverPrivateKey); Stream octetStream = this.encryptedKey.GetOctetStream(); IWrapper wrapper = WrapperUtilities.GetWrapper(identifier); Stream.ReadWriteTask activeReadWriteTask = octetStream._activeReadWriteTask; string contentAlgorithmName = base.GetContentAlgorithmName(); KeyParameter keyParameter2; return keyParameter2; } OriginatorID originatorID = new OriginatorID(); IssuerAndSerialNumber issuerAndSerialNumber = originator.IssuerAndSerialNumber; if (issuerAndSerialNumber == 0) { throw new NullReferenceException(); } throw new NullReferenceException(); } // Token: 0x0600C22C RID: 49708 RVA: 0x002BE8C0 File Offset: 0x002BCAC0 [Token(Token = "0x600C22C")] [Address(RVA = "0x2930FE0", Offset = "0x292FFE0", VA = "0x182930FE0", Slot = "4")] public override CmsTypedStream GetContentStream(ICipherParameters key) { /* An exception occurred when decompiling this method (0600C22C) ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.CmsTypedStream BestHTTP.SecureProtocol.Org.BouncyCastle.Cms.KeyAgreeRecipientInformation::GetContentStream(BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters) ---> System.Exception: Basic block has to end with unconditional control flow. { IL_18: stloc:ArgumentException(var_3_27, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("KeyAgreement requires asymmetric key"), ldstr:string("key"))) stloc:ArgumentException(var_4_37, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("Expected private key"), ldstr:string("key"))) } 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: 0x04007ADA RID: 31450 [FieldOffset(Offset = "0x30")] [Token(Token = "0x4007ADA")] private KeyAgreeRecipientInfo info; // Token: 0x04007ADB RID: 31451 [FieldOffset(Offset = "0x38")] [Token(Token = "0x4007ADB")] private Asn1OctetString encryptedKey; } }