Files
Jan2021-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Engines/IdeaEngine.cs
T
2026-04-08 23:40:05 +02:00

364 lines
14 KiB
C#

using System;
using System.Runtime.InteropServices;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
{
// Token: 0x020016B9 RID: 5817
[Token(Token = "0x20016B9")]
[StructLayout(3)]
public class IdeaEngine : IBlockCipher
{
// Token: 0x06009BF9 RID: 39929 RVA: 0x00234D40 File Offset: 0x00232F40
[Token(Token = "0x6009BF9")]
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
public IdeaEngine()
{
this.Reset();
}
// Token: 0x06009BFA RID: 39930 RVA: 0x00234D54 File Offset: 0x00232F54
[Token(Token = "0x6009BFA")]
[Address(RVA = "0x2123440", Offset = "0x2121E40", VA = "0x182123440", Slot = "10")]
public virtual void Init(bool forEncryption, ICipherParameters parameters)
{
/*
An exception occurred when decompiling this method (06009BFA)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.IdeaEngine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_36:
stloc:ArgumentException(var_7_47, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to IDEA init - "), ldloc:string(var_6))))
}
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: 0x170018D2 RID: 6354
// (get) Token: 0x06009BFB RID: 39931 RVA: 0x00234DAC File Offset: 0x00232FAC
[Token(Token = "0x170018D2")]
public virtual string AlgorithmName
{
[Token(Token = "0x6009BFB")]
[Address(RVA = "0x21241B0", Offset = "0x2122BB0", VA = "0x1821241B0", Slot = "11")]
get
{
return "IDEA";
}
}
// Token: 0x170018D3 RID: 6355
// (get) Token: 0x06009BFC RID: 39932 RVA: 0x00234DC0 File Offset: 0x00232FC0
[Token(Token = "0x170018D3")]
public virtual bool IsPartialBlockOkay
{
[Token(Token = "0x6009BFC")]
[Address(RVA = "0x413970", Offset = "0x412370", VA = "0x180413970", Slot = "12")]
get
{
}
}
// Token: 0x06009BFD RID: 39933 RVA: 0x00234DD0 File Offset: 0x00232FD0
[Token(Token = "0x6009BFD")]
[Address(RVA = "0x56E570", Offset = "0x56CF70", VA = "0x18056E570", Slot = "13")]
public virtual int GetBlockSize()
{
return 8;
}
// Token: 0x06009BFE RID: 39934 RVA: 0x00234DE0 File Offset: 0x00232FE0
[Token(Token = "0x6009BFE")]
[Address(RVA = "0x2123FF0", Offset = "0x21229F0", VA = "0x182123FF0", Slot = "14")]
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
{
/*
An exception occurred when decompiling this method (06009BFE)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.IdeaEngine::ProcessBlock(System.Byte[],System.Int32,System.Byte[],System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_1A:
stloc:InvalidOperationException(var_3_24, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("IDEA engine not initialised")))
}
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: 0x06009BFF RID: 39935 RVA: 0x0000220F File Offset: 0x0000040F
[Token(Token = "0x6009BFF")]
[Address(RVA = "0x3C9F60", Offset = "0x3C8960", VA = "0x1803C9F60", Slot = "15")]
public virtual void Reset()
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
// Token: 0x06009C00 RID: 39936 RVA: 0x00234E14 File Offset: 0x00233014
[Token(Token = "0x6009C00")]
[Address(RVA = "0x2122B40", Offset = "0x2121540", VA = "0x182122B40")]
private int BytesToWord(byte[] input, int inOff)
{
int length = input.Length;
byte b;
byte b2;
b += b2;
throw new NullReferenceException();
}
// Token: 0x06009C01 RID: 39937 RVA: 0x00234E34 File Offset: 0x00233034
[Token(Token = "0x6009C01")]
[Address(RVA = "0x2124100", Offset = "0x2122B00", VA = "0x182124100")]
private void WordToBytes(int word, byte[] outBytes, int outOff)
{
}
// Token: 0x06009C02 RID: 39938 RVA: 0x00234E48 File Offset: 0x00233048
[Token(Token = "0x6009C02")]
[Address(RVA = "0x2123ED0", Offset = "0x21228D0", VA = "0x182123ED0")]
private int Mul(int x, int y)
{
if (x != 0)
{
if (y != 0)
{
int num = x * y;
int mask = IdeaEngine.MASK;
bool flag = mask < num;
flag = (flag ? 1 : 0) - num != 0;
flag = (flag ? 1 : 0) + mask != 0;
}
int num2 = IdeaEngine.BASE;
num2 -= x;
}
int num3 = IdeaEngine.BASE;
num3 -= y;
return IdeaEngine.MASK;
}
// Token: 0x06009C03 RID: 39939 RVA: 0x00234E90 File Offset: 0x00233090
[Token(Token = "0x6009C03")]
[Address(RVA = "0x2122F00", Offset = "0x2121900", VA = "0x182122F00")]
private void IdeaFunc(int[] workingKey, byte[] input, int inOff, byte[] outBytes, int outOff)
{
int num = 0;
int length = input.Length;
int num2 = inOff + 1;
byte b;
byte b2;
b += b2;
byte b3;
b3 += b2;
byte b4;
b4 += b2;
byte b5;
b5 += b2;
int num3 = workingKey[num];
int num4 = this.Mul((int)b, num3);
int length2 = workingKey.Length;
int num5;
num5 += (int)b3;
int length3 = workingKey.Length;
int num6;
num6 += (int)b4;
num += 3;
int num7 = workingKey[num];
num += 4;
int num8 = workingKey[num];
int num9;
num6 = num9;
int num10;
num6 += num10;
num++;
int mask = IdeaEngine.MASK;
int num11 = workingKey[num];
int num12;
num12 += mask;
int num13;
int num14;
num13 += num14;
num += 3;
int num15 = workingKey[num];
}
// Token: 0x06009C04 RID: 39940 RVA: 0x00234F58 File Offset: 0x00233158
[Token(Token = "0x6009C04")]
[Address(RVA = "0x2122BA0", Offset = "0x21215A0", VA = "0x182122BA0")]
private int[] ExpandKey(byte[] uKey)
{
int[] array = new int[52];
int num = 0;
if (uKey.Length < 16)
{
byte[] array2 = new byte[0];
int length = uKey.Length;
int num2 = array2.Length;
int num3 = 0;
num2 -= length;
Array.Copy(uKey, num3, array2, num2, length);
}
int length2 = uKey.Length;
num += 2;
byte b;
byte b2;
b += b2;
num++;
array[0] = (int)b;
int length3 = array.Length;
uint num4;
if (num4 != (uint)6)
{
int length4 = array.Length;
}
int length5 = array.Length;
int length6 = array.Length;
num4 += (uint)1;
int num5;
array[0] = num5;
return array;
}
// Token: 0x06009C05 RID: 39941 RVA: 0x00235004 File Offset: 0x00233204
[Token(Token = "0x6009C05")]
[Address(RVA = "0x2123D50", Offset = "0x2122750", VA = "0x182123D50")]
private int MulInv(int x)
{
int num = IdeaEngine.BASE;
uint num2;
if (x != (int)num2)
{
int num3 = x * x;
num2 += (uint)num3;
if (x == (int)num2)
{
return x;
}
int num4 = x * (int)num2;
num = x + num4;
}
num2 -= (uint)num;
return IdeaEngine.MASK;
}
// Token: 0x06009C06 RID: 39942 RVA: 0x00235044 File Offset: 0x00233244
[Token(Token = "0x6009C06")]
[Address(RVA = "0x2122AE0", Offset = "0x21214E0", VA = "0x182122AE0")]
private int AddInv(int x)
{
return IdeaEngine.MASK;
}
// Token: 0x06009C07 RID: 39943 RVA: 0x00235058 File Offset: 0x00233258
[Token(Token = "0x6009C07")]
[Address(RVA = "0x21235F0", Offset = "0x2121FF0", VA = "0x1821235F0")]
private int[] InvertKey(int[] inKey)
{
int[] array = new int[52];
int num = inKey[0];
int num2 = this.MulInv(num);
int mask = IdeaEngine.MASK;
int num3 = inKey[1];
int num4 = inKey[1];
int num5 = this.MulInv(num4);
array[25] = num5;
array[25] = num3;
array[24] = mask;
array[24] = num2;
int length = inKey.Length;
uint num7;
int num6 = inKey[(int)num7];
uint num8 = num7 + 1U;
uint num10;
uint num9 = num10 - 1U;
int num11 = inKey[(int)num8];
array[0] = num11;
num7 += (uint)2;
array[0] = num6;
int num12 = inKey[(int)num7];
int num13 = this.MulInv(num12);
num7 += (uint)3;
uint num14 = num7 + 1U;
int mask2 = IdeaEngine.MASK;
uint num15 = num14 + 1U;
int num16 = inKey[(int)num14];
num15 += (uint)1;
int num17 = inKey[(int)num15];
int num18;
array[0] = num18;
array[0] = mask2;
array[0] = num16;
ulong num19;
num19 += (ulong)1L;
array[0] = num13;
int length2 = inKey.Length;
int num20 = inKey[(int)num15];
uint num21 = num15 + 1U;
int num22 = inKey[(int)num21];
int num23 = num16 - 1;
array[0] = num22;
array[0] = num20;
int num24 = inKey[num23];
num15 += (uint)4;
int mask3 = IdeaEngine.MASK;
int num25 = inKey[(int)num15];
num16 += -4;
int num26;
array[0] = num26;
array[0] = num25;
array[0] = mask3;
int num27;
array[0] = num27;
return array;
}
// Token: 0x06009C08 RID: 39944 RVA: 0x0023520C File Offset: 0x0023340C
[Token(Token = "0x6009C08")]
[Address(RVA = "0x2122EC0", Offset = "0x21218C0", VA = "0x182122EC0")]
private int[] GenerateWorkingKey(bool forEncryption, byte[] userKey)
{
int[] array = this.ExpandKey(userKey);
if (!forEncryption)
{
int[] array2 = this.InvertKey(array);
}
return array;
}
// Token: 0x0400665B RID: 26203
[Token(Token = "0x400665B")]
private const int BLOCK_SIZE = 8;
// Token: 0x0400665C RID: 26204
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x400665C")]
private int[] workingKey;
// Token: 0x0400665D RID: 26205
[Token(Token = "0x400665D")]
private static readonly int MASK;
// Token: 0x0400665E RID: 26206
[Token(Token = "0x400665E")]
private static readonly int BASE;
}
}