Files
2026-04-08 23:40:05 +02:00

438 lines
14 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
{
// Token: 0x020016BE RID: 5822
[Token(Token = "0x20016BE")]
[StructLayout(3)]
public class RC2Engine : IBlockCipher
{
// Token: 0x06009C33 RID: 39987 RVA: 0x002361A0 File Offset: 0x002343A0
[Token(Token = "0x6009C33")]
[Address(RVA = "0x2129B10", Offset = "0x2128510", VA = "0x182129B10")]
private int[] GenerateWorkingKey(byte[] key, int bits)
{
int[] array = new int[128];
int num = 0;
int num2 = key.Length;
if (num != num2)
{
num++;
byte b;
array[0] = (int)b;
}
uint num3;
if (num2 < (int)num3)
{
int num4 = num2 - 1;
int num5 = array[num4];
int length = array.Length;
byte[] array2 = RC2Engine.piTable;
num++;
int num6 = array[num];
num6 += num5;
num2++;
byte b2;
array[0] = (int)b2;
}
byte[] array3 = RC2Engine.piTable;
num3 -= (uint)num;
byte b3;
array[0] = (int)b3;
uint num7;
num7 -= (uint)num;
int length2 = array.Length;
byte[] array4 = RC2Engine.piTable;
int num8 = array[(int)num7];
byte b4;
array[0] = (int)b4;
int[] array5 = new int[64];
int length3 = array5.Length;
if (num != length3)
{
int length4 = array.Length;
num++;
num += 2;
int num9;
array5[0] = num9;
}
return array5;
}
// Token: 0x06009C34 RID: 39988 RVA: 0x00236290 File Offset: 0x00234490
[Token(Token = "0x6009C34")]
[Address(RVA = "0x2129EF0", Offset = "0x21288F0", VA = "0x182129EF0", Slot = "10")]
public virtual void Init(bool forEncryption, ICipherParameters parameters)
{
/*
An exception occurred when decompiling this method (06009C34)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC2Engine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_56:
stloc:ArgumentException(var_12_67, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to RC2 init - "), ldloc:string(var_11))))
}
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: 0x06009C35 RID: 39989 RVA: 0x0000220F File Offset: 0x0000040F
[Token(Token = "0x6009C35")]
[Address(RVA = "0x3C9F60", Offset = "0x3C8960", VA = "0x1803C9F60", Slot = "11")]
public virtual void Reset()
{
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
}
// Token: 0x170018DA RID: 6362
// (get) Token: 0x06009C36 RID: 39990 RVA: 0x00236308 File Offset: 0x00234508
[Token(Token = "0x170018DA")]
public virtual string AlgorithmName
{
[Token(Token = "0x6009C36")]
[Address(RVA = "0x212A2B0", Offset = "0x2128CB0", VA = "0x18212A2B0", Slot = "12")]
get
{
return "RC2";
}
}
// Token: 0x170018DB RID: 6363
// (get) Token: 0x06009C37 RID: 39991 RVA: 0x0023631C File Offset: 0x0023451C
[Token(Token = "0x170018DB")]
public virtual bool IsPartialBlockOkay
{
[Token(Token = "0x6009C37")]
[Address(RVA = "0x413970", Offset = "0x412370", VA = "0x180413970", Slot = "13")]
get
{
}
}
// Token: 0x06009C38 RID: 39992 RVA: 0x0023632C File Offset: 0x0023452C
[Token(Token = "0x6009C38")]
[Address(RVA = "0x56E570", Offset = "0x56CF70", VA = "0x18056E570", Slot = "14")]
public virtual int GetBlockSize()
{
return 8;
}
// Token: 0x06009C39 RID: 39993 RVA: 0x0023633C File Offset: 0x0023453C
[Token(Token = "0x6009C39")]
[Address(RVA = "0x212A120", Offset = "0x2128B20", VA = "0x18212A120", Slot = "15")]
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
{
/*
An exception occurred when decompiling this method (06009C39)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC2Engine::ProcessBlock(System.Byte[],System.Int32,System.Byte[],System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_25:
stloc:InvalidOperationException(var_1_2F, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("RC2 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: 0x06009C3A RID: 39994 RVA: 0x00236378 File Offset: 0x00234578
[Token(Token = "0x6009C3A")]
[Address(RVA = "0x212A220", Offset = "0x2128C20", VA = "0x18212A220")]
private int RotateWordLeft(int x, int y)
{
uint num;
num -= (uint)y;
return x;
}
// Token: 0x06009C3B RID: 39995 RVA: 0x0023638C File Offset: 0x0023458C
[Token(Token = "0x6009C3B")]
[Address(RVA = "0x2129300", Offset = "0x2127D00", VA = "0x182129300")]
private void EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
{
int length = input.Length;
byte b;
byte b2;
b += b2;
byte b3;
b3 += b2;
byte b4;
b4 += b2;
int num = inOff + 1;
int[] array = this.workingKey;
byte b5;
byte b6;
b5 += b6;
int i = 0;
int length2 = array.Length;
b6 = b;
int num2 = array[i];
num2 += (int)b6;
b6 = b3;
num2 += (int)b5;
b6 = (byte)((int)b6 + num2);
b5 = b6;
b6 += b6;
b6 = b5;
int num3;
num3 += (int)b6;
b6 = b5;
num3 += (int)b4;
b6 = (byte)((int)b6 + num3);
b4 = b6;
b6 = b4;
int num4;
num4 += (int)b6;
b6 = b5;
num4 += (int)b3;
b6 = (byte)((int)b6 + num4);
b3 = b6;
i += 3;
int num5 = array[i];
b6 = b3;
i += 4;
num5 += (int)b6;
b6 = b4;
num5 += (int)b;
b6 = (byte)((int)b6 + num5);
b = b6;
while (i <= 16)
{
}
b6 = b;
int num6 = array[(int)b6];
num6 += (int)b5;
b4 = b3;
b6 = b;
uint num8;
int num7 = array[(int)num8];
num7 += (int)b6;
b6 = b3;
num7 += num6;
b6 = (byte)((int)b6 + num7);
b5 = b6;
b6 += b6;
uint num9 = num8 + 1U;
int num10 = array[(int)num9];
b6 = b5;
num10 += (int)b6;
b6 = b;
num10 += (int)b4;
b6 = (byte)((int)b6 + num10);
b4 = b6;
int num11 = array[(int)b6];
b6 = b4;
num11 += (int)b6;
b6 = b4;
num11 += (int)b3;
b6 = (byte)((int)b6 + num11);
b3 = b6;
num8 += (uint)3;
int num12 = array[(int)num8];
b6 = b3;
num8 += (uint)4;
num12 += (int)b6;
b6 = b4;
num12 += (int)b;
b6 = (byte)((int)b6 + num12);
b = b6;
b6 = b;
while (num8 <= (uint)40)
{
}
int num13 = array[(int)b6];
num13 += (int)b5;
b4 = b3;
b6 = b;
uint num15;
int num14 = array[(int)num15];
num14 += (int)b6;
b6 = b3;
num14 += num13;
b6 = (byte)((int)b6 + num14);
b5 = b6;
b6 += b6;
uint num16 = num15 + 1U;
int num17 = array[(int)num16];
b6 = b5;
num17 += (int)b6;
b6 = b;
num17 += (int)b4;
b6 = (byte)((int)b6 + num17);
b4 = b6;
int num18 = array[(int)b6];
b6 = b4;
num18 += (int)b6;
b6 = b5;
num18 += (int)b3;
b6 = (byte)((int)b6 + num18);
b3 = b6;
num15 += (uint)3;
int num19 = array[(int)num15];
b6 = b3;
num15 += (uint)4;
num19 += (int)b6;
b6 = b4;
num19 += (int)b;
b6 = (byte)((int)b6 + num19);
b = b6;
}
// Token: 0x06009C3C RID: 39996 RVA: 0x00236640 File Offset: 0x00234840
[Token(Token = "0x6009C3C")]
[Address(RVA = "0x2128B30", Offset = "0x2127530", VA = "0x182128B30")]
private void DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
{
int length = input.Length;
byte b;
byte b2;
b += b2;
byte b3;
b3 += b2;
byte b4;
b4 += b2;
int num = inOff + 1;
int[] array = this.workingKey;
byte b5;
byte b6;
b5 += b6;
int length2 = array.Length;
b = b3;
b6 = b3;
b -= b6;
b6 = b4;
b -= b6;
b3 = b;
b = b4;
b6 = b4;
b3 -= b6;
b6 = b4;
b3 -= b6;
uint num3;
uint num2 = num3 + 1U;
b4 = b;
b4 -= b5;
b5 = b;
b4 -= b5;
b5 = b;
b5 -= b5;
b5 = b3;
b5 -= b5;
while (num3 >= (uint)44)
{
}
b5 = b3;
b5 = b4;
b5 = b;
b = b3;
b5 = b3;
b -= b5;
b5 = b4;
b -= b5;
b3 = b;
b = b4;
b5 = b4;
b3 -= b5;
b5 = b4;
b3 -= b5;
uint num5;
uint num4 = num5 + 1U;
b4 = b;
b4 -= b5;
b5 = b;
b4 -= b5;
b5 = b;
b5 -= b5;
b5 = b3;
b5 -= b5;
while (num5 >= (uint)20)
{
}
b5 = b3;
b5 = b4;
b5 = b;
b = b3;
b5 = b3;
b -= b5;
b5 = b4;
b -= b5;
b3 = b;
b = b4;
b5 = b4;
b3 -= b5;
b3 -= b5;
uint num7;
uint num6 = num7 + 1U;
b4 = b;
b4 -= b5;
b5 = b;
b4 -= b5;
b5 = b;
b5 -= b5;
b5 = b3;
b5 -= b5;
array[0] = (int)b5;
}
// Token: 0x06009C3D RID: 39997 RVA: 0x002367B8 File Offset: 0x002349B8
[Token(Token = "0x6009C3D")]
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
public RC2Engine()
{
this.Reset();
}
// Token: 0x06009C3E RID: 39998 RVA: 0x002367CC File Offset: 0x002349CC
// Note: this type is marked as 'beforefieldinit'.
[Token(Token = "0x6009C3E")]
[Address(RVA = "0x212A250", Offset = "0x2128C50", VA = "0x18212A250")]
static RC2Engine()
{
byte[] array = new byte[256];
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.0392525BCB01691D1F319D89F2C12BF93A478467).FieldHandle);
RC2Engine.piTable = array;
}
// Token: 0x04006675 RID: 26229
[Token(Token = "0x4006675")]
private static readonly byte[] piTable;
// Token: 0x04006676 RID: 26230
[Token(Token = "0x4006676")]
private const int BLOCK_SIZE = 8;
// Token: 0x04006677 RID: 26231
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006677")]
private int[] workingKey;
// Token: 0x04006678 RID: 26232
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x4006678")]
private bool encrypting;
}
}