Files
Jan2021-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Engines/IsaacEngine.cs
T
2026-04-08 23:40:05 +02:00

338 lines
14 KiB
C#

using System;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
{
// Token: 0x020016B8 RID: 5816
[Token(Token = "0x20016B8")]
[StructLayout(3)]
public class IsaacEngine : IStreamCipher
{
// Token: 0x06009BEF RID: 39919 RVA: 0x0023475C File Offset: 0x0023295C
[Token(Token = "0x6009BEF")]
[Address(RVA = "0x2125090", Offset = "0x2123A90", VA = "0x182125090", Slot = "9")]
public virtual void Init(bool forEncryption, ICipherParameters parameters)
{
/*
An exception occurred when decompiling this method (06009BEF)
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: 0x06009BF0 RID: 39920 RVA: 0x00234798 File Offset: 0x00232998
[Token(Token = "0x6009BF0")]
[Address(RVA = "0x21253D0", Offset = "0x2123DD0", VA = "0x1821253D0", 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: 0x06009BF1 RID: 39921 RVA: 0x002347E8 File Offset: 0x002329E8
[Token(Token = "0x6009BF1")]
[Address(RVA = "0x21251E0", Offset = "0x2123BE0", VA = "0x1821251E0", Slot = "11")]
public virtual void ProcessBytes(byte[] input, int inOff, int len, byte[] output, int outOff)
{
/*
An exception occurred when decompiling this method (06009BF1)
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: 0x170018D1 RID: 6353
// (get) Token: 0x06009BF2 RID: 39922 RVA: 0x00234860 File Offset: 0x00232A60
[Token(Token = "0x170018D1")]
public virtual string AlgorithmName
{
[Token(Token = "0x6009BF2")]
[Address(RVA = "0x2125520", Offset = "0x2123F20", VA = "0x182125520", Slot = "12")]
get
{
return "ISAAC";
}
}
// Token: 0x06009BF3 RID: 39923 RVA: 0x00234874 File Offset: 0x00232A74
[Token(Token = "0x6009BF3")]
[Address(RVA = "0x21253C0", Offset = "0x2123DC0", VA = "0x1821253C0", Slot = "13")]
public virtual void Reset()
{
byte[] array = this.workingKey;
this.setKey(array);
}
// Token: 0x06009BF4 RID: 39924 RVA: 0x00234890 File Offset: 0x00232A90
[Token(Token = "0x6009BF4")]
[Address(RVA = "0x2125C80", Offset = "0x2124680", VA = "0x182125C80")]
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: 0x06009BF5 RID: 39925 RVA: 0x00234A00 File Offset: 0x00232C00
[Token(Token = "0x6009BF5")]
[Address(RVA = "0x2125550", Offset = "0x2123F50", VA = "0x182125550")]
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: 0x06009BF6 RID: 39926 RVA: 0x00234AC0 File Offset: 0x00232CC0
[Token(Token = "0x6009BF6")]
[Address(RVA = "0x2125740", Offset = "0x2124140", VA = "0x182125740")]
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: 0x06009BF7 RID: 39927 RVA: 0x00234D00 File Offset: 0x00232F00
[Token(Token = "0x6009BF7")]
[Address(RVA = "0x21254A0", Offset = "0x2123EA0", VA = "0x1821254A0")]
public IsaacEngine()
{
byte[] array = new byte[IsaacEngine.stateArraySize];
this.keyStream = array;
base..ctor();
}
// Token: 0x04006650 RID: 26192
[Token(Token = "0x4006650")]
private static readonly int sizeL;
// Token: 0x04006651 RID: 26193
[Token(Token = "0x4006651")]
private static readonly int stateArraySize = IsaacEngine.sizeL;
// Token: 0x04006652 RID: 26194
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x4006652")]
private uint[] engineState;
// Token: 0x04006653 RID: 26195
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x4006653")]
private uint[] results;
// Token: 0x04006654 RID: 26196
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x4006654")]
private uint a;
// Token: 0x04006655 RID: 26197
[global::Cpp2IlInjected.FieldOffset(Offset = "0x24")]
[Token(Token = "0x4006655")]
private uint b;
// Token: 0x04006656 RID: 26198
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x4006656")]
private uint c;
// Token: 0x04006657 RID: 26199
[global::Cpp2IlInjected.FieldOffset(Offset = "0x2C")]
[Token(Token = "0x4006657")]
private int index;
// Token: 0x04006658 RID: 26200
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
[Token(Token = "0x4006658")]
private byte[] keyStream;
// Token: 0x04006659 RID: 26201
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
[Token(Token = "0x4006659")]
private byte[] workingKey;
// Token: 0x0400665A RID: 26202
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
[Token(Token = "0x400665A")]
private bool initialised;
}
}