334 lines
13 KiB
C#
334 lines
13 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001D80 RID: 7552
|
|
[Token(Token = "0x2001D80")]
|
|
public class RC6Engine : IBlockCipher
|
|
{
|
|
// Token: 0x0600BC15 RID: 48149 RVA: 0x00298120 File Offset: 0x00296320
|
|
[Token(Token = "0x600BC15")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
public RC6Engine()
|
|
{
|
|
this.Reset();
|
|
}
|
|
|
|
// Token: 0x17001D80 RID: 7552
|
|
// (get) Token: 0x0600BC16 RID: 48150 RVA: 0x00298134 File Offset: 0x00296334
|
|
[Token(Token = "0x17001D80")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600BC16")]
|
|
[Address(RVA = "0x2731D20", Offset = "0x2730D20", VA = "0x182731D20", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC6";
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001D81 RID: 7553
|
|
// (get) Token: 0x0600BC17 RID: 48151 RVA: 0x00298148 File Offset: 0x00296348
|
|
[Token(Token = "0x17001D81")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x600BC17")]
|
|
[Address(RVA = "0x424690", Offset = "0x423690", VA = "0x180424690", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BC18 RID: 48152 RVA: 0x00298158 File Offset: 0x00296358
|
|
[Token(Token = "0x600BC18")]
|
|
[Address(RVA = "0x2731360", Offset = "0x2730360", VA = "0x182731360", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
return RC6Engine.bytesPerWord;
|
|
}
|
|
|
|
// Token: 0x0600BC19 RID: 48153 RVA: 0x0029816C File Offset: 0x0029636C
|
|
[Token(Token = "0x600BC19")]
|
|
[Address(RVA = "0x27313C0", Offset = "0x27303C0", VA = "0x1827313C0", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BC19)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC6Engine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_1F:
|
|
stloc:ArgumentException(var_4_2F, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to RC6 init - "), ldloc:string(var_3))))
|
|
}
|
|
|
|
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: 0x0600BC1A RID: 48154 RVA: 0x002981AC File Offset: 0x002963AC
|
|
[Token(Token = "0x600BC1A")]
|
|
[Address(RVA = "0x2731520", Offset = "0x2730520", VA = "0x182731520", Slot = "14")]
|
|
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BC1A)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC6Engine::ProcessBlock(System.Byte[],System.Int32,System.Byte[],System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_2C:
|
|
stloc:InvalidOperationException(var_4_36, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldstr:string("RC6 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.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: 0x0600BC1B RID: 48155 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600BC1B")]
|
|
[Address(RVA = "0x4242D0", Offset = "0x4232D0", VA = "0x1804242D0", Slot = "15")]
|
|
public virtual void Reset()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600BC1C RID: 48156 RVA: 0x002981F0 File Offset: 0x002963F0
|
|
[Token(Token = "0x600BC1C")]
|
|
[Address(RVA = "0x2731730", Offset = "0x2730730", VA = "0x182731730")]
|
|
private void SetKey(byte[] key)
|
|
{
|
|
int num = RC6Engine.bytesPerWord;
|
|
int num2 = key.Length;
|
|
num2 += num;
|
|
int[] array = new int[num2];
|
|
num2 = key.Length;
|
|
int num3 = array[num2];
|
|
byte b = (byte)((int)b + num3);
|
|
array[0] = (int)b;
|
|
int[] array2 = new int[RC6Engine._noRounds];
|
|
this._S = array2;
|
|
int p = RC6Engine.P32;
|
|
array2[0] = p;
|
|
int[] s = this._S;
|
|
uint num4;
|
|
int[] s2;
|
|
if (num4 < (uint)s.Length)
|
|
{
|
|
int length = s.Length;
|
|
uint num5 = num4 - 1U;
|
|
int num6 = s[(int)num5];
|
|
int length2 = s.Length;
|
|
num4 += (uint)1;
|
|
int num7 = RC6Engine.Q32;
|
|
num7 += num6;
|
|
s[0] = num7;
|
|
s2 = this._S;
|
|
}
|
|
int length3 = s2.Length;
|
|
if (array.Length > length3)
|
|
{
|
|
}
|
|
int num8 = 0;
|
|
if (s2 > 0)
|
|
{
|
|
int num9 = s2[num8];
|
|
num9 += num8;
|
|
num9 += num8;
|
|
int num10 = RC6Engine.wordSize;
|
|
int num11 = num10 - 1;
|
|
num10 -= num11;
|
|
s2[0] = num9;
|
|
int num12 = array[num8];
|
|
num12 += num9;
|
|
num12 += num8;
|
|
int num13 = RC6Engine.wordSize;
|
|
int num14 = num13 - 1;
|
|
num13 -= num14;
|
|
array[0] = num12;
|
|
num8++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BC1D RID: 48157 RVA: 0x00298350 File Offset: 0x00296550
|
|
[Token(Token = "0x600BC1D")]
|
|
[Address(RVA = "0x2730C50", Offset = "0x272FC50", VA = "0x182730C50")]
|
|
private int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
|
|
{
|
|
int num = this.BytesToWord(input, inOff);
|
|
int num2 = RC6Engine.bytesPerWord;
|
|
num2 += inOff;
|
|
int num3 = this.BytesToWord(input, num2);
|
|
int num4 = this.BytesToWord(input, num2);
|
|
int num5 = RC6Engine.bytesPerWord;
|
|
num5 += typeof(RC6Engine).TypeHandle;
|
|
int num6 = this.BytesToWord(input, num5);
|
|
int length = this._S.Length;
|
|
int num7 = RC6Engine.wordSize;
|
|
int num8 = num7 - 1;
|
|
num7 -= num8;
|
|
int num9 = RC6Engine.wordSize;
|
|
int num10 = num9 - 1;
|
|
num9 -= num10;
|
|
int[] s = this._S;
|
|
int num11 = RC6Engine.wordSize;
|
|
int num12 = num11 - 1;
|
|
num11 -= num12;
|
|
ulong num14;
|
|
ulong num13 = num14 + 1UL;
|
|
int num15 = RC6Engine.wordSize;
|
|
int num16 = num15 - 1;
|
|
num15 -= num16;
|
|
uint num17;
|
|
num17 += (uint)1;
|
|
int num18 = RC6Engine._noRounds;
|
|
num18 += num18;
|
|
num18 += 3;
|
|
num3 += num16;
|
|
int num19 = RC6Engine.bytesPerWord;
|
|
int num20 = 0;
|
|
int num21 = RC6Engine.bytesPerWord;
|
|
if (num20 < num21)
|
|
{
|
|
num20++;
|
|
}
|
|
int num22 = RC6Engine.bytesPerWord;
|
|
if (num20 < num22)
|
|
{
|
|
num20++;
|
|
}
|
|
int num23 = RC6Engine.bytesPerWord;
|
|
if (num20 < num23)
|
|
{
|
|
num20++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600BC1E RID: 48158 RVA: 0x00298488 File Offset: 0x00296688
|
|
[Token(Token = "0x600BC1E")]
|
|
[Address(RVA = "0x2730880", Offset = "0x272F880", VA = "0x182730880")]
|
|
private int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
|
|
{
|
|
int num = this.BytesToWord(input, inOff);
|
|
int num2 = RC6Engine.bytesPerWord;
|
|
num2 += inOff;
|
|
int num3 = this.BytesToWord(input, num2);
|
|
int num4 = this.BytesToWord(input, num2);
|
|
int num5 = RC6Engine.bytesPerWord;
|
|
num5 += typeof(RC6Engine).TypeHandle;
|
|
int num6 = this.BytesToWord(input, num5);
|
|
int length = this._S.Length;
|
|
int noRounds = RC6Engine._noRounds;
|
|
num6 = num4;
|
|
int num7 = num4 * num;
|
|
int lgw = RC6Engine.LGW;
|
|
num7 = this.RotateLeft(num7, lgw);
|
|
int num8 = RC6Engine.LGW;
|
|
int[] s = this._S;
|
|
int num9 = inOff + 1;
|
|
num8 = num7;
|
|
num7 = this.RotateRight(num3, num8);
|
|
int[] s2 = this._S;
|
|
num3 = num6;
|
|
int num10;
|
|
num = this.RotateRight(num3, num10);
|
|
int[] s3 = this._S;
|
|
int num11 = s3[0];
|
|
num -= num11;
|
|
int num12 = RC6Engine.bytesPerWord;
|
|
int num13 = RC6Engine.bytesPerWord;
|
|
num13 += typeof(RC6Engine).TypeHandle;
|
|
return RC6Engine.bytesPerWord;
|
|
}
|
|
|
|
// Token: 0x0600BC1F RID: 48159 RVA: 0x0029858C File Offset: 0x0029678C
|
|
[Token(Token = "0x600BC1F")]
|
|
[Address(RVA = "0x2731630", Offset = "0x2730630", VA = "0x182731630")]
|
|
private int RotateLeft(int x, int y)
|
|
{
|
|
int num = RC6Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600BC20 RID: 48160 RVA: 0x002985AC File Offset: 0x002967AC
|
|
[Token(Token = "0x600BC20")]
|
|
[Address(RVA = "0x27316B0", Offset = "0x27306B0", VA = "0x1827316B0")]
|
|
private int RotateRight(int x, int y)
|
|
{
|
|
int num = RC6Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600BC21 RID: 48161 RVA: 0x002985CC File Offset: 0x002967CC
|
|
[Token(Token = "0x600BC21")]
|
|
[Address(RVA = "0x27307C0", Offset = "0x272F7C0", VA = "0x1827307C0")]
|
|
private int BytesToWord(byte[] src, int srcOff)
|
|
{
|
|
int num = 0;
|
|
byte b = src[src];
|
|
return num + (int)b;
|
|
}
|
|
|
|
// Token: 0x0600BC22 RID: 48162 RVA: 0x002985F0 File Offset: 0x002967F0
|
|
[Token(Token = "0x600BC22")]
|
|
[Address(RVA = "0x2731BB0", Offset = "0x2730BB0", VA = "0x182731BB0")]
|
|
private void WordToBytes(int word, byte[] dst, int dstOff)
|
|
{
|
|
}
|
|
|
|
// Token: 0x0400768F RID: 30351
|
|
[Token(Token = "0x400768F")]
|
|
private static readonly int wordSize;
|
|
|
|
// Token: 0x04007690 RID: 30352
|
|
[Token(Token = "0x4007690")]
|
|
private static readonly int bytesPerWord = RC6Engine.wordSize;
|
|
|
|
// Token: 0x04007691 RID: 30353
|
|
[Token(Token = "0x4007691")]
|
|
private static readonly int _noRounds;
|
|
|
|
// Token: 0x04007692 RID: 30354
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4007692")]
|
|
private int[] _S;
|
|
|
|
// Token: 0x04007693 RID: 30355
|
|
[Token(Token = "0x4007693")]
|
|
private static readonly int P32;
|
|
|
|
// Token: 0x04007694 RID: 30356
|
|
[Token(Token = "0x4007694")]
|
|
private static readonly int Q32;
|
|
|
|
// Token: 0x04007695 RID: 30357
|
|
[Token(Token = "0x4007695")]
|
|
private static readonly int LGW;
|
|
|
|
// Token: 0x04007696 RID: 30358
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4007696")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|