311 lines
10 KiB
C#
311 lines
10 KiB
C#
using System;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001C9F RID: 7327
|
|
[Token(Token = "0x2001C9F")]
|
|
public class RC564Engine : IBlockCipher
|
|
{
|
|
// Token: 0x0600B838 RID: 47160 RVA: 0x0028EBCC File Offset: 0x0028CDCC
|
|
[Token(Token = "0x600B838")]
|
|
[Address(RVA = "0x1DF2990", Offset = "0x1DF1790", VA = "0x181DF2990")]
|
|
public RC564Engine()
|
|
{
|
|
this.Reset();
|
|
this._noRounds = (int)((ulong)12L);
|
|
}
|
|
|
|
// Token: 0x17001CE1 RID: 7393
|
|
// (get) Token: 0x0600B839 RID: 47161 RVA: 0x0028EBEC File Offset: 0x0028CDEC
|
|
[Token(Token = "0x17001CE1")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600B839")]
|
|
[Address(RVA = "0x1DF3A30", Offset = "0x1DF2830", VA = "0x181DF3A30", Slot = "10")]
|
|
get
|
|
{
|
|
return "RC5-64";
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001CE2 RID: 7394
|
|
// (get) Token: 0x0600B83A RID: 47162 RVA: 0x0028EC00 File Offset: 0x0028CE00
|
|
[Token(Token = "0x17001CE2")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x600B83A")]
|
|
[Address(RVA = "0x403930", Offset = "0x402730", VA = "0x180403930", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B83B RID: 47163 RVA: 0x0028EC10 File Offset: 0x0028CE10
|
|
[Token(Token = "0x600B83B")]
|
|
[Address(RVA = "0x1DF3110", Offset = "0x1DF1F10", VA = "0x181DF3110", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
int num = RC564Engine.bytesPerWord;
|
|
return num + num;
|
|
}
|
|
|
|
// Token: 0x0600B83C RID: 47164 RVA: 0x0028EC28 File Offset: 0x0028CE28
|
|
[Token(Token = "0x600B83C")]
|
|
[Address(RVA = "0x1DF3170", Offset = "0x1DF1F70", VA = "0x181DF3170", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B83C)
|
|
|
|
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: 0x0600B83D RID: 47165 RVA: 0x0028EC7C File Offset: 0x0028CE7C
|
|
[Token(Token = "0x600B83D")]
|
|
[Address(RVA = "0x1DF3300", Offset = "0x1DF2100", VA = "0x181DF3300", 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: 0x0600B83E RID: 47166 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600B83E")]
|
|
[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: 0x0600B83F RID: 47167 RVA: 0x0028EC98 File Offset: 0x0028CE98
|
|
[Token(Token = "0x600B83F")]
|
|
[Address(RVA = "0x1DF3450", Offset = "0x1DF2250", VA = "0x181DF3450")]
|
|
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: 0x0600B840 RID: 47168 RVA: 0x0028EDE4 File Offset: 0x0028CFE4
|
|
[Token(Token = "0x600B840")]
|
|
[Address(RVA = "0x1DF2D90", Offset = "0x1DF1B90", VA = "0x181DF2D90")]
|
|
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: 0x0600B841 RID: 47169 RVA: 0x0028EEB8 File Offset: 0x0028D0B8
|
|
[Token(Token = "0x600B841")]
|
|
[Address(RVA = "0x1DF2AA0", Offset = "0x1DF18A0", VA = "0x181DF2AA0")]
|
|
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: 0x0600B842 RID: 47170 RVA: 0x0028EF74 File Offset: 0x0028D174
|
|
[Token(Token = "0x600B842")]
|
|
[Address(RVA = "0x1DF3330", Offset = "0x1DF2130", VA = "0x181DF3330")]
|
|
private long RotateLeft(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600B843 RID: 47171 RVA: 0x0028EF94 File Offset: 0x0028D194
|
|
[Token(Token = "0x600B843")]
|
|
[Address(RVA = "0x1DF33C0", Offset = "0x1DF21C0", VA = "0x181DF33C0")]
|
|
private long RotateRight(long x, long y)
|
|
{
|
|
int num = RC564Engine.wordSize;
|
|
int num2 = num - 1;
|
|
num -= num2;
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600B844 RID: 47172 RVA: 0x0028EFB4 File Offset: 0x0028D1B4
|
|
[Token(Token = "0x600B844")]
|
|
[Address(RVA = "0x1DF29E0", Offset = "0x1DF17E0", VA = "0x181DF29E0")]
|
|
private long BytesToWord(byte[] src, int srcOff)
|
|
{
|
|
int num = 0;
|
|
byte b = src[src];
|
|
num += (int)b;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600B845 RID: 47173 RVA: 0x0028EFD4 File Offset: 0x0028D1D4
|
|
[Token(Token = "0x600B845")]
|
|
[Address(RVA = "0x1DF38E0", Offset = "0x1DF26E0", VA = "0x181DF38E0")]
|
|
private void WordToBytes(long word, byte[] dst, int dstOff)
|
|
{
|
|
}
|
|
|
|
// Token: 0x0600B846 RID: 47174 RVA: 0x0028EFE8 File Offset: 0x0028D1E8
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600B846")]
|
|
[Address(RVA = "0x1DF39A0", Offset = "0x1DF27A0", VA = "0x181DF39A0")]
|
|
static RC564Engine()
|
|
{
|
|
ulong num;
|
|
RC564Engine.P64 = (long)num;
|
|
ulong num2;
|
|
RC564Engine.Q64 = (long)num2;
|
|
}
|
|
|
|
// Token: 0x040074CF RID: 29903
|
|
[Token(Token = "0x40074CF")]
|
|
private static readonly int wordSize;
|
|
|
|
// Token: 0x040074D0 RID: 29904
|
|
[Token(Token = "0x40074D0")]
|
|
private static readonly int bytesPerWord = RC564Engine.wordSize;
|
|
|
|
// Token: 0x040074D1 RID: 29905
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40074D1")]
|
|
private int _noRounds;
|
|
|
|
// Token: 0x040074D2 RID: 29906
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40074D2")]
|
|
private long[] _S;
|
|
|
|
// Token: 0x040074D3 RID: 29907
|
|
[Token(Token = "0x40074D3")]
|
|
private static readonly long P64;
|
|
|
|
// Token: 0x040074D4 RID: 29908
|
|
[Token(Token = "0x40074D4")]
|
|
private static readonly long Q64;
|
|
|
|
// Token: 0x040074D5 RID: 29909
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40074D5")]
|
|
private bool forEncryption;
|
|
}
|
|
}
|