using System; using System.Collections; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters; using BestHTTP.SecureProtocol.Org.BouncyCastle.Math; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines { // Token: 0x02001C98 RID: 7320 [Token(Token = "0x2001C98")] public class NaccacheSternEngine : IAsymmetricBlockCipher { // Token: 0x17001CD5 RID: 7381 // (get) Token: 0x0600B7EB RID: 47083 RVA: 0x0028CCCC File Offset: 0x0028AECC [Token(Token = "0x17001CD5")] public string AlgorithmName { [Token(Token = "0x600B7EB")] [Address(RVA = "0x1DD4FB0", Offset = "0x1DD3DB0", VA = "0x181DD4FB0", Slot = "4")] get { return "NaccacheStern"; } } // Token: 0x0600B7EC RID: 47084 RVA: 0x0028CCE0 File Offset: 0x0028AEE0 [Token(Token = "0x600B7EC")] [Address(RVA = "0x1DD3E00", Offset = "0x1DD2C00", VA = "0x181DD3E00", Slot = "9")] public virtual void Init(bool forEncryption, ICipherParameters parameters) { for (;;) { this.forEncryption = forEncryption; if (parameters == 0 || ((parameters == 0 || (parameters != 0 && parameters != 0)) && (parameters == 0 || parameters != 0))) { int num = 0; this.key = num; if (forEncryption) { return; } int num2 = 0; if (num != 0) { IList[] array = new IList[num2]; if (0 >= array) { return; } if (array != 0) { break; } } } } int num3; IList list = Platform.CreateArrayList(num3); throw new ArrayTypeMismatchException(); } // Token: 0x17001CD6 RID: 7382 // (set) Token: 0x0600B7ED RID: 47085 RVA: 0x0000220F File Offset: 0x0000040F [Token(Token = "0x17001CD6")] [Obsolete] public virtual bool Debug { [Token(Token = "0x600B7ED")] [Address(RVA = "0x402080", Offset = "0x400E80", VA = "0x180402080", Slot = "10")] set { throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method."); } } // Token: 0x0600B7EE RID: 47086 RVA: 0x0028CD78 File Offset: 0x0028AF78 [Token(Token = "0x600B7EE")] [Address(RVA = "0x1DD3D40", Offset = "0x1DD2B40", VA = "0x181DD3D40", Slot = "11")] public virtual int GetInputBlockSize() { NaccacheSternKeyParameters naccacheSternKeyParameters = this.key; if (!this.forEncryption) { BigInteger n = naccacheSternKeyParameters.n; int num = 0; int num2 = n.BitLength; num2 += num; return num2 + 1; } int lowerSigmaBound = naccacheSternKeyParameters.lowerSigmaBound; return lowerSigmaBound + 7; } // Token: 0x0600B7EF RID: 47087 RVA: 0x0028CDC8 File Offset: 0x0028AFC8 [Token(Token = "0x600B7EF")] [Address(RVA = "0x1DD3DA0", Offset = "0x1DD2BA0", VA = "0x181DD3DA0", Slot = "12")] public virtual int GetOutputBlockSize() { NaccacheSternKeyParameters naccacheSternKeyParameters = this.key; if (!this.forEncryption) { int lowerSigmaBound = naccacheSternKeyParameters.lowerSigmaBound; return lowerSigmaBound + 7; } BigInteger n = naccacheSternKeyParameters.n; int num = 0; int num2 = n.BitLength; num2 += num; return num2 + 1; } // Token: 0x0600B7F0 RID: 47088 RVA: 0x0028CE18 File Offset: 0x0028B018 [Token(Token = "0x600B7F0")] [Address(RVA = "0x1DD42A0", Offset = "0x1DD30A0", VA = "0x181DD42A0", Slot = "13")] public virtual byte[] ProcessBlock(byte[] inBytes, int inOff, int length) { if (this.key != (ulong)0L) { if (!this.forEncryption) { } BigInteger bigInteger = new BigInteger(1, inBytes, length, length); int num = 0; if ((this.forEncryption ? 1 : 0) == num) { IList list = Platform.CreateArrayList(); if (num >= list) { BigInteger bigInteger2; return bigInteger2.ToByteArray(); } int num2 = 0; BigInteger bigInteger4; BigInteger bigInteger3 = bigInteger.ModPow(bigInteger4, num2); IList list2 = this.lookup[num]; int intValue = bigInteger3.IntValue; if (intValue != -1) { BigInteger bigInteger5 = BigInteger.ValueOf((long)intValue); num++; object[] array = new object[6]; throw new ArrayTypeMismatchException(); } goto IL_B5; } } InvalidOperationException ex = new InvalidOperationException("NaccacheStern engine not initialised"); IL_B5: InvalidCipherTextException ex2 = new InvalidCipherTextException("Lookup failed"); inBytes[1] = (byte)length; throw new ArrayTypeMismatchException(); } // Token: 0x0600B7F1 RID: 47089 RVA: 0x0028CF5C File Offset: 0x0028B15C [Token(Token = "0x600B7F1")] [Address(RVA = "0x1DD3C50", Offset = "0x1DD2A50", VA = "0x181DD3C50", Slot = "14")] public virtual byte[] Encrypt(BigInteger plain) { BigInteger n = this.key.n; int num = 0; int bitLength = n.BitLength; num += bitLength; num++; byte[] array = new byte[num]; NaccacheSternKeyParameters naccacheSternKeyParameters = this.key; BigInteger g = naccacheSternKeyParameters.g; BigInteger n2 = naccacheSternKeyParameters.n; byte[] array2 = g.ModPow(plain, n2).ToByteArray(); int length = array2.Length; int num2 = array.Length; int num3 = 0; num2 -= length; Array.Copy(array2, num3, array, num2, length); return array; } // Token: 0x0600B7F2 RID: 47090 RVA: 0x0028CFE8 File Offset: 0x0028B1E8 [Token(Token = "0x600B7F2")] [Address(RVA = "0x1DD3A10", Offset = "0x1DD2810", VA = "0x181DD3A10", Slot = "15")] public virtual byte[] AddCryptedBlocks(byte[] block1, byte[] block2) { if (!this.forEncryption) { } int inputBlockSize = this.GetInputBlockSize(); int inputBlockSize2 = this.GetInputBlockSize(); BigInteger bigInteger = new BigInteger(1, block1); BigInteger bigInteger2 = new BigInteger(1, block2); BigInteger bigInteger3 = bigInteger.Multiply(bigInteger2); BigInteger n = this.key.n; BigInteger bigInteger4 = bigInteger3.Mod(n); BigInteger n2 = this.key.n; int num = 0; int bitLength = n2.BitLength; num += bitLength; num++; byte[] array = new byte[num]; byte[] array2 = bigInteger4.ToByteArray(); int length = array2.Length; int num2 = array.Length; int num3 = 0; num2 -= length; Array.Copy(array2, num3, array, num2, length); return array; } // Token: 0x0600B7F3 RID: 47091 RVA: 0x0028D0A8 File Offset: 0x0028B2A8 [Token(Token = "0x600B7F3")] [Address(RVA = "0x1DD4900", Offset = "0x1DD3700", VA = "0x181DD4900", Slot = "16")] public virtual byte[] ProcessData(byte[] data) { /* An exception occurred when decompiling this method (0600B7F3) ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.NaccacheSternEngine::ProcessData(System.Byte[]) ---> System.Exception: Basic block has to end with unconditional control flow. { IL_7D: stloc:InvalidCipherTextException(var_13_87, newobj:InvalidCipherTextException(InvalidCipherTextException::.ctor, ldstr:string("cipher returned null"))) } 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.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: 0x0600B7F4 RID: 47092 RVA: 0x0028D140 File Offset: 0x0028B340 [Token(Token = "0x600B7F4")] [Address(RVA = "0x1DD4AE0", Offset = "0x1DD38E0", VA = "0x181DD4AE0")] private static BigInteger chineseRemainder(IList congruences, IList primes) { int num; BigInteger zero; BigInteger bigInteger; BigInteger bigInteger4; for (;;) { num = 0; zero = BigInteger.Zero; BigInteger one = BigInteger.One; num += num; num++; uint num2; if (num < (int)num2) { num += num; num++; } if (num == 0) { num += num; num++; num += 19; num += num; num += 19; } if (num != 0) { int num3 = 0; bigInteger = one.Multiply(num); num++; if (num < num3) { num += num; num++; } if (num >= num) { goto IL_EE; } uint num4; if (num < (int)num4) { num += num; num++; } if (num == 0) { num++; num += 19; num += 19; } if (num != 0) { BigInteger bigInteger2 = bigInteger.Divide(num); BigInteger bigInteger3 = bigInteger2.ModInverse(num); int num5 = 0; bigInteger4 = bigInteger2.Multiply(bigInteger3); if (num < num5) { num += num; num++; } if (num == 0) { num += num; num += 19; } if (num != 0) { break; } } } } BigInteger bigInteger5 = bigInteger4.Multiply(num); BigInteger bigInteger6 = zero.Add(bigInteger5); num++; IL_EE: return bigInteger6.Mod(bigInteger); } // Token: 0x0600B7F5 RID: 47093 RVA: 0x0028D24C File Offset: 0x0028B44C [Token(Token = "0x600B7F5")] [Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")] public NaccacheSternEngine() { int num = 0; this.Debug = num != 0; } // Token: 0x040074AB RID: 29867 [FieldOffset(Offset = "0x10")] [Token(Token = "0x40074AB")] private bool forEncryption; // Token: 0x040074AC RID: 29868 [FieldOffset(Offset = "0x18")] [Token(Token = "0x40074AC")] private NaccacheSternKeyParameters key; // Token: 0x040074AD RID: 29869 [FieldOffset(Offset = "0x20")] [Token(Token = "0x40074AD")] private IList[] lookup; } }