334 lines
13 KiB
C#
334 lines
13 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001CA0 RID: 7328
|
|
[Token(Token = "0x2001CA0")]
|
|
public class RC6Engine : IBlockCipher
|
|
{
|
|
// Token: 0x0600B847 RID: 47175 RVA: 0x0028F00C File Offset: 0x0028D20C
|
|
[Token(Token = "0x600B847")]
|
|
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
|
|
public RC6Engine()
|
|
{
|
|
this.Reset();
|
|
}
|
|
|
|
// Token: 0x17001CE3 RID: 7395
|
|
// (get) Token: 0x0600B848 RID: 47176 RVA: 0x0028F020 File Offset: 0x0028D220
|
|
[Token(Token = "0x17001CE3")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B848")]
|
|
[Address(RVA = "0x1DF4FC0", Offset = "0x1DF3DC0", VA = "0x181DF4FC0", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC6";
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001CE4 RID: 7396
|
|
// (get) Token: 0x0600B849 RID: 47177 RVA: 0x0028F034 File Offset: 0x0028D234
|
|
[Token(Token = "0x17001CE4")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x600B849")]
|
|
[Address(RVA = "0x403930", Offset = "0x402730", VA = "0x180403930", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B84A RID: 47178 RVA: 0x0028F044 File Offset: 0x0028D244
|
|
[Token(Token = "0x600B84A")]
|
|
[Address(RVA = "0x1DF4600", Offset = "0x1DF3400", VA = "0x181DF4600", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
return RC6Engine.bytesPerWord;
|
|
}
|
|
|
|
// Token: 0x0600B84B RID: 47179 RVA: 0x0028F058 File Offset: 0x0028D258
|
|
[Token(Token = "0x600B84B")]
|
|
[Address(RVA = "0x1DF4660", Offset = "0x1DF3460", VA = "0x181DF4660", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B84B)
|
|
|
|
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: 0x0600B84C RID: 47180 RVA: 0x0028F098 File Offset: 0x0028D298
|
|
[Token(Token = "0x600B84C")]
|
|
[Address(RVA = "0x1DF47C0", Offset = "0x1DF35C0", VA = "0x181DF47C0", Slot = "14")]
|
|
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B84C)
|
|
|
|
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: 0x0600B84D RID: 47181 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600B84D")]
|
|
[Address(RVA = "0x402080", Offset = "0x400E80", VA = "0x180402080", Slot = "15")]
|
|
public virtual void Reset()
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600B84E RID: 47182 RVA: 0x0028F0DC File Offset: 0x0028D2DC
|
|
[Token(Token = "0x600B84E")]
|
|
[Address(RVA = "0x1DF49D0", Offset = "0x1DF37D0", VA = "0x181DF49D0")]
|
|
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: 0x0600B84F RID: 47183 RVA: 0x0028F23C File Offset: 0x0028D43C
|
|
[Token(Token = "0x600B84F")]
|
|
[Address(RVA = "0x1DF3EF0", Offset = "0x1DF2CF0", VA = "0x181DF3EF0")]
|
|
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: 0x0600B850 RID: 47184 RVA: 0x0028F374 File Offset: 0x0028D574
|
|
[Token(Token = "0x600B850")]
|
|
[Address(RVA = "0x1DF3B20", Offset = "0x1DF2920", VA = "0x181DF3B20")]
|
|
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: 0x0600B851 RID: 47185 RVA: 0x0028F478 File Offset: 0x0028D678
|
|
[Token(Token = "0x600B851")]
|
|
[Address(RVA = "0x1DF48D0", Offset = "0x1DF36D0", VA = "0x181DF48D0")]
|
|
private int RotateLeft(int x, int y)
|
|
{
|
|
int num = RC6Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600B852 RID: 47186 RVA: 0x0028F498 File Offset: 0x0028D698
|
|
[Token(Token = "0x600B852")]
|
|
[Address(RVA = "0x1DF4950", Offset = "0x1DF3750", VA = "0x181DF4950")]
|
|
private int RotateRight(int x, int y)
|
|
{
|
|
int num = RC6Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600B853 RID: 47187 RVA: 0x0028F4B8 File Offset: 0x0028D6B8
|
|
[Token(Token = "0x600B853")]
|
|
[Address(RVA = "0x1DF3A60", Offset = "0x1DF2860", VA = "0x181DF3A60")]
|
|
private int BytesToWord(byte[] src, int srcOff)
|
|
{
|
|
int num = 0;
|
|
byte b = src[src];
|
|
return num + (int)b;
|
|
}
|
|
|
|
// Token: 0x0600B854 RID: 47188 RVA: 0x0028F4DC File Offset: 0x0028D6DC
|
|
[Token(Token = "0x600B854")]
|
|
[Address(RVA = "0x1DF4E50", Offset = "0x1DF3C50", VA = "0x181DF4E50")]
|
|
private void WordToBytes(int word, byte[] dst, int dstOff)
|
|
{
|
|
}
|
|
|
|
// Token: 0x040074D6 RID: 29910
|
|
[Token(Token = "0x40074D6")]
|
|
private static readonly int wordSize;
|
|
|
|
// Token: 0x040074D7 RID: 29911
|
|
[Token(Token = "0x40074D7")]
|
|
private static readonly int bytesPerWord = RC6Engine.wordSize;
|
|
|
|
// Token: 0x040074D8 RID: 29912
|
|
[Token(Token = "0x40074D8")]
|
|
private static readonly int _noRounds;
|
|
|
|
// Token: 0x040074D9 RID: 29913
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40074D9")]
|
|
private int[] _S;
|
|
|
|
// Token: 0x040074DA RID: 29914
|
|
[Token(Token = "0x40074DA")]
|
|
private static readonly int P32;
|
|
|
|
// Token: 0x040074DB RID: 29915
|
|
[Token(Token = "0x40074DB")]
|
|
private static readonly int Q32;
|
|
|
|
// Token: 0x040074DC RID: 29916
|
|
[Token(Token = "0x40074DC")]
|
|
private static readonly int LGW;
|
|
|
|
// Token: 0x040074DD RID: 29917
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40074DD")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|