336 lines
13 KiB
C#
336 lines
13 KiB
C#
using System;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001D75 RID: 7541
|
|
[Token(Token = "0x2001D75")]
|
|
public class IsaacEngine : IStreamCipher
|
|
{
|
|
// Token: 0x0600BB97 RID: 48023 RVA: 0x00294F1C File Offset: 0x0029311C
|
|
[Token(Token = "0x600BB97")]
|
|
[Address(RVA = "0x27F4DD0", Offset = "0x27F3DD0", VA = "0x1827F4DD0", Slot = "9")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BB97)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.IsaacEngine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_18:
|
|
stloc:ArgumentException(var_4_2D, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("invalid parameter passed to ISAAC Init - "), ldloc:string(var_3)), ldstr:string("parameters")))
|
|
}
|
|
|
|
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: 0x0600BB98 RID: 48024 RVA: 0x00294F58 File Offset: 0x00293158
|
|
[Token(Token = "0x600BB98")]
|
|
[Address(RVA = "0x27F5110", Offset = "0x27F4110", VA = "0x1827F5110", Slot = "10")]
|
|
public virtual byte ReturnByte(byte input)
|
|
{
|
|
if (this.index == 0)
|
|
{
|
|
this.isaac();
|
|
byte[] array = Pack.UInt32_To_BE(this.results);
|
|
this.keyStream = array;
|
|
}
|
|
byte[] array2 = this.keyStream;
|
|
int num = this.index + 1;
|
|
this.index = num;
|
|
byte b;
|
|
return b;
|
|
}
|
|
|
|
// Token: 0x0600BB99 RID: 48025 RVA: 0x00294FA8 File Offset: 0x002931A8
|
|
[Token(Token = "0x600BB99")]
|
|
[Address(RVA = "0x27F4F20", Offset = "0x27F3F20", VA = "0x1827F4F20", Slot = "11")]
|
|
public virtual void ProcessBytes(byte[] input, int inOff, int len, byte[] output, int outOff)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BB99)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.IsaacEngine::ProcessBytes(System.Byte[],System.Int32,System.Int32,System.Byte[],System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_63:
|
|
stloc:InvalidOperationException(var_7_6A, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldloc:string(var_6)))
|
|
}
|
|
|
|
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.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1878
|
|
at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1846
|
|
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: 0x17001D6F RID: 7535
|
|
// (get) Token: 0x0600BB9A RID: 48026 RVA: 0x00295020 File Offset: 0x00293220
|
|
[Token(Token = "0x17001D6F")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600BB9A")]
|
|
[Address(RVA = "0x27F5260", Offset = "0x27F4260", VA = "0x1827F5260", Slot = "12")]
|
|
get
|
|
{
|
|
return "ISAAC";
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BB9B RID: 48027 RVA: 0x00295034 File Offset: 0x00293234
|
|
[Token(Token = "0x600BB9B")]
|
|
[Address(RVA = "0x27F5100", Offset = "0x27F4100", VA = "0x1827F5100", Slot = "13")]
|
|
public virtual void Reset()
|
|
{
|
|
byte[] array = this.workingKey;
|
|
this.setKey(array);
|
|
}
|
|
|
|
// Token: 0x0600BB9C RID: 48028 RVA: 0x00295050 File Offset: 0x00293250
|
|
[Token(Token = "0x600BB9C")]
|
|
[Address(RVA = "0x27F59C0", Offset = "0x27F49C0", VA = "0x1827F59C0")]
|
|
private void setKey(byte[] keyBytes)
|
|
{
|
|
this.workingKey = keyBytes;
|
|
if (this.engineState == (ulong)0L)
|
|
{
|
|
uint[] array = new uint[IsaacEngine.stateArraySize];
|
|
this.engineState = array;
|
|
}
|
|
if (this.results == (ulong)0L)
|
|
{
|
|
uint[] array2 = new uint[IsaacEngine.stateArraySize];
|
|
this.results = array2;
|
|
}
|
|
int num = 0;
|
|
uint[] array3 = this.results;
|
|
uint[] array4 = this.engineState;
|
|
array3[0] = (uint)num;
|
|
array4[0] = (uint)num;
|
|
num++;
|
|
this.b = (uint)num;
|
|
this.a = (uint)num;
|
|
this.index = num;
|
|
byte[] array5 = new byte[keyBytes.Length];
|
|
int length = keyBytes.Length;
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
Array.Copy(keyBytes, num3, array5, num2, length);
|
|
if (num < array5.Length)
|
|
{
|
|
uint[] array6 = this.results;
|
|
int @int = SerializationHeaderRecord.GetInt32(array5, num);
|
|
num += 4;
|
|
array6[0] = (uint)@int;
|
|
}
|
|
uint[] array7 = new uint[IsaacEngine.sizeL];
|
|
num++;
|
|
array7[0] = (uint)((ulong)2654435769L);
|
|
this.mix(array7);
|
|
while (num != array7.Length)
|
|
{
|
|
}
|
|
num -= num;
|
|
if (num < 1)
|
|
{
|
|
uint[] array8 = this.results;
|
|
}
|
|
uint[] array9 = this.engineState;
|
|
num++;
|
|
this.mix(array7);
|
|
uint[] array10 = this.engineState;
|
|
num++;
|
|
uint num4 = array7[num];
|
|
array10[0] = num4;
|
|
num++;
|
|
this.isaac();
|
|
this.initialised = true;
|
|
}
|
|
|
|
// Token: 0x0600BB9D RID: 48029 RVA: 0x002951C0 File Offset: 0x002933C0
|
|
[Token(Token = "0x600BB9D")]
|
|
[Address(RVA = "0x27F5290", Offset = "0x27F4290", VA = "0x1827F5290")]
|
|
private void isaac()
|
|
{
|
|
uint num = this.c;
|
|
num += (uint)1;
|
|
int num2 = 0;
|
|
this.c = num;
|
|
uint[] array = this.engineState;
|
|
uint num3 = array[num2];
|
|
if (num2 != array.Length && num2 != array.Length && (num2 == array.Length || num2 == 1))
|
|
{
|
|
this.a = (uint)num2;
|
|
}
|
|
uint num4;
|
|
this.a = num4;
|
|
int length = array.Length;
|
|
uint num5 = array[(int)num3];
|
|
num5 += num4;
|
|
array.m_value = num5;
|
|
uint[] array2 = this.engineState;
|
|
uint[] array3 = this.results;
|
|
num3 = num5;
|
|
uint num6 = array2[(int)num3];
|
|
num6 += num3;
|
|
this.b = num6;
|
|
array3.m_value = num6;
|
|
num2++;
|
|
}
|
|
|
|
// Token: 0x0600BB9E RID: 48030 RVA: 0x00295280 File Offset: 0x00293480
|
|
[Token(Token = "0x600BB9E")]
|
|
[Address(RVA = "0x27F5480", Offset = "0x27F4480", VA = "0x1827F5480")]
|
|
private void mix(uint[] x)
|
|
{
|
|
int length = x.Length;
|
|
uint num = x[0];
|
|
x[0] = num;
|
|
int length2 = x.Length;
|
|
uint num2 = x[0];
|
|
uint num3 = x[1];
|
|
num3 += num2;
|
|
x[0] = num3;
|
|
int length3 = x.Length;
|
|
uint num4 = x[1];
|
|
x[0] = num4;
|
|
int length4 = x.Length;
|
|
uint num5 = x[1];
|
|
uint num6 = x[1];
|
|
num6 += num5;
|
|
x[1] = num6;
|
|
int length5 = x.Length;
|
|
uint num7 = x[1];
|
|
x[1] = num7;
|
|
int length6 = x.Length;
|
|
uint num8 = x[1];
|
|
uint num9 = x[2];
|
|
num9 += num8;
|
|
x[1] = num9;
|
|
int length7 = x.Length;
|
|
uint num10 = x[2];
|
|
x[1] = num10;
|
|
int length8 = x.Length;
|
|
uint num11 = x[2];
|
|
uint num12 = x[2];
|
|
num12 += num11;
|
|
x[2] = num12;
|
|
int length9 = x.Length;
|
|
uint num13 = x[2];
|
|
x[2] = num13;
|
|
int length10 = x.Length;
|
|
uint num14 = x[2];
|
|
x[2] = num14;
|
|
int length11 = x.Length;
|
|
uint num15 = x[3];
|
|
x[2] = num15;
|
|
int length12 = x.Length;
|
|
uint num16 = x[0];
|
|
num15 += num16;
|
|
x[0] = num15;
|
|
int length13 = x.Length;
|
|
uint num17 = x[3];
|
|
x[3] = num17;
|
|
int length14 = x.Length;
|
|
uint num18 = x[3];
|
|
x[3] = num18;
|
|
int length15 = x.Length;
|
|
uint num19 = x[0];
|
|
num18 += num19;
|
|
x[0] = num18;
|
|
uint num20 = x[0];
|
|
x[3] = num20;
|
|
uint num21 = x[0];
|
|
x[3] = num21;
|
|
int length16 = x.Length;
|
|
uint num22 = x[1];
|
|
num21 += num22;
|
|
x[1] = num21;
|
|
int length17 = x.Length;
|
|
uint num23 = x[0];
|
|
x[0] = num23;
|
|
}
|
|
|
|
// Token: 0x0600BB9F RID: 48031 RVA: 0x002954C0 File Offset: 0x002936C0
|
|
[Token(Token = "0x600BB9F")]
|
|
[Address(RVA = "0x27F51E0", Offset = "0x27F41E0", VA = "0x1827F51E0")]
|
|
public IsaacEngine()
|
|
{
|
|
byte[] array = new byte[IsaacEngine.stateArraySize];
|
|
this.keyStream = array;
|
|
base..ctor();
|
|
}
|
|
|
|
// Token: 0x0400764C RID: 30284
|
|
[Token(Token = "0x400764C")]
|
|
private static readonly int sizeL;
|
|
|
|
// Token: 0x0400764D RID: 30285
|
|
[Token(Token = "0x400764D")]
|
|
private static readonly int stateArraySize = IsaacEngine.sizeL;
|
|
|
|
// Token: 0x0400764E RID: 30286
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400764E")]
|
|
private uint[] engineState;
|
|
|
|
// Token: 0x0400764F RID: 30287
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400764F")]
|
|
private uint[] results;
|
|
|
|
// Token: 0x04007650 RID: 30288
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4007650")]
|
|
private uint a;
|
|
|
|
// Token: 0x04007651 RID: 30289
|
|
[FieldOffset(Offset = "0x24")]
|
|
[Token(Token = "0x4007651")]
|
|
private uint b;
|
|
|
|
// Token: 0x04007652 RID: 30290
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4007652")]
|
|
private uint c;
|
|
|
|
// Token: 0x04007653 RID: 30291
|
|
[FieldOffset(Offset = "0x2C")]
|
|
[Token(Token = "0x4007653")]
|
|
private int index;
|
|
|
|
// Token: 0x04007654 RID: 30292
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x4007654")]
|
|
private byte[] keyStream;
|
|
|
|
// Token: 0x04007655 RID: 30293
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x4007655")]
|
|
private byte[] workingKey;
|
|
|
|
// Token: 0x04007656 RID: 30294
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x4007656")]
|
|
private bool initialised;
|
|
}
|
|
}
|