313 lines
11 KiB
C#
313 lines
11 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x020016C2 RID: 5826
|
|
[Token(Token = "0x20016C2")]
|
|
[StructLayout(3)]
|
|
public class RC564Engine : IBlockCipher
|
|
{
|
|
// Token: 0x06009C5E RID: 40030 RVA: 0x00237454 File Offset: 0x00235654
|
|
[Token(Token = "0x6009C5E")]
|
|
[Address(RVA = "0x212C840", Offset = "0x212B240", VA = "0x18212C840")]
|
|
public RC564Engine()
|
|
{
|
|
this.Reset();
|
|
this._noRounds = (int)((ulong)12L);
|
|
}
|
|
|
|
// Token: 0x170018E0 RID: 6368
|
|
// (get) Token: 0x06009C5F RID: 40031 RVA: 0x00237474 File Offset: 0x00235674
|
|
[Token(Token = "0x170018E0")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x6009C5F")]
|
|
[Address(RVA = "0x212D8E0", Offset = "0x212C2E0", VA = "0x18212D8E0", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC5-64";
|
|
}
|
|
}
|
|
|
|
// Token: 0x170018E1 RID: 6369
|
|
// (get) Token: 0x06009C60 RID: 40032 RVA: 0x00237488 File Offset: 0x00235688
|
|
[Token(Token = "0x170018E1")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x6009C60")]
|
|
[Address(RVA = "0x413970", Offset = "0x412370", VA = "0x180413970", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009C61 RID: 40033 RVA: 0x00237498 File Offset: 0x00235698
|
|
[Token(Token = "0x6009C61")]
|
|
[Address(RVA = "0x212CFC0", Offset = "0x212B9C0", VA = "0x18212CFC0", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
int num = RC564Engine.bytesPerWord;
|
|
return num + num;
|
|
}
|
|
|
|
// Token: 0x06009C62 RID: 40034 RVA: 0x002374B0 File Offset: 0x002356B0
|
|
[Token(Token = "0x6009C62")]
|
|
[Address(RVA = "0x212D020", Offset = "0x212BA20", VA = "0x18212D020", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009C62)
|
|
|
|
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: 0x06009C63 RID: 40035 RVA: 0x00237504 File Offset: 0x00235704
|
|
[Token(Token = "0x6009C63")]
|
|
[Address(RVA = "0x212D1B0", Offset = "0x212BBB0", VA = "0x18212D1B0", 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: 0x06009C64 RID: 40036 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x6009C64")]
|
|
[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: 0x06009C65 RID: 40037 RVA: 0x00237520 File Offset: 0x00235720
|
|
[Token(Token = "0x6009C65")]
|
|
[Address(RVA = "0x212D300", Offset = "0x212BD00", VA = "0x18212D300")]
|
|
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: 0x06009C66 RID: 40038 RVA: 0x0023766C File Offset: 0x0023586C
|
|
[Token(Token = "0x6009C66")]
|
|
[Address(RVA = "0x212CC40", Offset = "0x212B640", VA = "0x18212CC40")]
|
|
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: 0x06009C67 RID: 40039 RVA: 0x00237740 File Offset: 0x00235940
|
|
[Token(Token = "0x6009C67")]
|
|
[Address(RVA = "0x212C950", Offset = "0x212B350", VA = "0x18212C950")]
|
|
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: 0x06009C68 RID: 40040 RVA: 0x002377FC File Offset: 0x002359FC
|
|
[Token(Token = "0x6009C68")]
|
|
[Address(RVA = "0x212D1E0", Offset = "0x212BBE0", VA = "0x18212D1E0")]
|
|
private long RotateLeft(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x06009C69 RID: 40041 RVA: 0x0023781C File Offset: 0x00235A1C
|
|
[Token(Token = "0x6009C69")]
|
|
[Address(RVA = "0x212D270", Offset = "0x212BC70", VA = "0x18212D270")]
|
|
private long RotateRight(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x06009C6A RID: 40042 RVA: 0x0023783C File Offset: 0x00235A3C
|
|
[Token(Token = "0x6009C6A")]
|
|
[Address(RVA = "0x212C890", Offset = "0x212B290", VA = "0x18212C890")]
|
|
private long BytesToWord(byte[] src, int srcOff)
|
|
{
|
|
int num = 0;
|
|
byte b = src[src];
|
|
num += (int)b;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009C6B RID: 40043 RVA: 0x0023785C File Offset: 0x00235A5C
|
|
[Token(Token = "0x6009C6B")]
|
|
[Address(RVA = "0x212D790", Offset = "0x212C190", VA = "0x18212D790")]
|
|
private void WordToBytes(long word, byte[] dst, int dstOff)
|
|
{
|
|
}
|
|
|
|
// Token: 0x06009C6C RID: 40044 RVA: 0x00237870 File Offset: 0x00235A70
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x6009C6C")]
|
|
[Address(RVA = "0x212D850", Offset = "0x212C250", VA = "0x18212D850")]
|
|
static RC564Engine()
|
|
{
|
|
ulong num;
|
|
RC564Engine.P64 = (long)num;
|
|
ulong num2;
|
|
RC564Engine.Q64 = (long)num2;
|
|
}
|
|
|
|
// Token: 0x0400668C RID: 26252
|
|
[Token(Token = "0x400668C")]
|
|
private static readonly int wordSize;
|
|
|
|
// Token: 0x0400668D RID: 26253
|
|
[Token(Token = "0x400668D")]
|
|
private static readonly int bytesPerWord = RC564Engine.wordSize;
|
|
|
|
// Token: 0x0400668E RID: 26254
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400668E")]
|
|
private int _noRounds;
|
|
|
|
// Token: 0x0400668F RID: 26255
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400668F")]
|
|
private long[] _S;
|
|
|
|
// Token: 0x04006690 RID: 26256
|
|
[Token(Token = "0x4006690")]
|
|
private static readonly long P64;
|
|
|
|
// Token: 0x04006691 RID: 26257
|
|
[Token(Token = "0x4006691")]
|
|
private static readonly long Q64;
|
|
|
|
// Token: 0x04006692 RID: 26258
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4006692")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|