311 lines
10 KiB
C#
311 lines
10 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001D7F RID: 7551
|
|
[Token(Token = "0x2001D7F")]
|
|
public class RC564Engine : IBlockCipher
|
|
{
|
|
// Token: 0x0600BC06 RID: 48134 RVA: 0x00297CE0 File Offset: 0x00295EE0
|
|
[Token(Token = "0x600BC06")]
|
|
[Address(RVA = "0x272F6F0", Offset = "0x272E6F0", VA = "0x18272F6F0")]
|
|
public RC564Engine()
|
|
{
|
|
this.Reset();
|
|
this._noRounds = (int)((ulong)12L);
|
|
}
|
|
|
|
// Token: 0x17001D7E RID: 7550
|
|
// (get) Token: 0x0600BC07 RID: 48135 RVA: 0x00297D00 File Offset: 0x00295F00
|
|
[Token(Token = "0x17001D7E")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600BC07")]
|
|
[Address(RVA = "0x2730790", Offset = "0x272F790", VA = "0x182730790", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC5-64";
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001D7F RID: 7551
|
|
// (get) Token: 0x0600BC08 RID: 48136 RVA: 0x00297D14 File Offset: 0x00295F14
|
|
[Token(Token = "0x17001D7F")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x600BC08")]
|
|
[Address(RVA = "0x424690", Offset = "0x423690", VA = "0x180424690", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BC09 RID: 48137 RVA: 0x00297D24 File Offset: 0x00295F24
|
|
[Token(Token = "0x600BC09")]
|
|
[Address(RVA = "0x272FE70", Offset = "0x272EE70", VA = "0x18272FE70", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
int num = RC564Engine.bytesPerWord;
|
|
return num + num;
|
|
}
|
|
|
|
// Token: 0x0600BC0A RID: 48138 RVA: 0x00297D3C File Offset: 0x00295F3C
|
|
[Token(Token = "0x600BC0A")]
|
|
[Address(RVA = "0x272FED0", Offset = "0x272EED0", VA = "0x18272FED0", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BC0A)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.RC564Engine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_35:
|
|
stloc:ArgumentException(var_5_46, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to RC564 init - "), ldloc:string(var_4))))
|
|
}
|
|
|
|
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: 0x0600BC0B RID: 48139 RVA: 0x00297D90 File Offset: 0x00295F90
|
|
[Token(Token = "0x600BC0B")]
|
|
[Address(RVA = "0x2730060", Offset = "0x272F060", VA = "0x182730060", Slot = "14")]
|
|
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
if (this.forEncryption)
|
|
{
|
|
int num;
|
|
return num;
|
|
}
|
|
int num2;
|
|
return num2;
|
|
}
|
|
|
|
// Token: 0x0600BC0C RID: 48140 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600BC0C")]
|
|
[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: 0x0600BC0D RID: 48141 RVA: 0x00297DAC File Offset: 0x00295FAC
|
|
[Token(Token = "0x600BC0D")]
|
|
[Address(RVA = "0x27301B0", Offset = "0x272F1B0", VA = "0x1827301B0")]
|
|
private void SetKey(byte[] key)
|
|
{
|
|
int num = RC564Engine.bytesPerWord;
|
|
int num2 = key.Length;
|
|
num2 += num;
|
|
long[] array = new long[num2];
|
|
int num3 = 0;
|
|
if (num3 != key.Length)
|
|
{
|
|
num3++;
|
|
}
|
|
long[] array2 = new long[this._noRounds];
|
|
this._S = array2;
|
|
long p = RC564Engine.P64;
|
|
array2[0] = p;
|
|
long[] s = this._S;
|
|
uint num4;
|
|
long[] s2;
|
|
if (num4 < (uint)s.Length)
|
|
{
|
|
int length = s.Length;
|
|
uint num5 = num4 - 1U;
|
|
long num6 = s[(int)num5];
|
|
int length2 = s.Length;
|
|
num4 += (uint)1;
|
|
long num7 = RC564Engine.Q64;
|
|
num7 += num6;
|
|
s[0] = num7;
|
|
s2 = this._S;
|
|
}
|
|
int length3 = s2.Length;
|
|
if (array.Length > length3)
|
|
{
|
|
}
|
|
if (s2 > 0)
|
|
{
|
|
long num8 = s2[num3];
|
|
num8 += (long)num3;
|
|
num8 += (long)num3;
|
|
int num9 = RC564Engine.wordSize;
|
|
int num10 = num9 - 1;
|
|
num9 -= num10;
|
|
s2[0] = num8;
|
|
long num11 = array[num3];
|
|
num11 += num8;
|
|
num11 += (long)num3;
|
|
int num12 = RC564Engine.wordSize;
|
|
int num13 = num12 - 1;
|
|
num12 -= num13;
|
|
array[0] = num11;
|
|
num3++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BC0E RID: 48142 RVA: 0x00297EF8 File Offset: 0x002960F8
|
|
[Token(Token = "0x600BC0E")]
|
|
[Address(RVA = "0x272FAF0", Offset = "0x272EAF0", VA = "0x18272FAF0")]
|
|
private int EncryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
|
|
{
|
|
long num = this.BytesToWord(input, inOff);
|
|
long num2 = this._S[0];
|
|
num2 += num;
|
|
int num3 = RC564Engine.bytesPerWord;
|
|
num3 += inOff;
|
|
long num4 = this.BytesToWord(input, num3);
|
|
long num5 = this._S[1];
|
|
num5 += num4;
|
|
uint num7;
|
|
uint num6 = num7 + 1U;
|
|
long[] s = this._S;
|
|
int num8 = RC564Engine.wordSize;
|
|
int num9 = num8 - 1;
|
|
num8 -= num9;
|
|
long[] s2 = this._S;
|
|
uint num10 = num6 + 1U;
|
|
num7 += (uint)1;
|
|
num6 += (uint)2;
|
|
int num11 = RC564Engine.wordSize;
|
|
int num12 = num11 - 1;
|
|
num11 -= num12;
|
|
while (num7 <= (uint)this._noRounds)
|
|
{
|
|
}
|
|
int num13 = 0;
|
|
int num14 = RC564Engine.bytesPerWord;
|
|
if (num13 < num14)
|
|
{
|
|
num13++;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// Token: 0x0600BC0F RID: 48143 RVA: 0x00297FCC File Offset: 0x002961CC
|
|
[Token(Token = "0x600BC0F")]
|
|
[Address(RVA = "0x272F800", Offset = "0x272E800", VA = "0x18272F800")]
|
|
private int DecryptBlock(byte[] input, int inOff, byte[] outBytes, int outOff)
|
|
{
|
|
long num = this.BytesToWord(input, inOff);
|
|
int num2 = RC564Engine.bytesPerWord;
|
|
num2 += inOff;
|
|
long num3 = this.BytesToWord(input, num2);
|
|
int i = this._noRounds;
|
|
long[] s = this._S;
|
|
int num4 = RC564Engine.wordSize;
|
|
int num5 = num4 - 1;
|
|
num4 -= num5;
|
|
long[] s2 = this._S;
|
|
int num6 = RC564Engine.wordSize;
|
|
int num7 = num6 - 1;
|
|
num6 -= num7;
|
|
while (i >= 1)
|
|
{
|
|
}
|
|
long[] s3 = this._S;
|
|
long num8 = this._S[1];
|
|
num3 -= num8;
|
|
num = num3;
|
|
int num9 = RC564Engine.bytesPerWord;
|
|
this.WordToBytes(num, outBytes, num9);
|
|
int num10 = RC564Engine.bytesPerWord;
|
|
return num10 + num10;
|
|
}
|
|
|
|
// Token: 0x0600BC10 RID: 48144 RVA: 0x00298088 File Offset: 0x00296288
|
|
[Token(Token = "0x600BC10")]
|
|
[Address(RVA = "0x2730090", Offset = "0x272F090", VA = "0x182730090")]
|
|
private long RotateLeft(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600BC11 RID: 48145 RVA: 0x002980A8 File Offset: 0x002962A8
|
|
[Token(Token = "0x600BC11")]
|
|
[Address(RVA = "0x2730120", Offset = "0x272F120", VA = "0x182730120")]
|
|
private long RotateRight(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600BC12 RID: 48146 RVA: 0x002980C8 File Offset: 0x002962C8
|
|
[Token(Token = "0x600BC12")]
|
|
[Address(RVA = "0x272F740", Offset = "0x272E740", VA = "0x18272F740")]
|
|
private long BytesToWord(byte[] src, int srcOff)
|
|
{
|
|
int num = 0;
|
|
byte b = src[src];
|
|
num += (int)b;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600BC13 RID: 48147 RVA: 0x002980E8 File Offset: 0x002962E8
|
|
[Token(Token = "0x600BC13")]
|
|
[Address(RVA = "0x2730640", Offset = "0x272F640", VA = "0x182730640")]
|
|
private void WordToBytes(long word, byte[] dst, int dstOff)
|
|
{
|
|
}
|
|
|
|
// Token: 0x0600BC14 RID: 48148 RVA: 0x002980FC File Offset: 0x002962FC
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600BC14")]
|
|
[Address(RVA = "0x2730700", Offset = "0x272F700", VA = "0x182730700")]
|
|
static RC564Engine()
|
|
{
|
|
ulong num;
|
|
RC564Engine.P64 = (long)num;
|
|
ulong num2;
|
|
RC564Engine.Q64 = (long)num2;
|
|
}
|
|
|
|
// Token: 0x04007688 RID: 30344
|
|
[Token(Token = "0x4007688")]
|
|
private static readonly int wordSize;
|
|
|
|
// Token: 0x04007689 RID: 30345
|
|
[Token(Token = "0x4007689")]
|
|
private static readonly int bytesPerWord = RC564Engine.wordSize;
|
|
|
|
// Token: 0x0400768A RID: 30346
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400768A")]
|
|
private int _noRounds;
|
|
|
|
// Token: 0x0400768B RID: 30347
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400768B")]
|
|
private long[] _S;
|
|
|
|
// Token: 0x0400768C RID: 30348
|
|
[Token(Token = "0x400768C")]
|
|
private static readonly long P64;
|
|
|
|
// Token: 0x0400768D RID: 30349
|
|
[Token(Token = "0x400768D")]
|
|
private static readonly long Q64;
|
|
|
|
// Token: 0x0400768E RID: 30350
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x400768E")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|