349 lines
14 KiB
C#
349 lines
14 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines
|
|
{
|
|
// Token: 0x02001D79 RID: 7545
|
|
[Token(Token = "0x2001D79")]
|
|
public class NoekeonEngine : IBlockCipher
|
|
{
|
|
// Token: 0x0600BBC4 RID: 48068 RVA: 0x00296370 File Offset: 0x00294570
|
|
[Token(Token = "0x600BBC4")]
|
|
[Address(RVA = "0x272AA10", Offset = "0x2729A10", VA = "0x18272AA10")]
|
|
public NoekeonEngine()
|
|
{
|
|
uint[] array = new uint[4];
|
|
this.state = array;
|
|
uint[] array2 = new uint[4];
|
|
this.subKeys = array2;
|
|
uint[] array3 = new uint[4];
|
|
this.decryptKeys = array3;
|
|
this.Reset();
|
|
this._initialised = false;
|
|
}
|
|
|
|
// Token: 0x17001D74 RID: 7540
|
|
// (get) Token: 0x0600BBC5 RID: 48069 RVA: 0x002963B4 File Offset: 0x002945B4
|
|
[Token(Token = "0x17001D74")]
|
|
public virtual string AlgorithmName
|
|
{
|
|
[Token(Token = "0x600BBC5")]
|
|
[Address(RVA = "0x272B460", Offset = "0x272A460", VA = "0x18272B460", Slot = "10")]
|
|
get
|
|
{
|
|
return "Noekeon";
|
|
}
|
|
}
|
|
|
|
// Token: 0x17001D75 RID: 7541
|
|
// (get) Token: 0x0600BBC6 RID: 48070 RVA: 0x002963C8 File Offset: 0x002945C8
|
|
[Token(Token = "0x17001D75")]
|
|
public virtual bool IsPartialBlockOkay
|
|
{
|
|
[Token(Token = "0x600BBC6")]
|
|
[Address(RVA = "0x424690", Offset = "0x423690", VA = "0x180424690", Slot = "11")]
|
|
get
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600BBC7 RID: 48071 RVA: 0x002963D8 File Offset: 0x002945D8
|
|
[Token(Token = "0x600BBC7")]
|
|
[Address(RVA = "0x8BB9C0", Offset = "0x8BA9C0", VA = "0x1808BB9C0", Slot = "12")]
|
|
public virtual int GetBlockSize()
|
|
{
|
|
return 16;
|
|
}
|
|
|
|
// Token: 0x0600BBC8 RID: 48072 RVA: 0x002963E8 File Offset: 0x002945E8
|
|
[Token(Token = "0x600BBC8")]
|
|
[Address(RVA = "0x272A610", Offset = "0x2729610", VA = "0x18272A610", Slot = "13")]
|
|
public virtual void Init(bool forEncryption, ICipherParameters parameters)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BBC8)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.NoekeonEngine::Init(System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.ICipherParameters)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_94:
|
|
stloc:ArgumentException(var_13_AA, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string("Invalid parameters passed to Noekeon init - "), ldloc:string(var_12)), 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: 0x0600BBC9 RID: 48073 RVA: 0x002964A0 File Offset: 0x002946A0
|
|
[Token(Token = "0x600BBC9")]
|
|
[Address(RVA = "0x272A860", Offset = "0x2729860", VA = "0x18272A860", Slot = "14")]
|
|
public virtual int ProcessBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BBC9)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines.NoekeonEngine::ProcessBlock(System.Byte[],System.Int32,System.Byte[],System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_24:
|
|
stloc:InvalidOperationException(var_4_2A, newobj:InvalidOperationException(InvalidOperationException::.ctor, ldloc:string(var_3)))
|
|
}
|
|
|
|
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: 0x0600BBCA RID: 48074 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600BBCA")]
|
|
[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: 0x0600BBCB RID: 48075 RVA: 0x002964D8 File Offset: 0x002946D8
|
|
[Token(Token = "0x600BBCB")]
|
|
[Address(RVA = "0x272B5D0", Offset = "0x272A5D0", VA = "0x18272B5D0")]
|
|
private void setKey(byte[] key)
|
|
{
|
|
uint[] array = this.subKeys;
|
|
int num = 0;
|
|
uint num2 = Pack.BE_To_UInt32(key, num);
|
|
array[0] = num2;
|
|
uint[] array2 = this.subKeys;
|
|
uint num3 = Pack.BE_To_UInt32(key, 4);
|
|
array2[0] = num3;
|
|
uint[] array3 = this.subKeys;
|
|
uint num4 = Pack.BE_To_UInt32(key, 8);
|
|
array3[1] = num4;
|
|
uint[] array4 = this.subKeys;
|
|
uint num5 = Pack.BE_To_UInt32(key, 12);
|
|
array4[1] = num5;
|
|
}
|
|
|
|
// Token: 0x0600BBCC RID: 48076 RVA: 0x00296554 File Offset: 0x00294754
|
|
[Token(Token = "0x600BBCC")]
|
|
[Address(RVA = "0x272AEB0", Offset = "0x2729EB0", VA = "0x18272AEB0")]
|
|
private int encryptBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
uint[] array = this.state;
|
|
uint num = Pack.BE_To_UInt32(input, inOff);
|
|
array[0] = num;
|
|
uint[] array2 = this.state;
|
|
uint num2 = Pack.BE_To_UInt32(input, inOff);
|
|
array2[0] = num2;
|
|
uint[] array3 = this.state;
|
|
uint num3 = Pack.BE_To_UInt32(input, inOff);
|
|
array3[1] = num3;
|
|
uint[] array4 = this.state;
|
|
uint num4 = Pack.BE_To_UInt32(input, inOff);
|
|
array4[1] = num4;
|
|
int num5 = 0;
|
|
uint[] array5 = this.state;
|
|
uint num6 = NoekeonEngine.roundConstants[num5];
|
|
array5[0] = num6;
|
|
uint[] array6 = this.subKeys;
|
|
uint[] array7 = this.state;
|
|
this.theta(array7, array6);
|
|
uint[] array8 = this.state;
|
|
this.pi1(array8);
|
|
uint[] array9 = this.state;
|
|
this.gamma(array9);
|
|
uint[] array10 = this.state;
|
|
this.pi2(array10);
|
|
num5++;
|
|
uint[] array11 = this.state;
|
|
uint num7 = NoekeonEngine.roundConstants[num5];
|
|
array11[0] = num7;
|
|
uint[] array12 = this.subKeys;
|
|
uint[] array13 = this.state;
|
|
this.theta(array13, array12);
|
|
uint num8 = this.state[0];
|
|
uint num9 = this.state[0];
|
|
uint num10 = this.state[1];
|
|
uint num11 = this.state[1];
|
|
return 16;
|
|
}
|
|
|
|
// Token: 0x0600BBCD RID: 48077 RVA: 0x002966B4 File Offset: 0x002948B4
|
|
[Token(Token = "0x600BBCD")]
|
|
[Address(RVA = "0x272AA90", Offset = "0x2729A90", VA = "0x18272AA90")]
|
|
private int decryptBlock(byte[] input, int inOff, byte[] output, int outOff)
|
|
{
|
|
uint[] array = this.state;
|
|
uint num = Pack.BE_To_UInt32(input, inOff);
|
|
array[0] = num;
|
|
uint[] array2 = this.state;
|
|
uint num2 = Pack.BE_To_UInt32(input, inOff);
|
|
array2[0] = num2;
|
|
uint[] array3 = this.state;
|
|
uint num3 = Pack.BE_To_UInt32(input, inOff);
|
|
array3[1] = num3;
|
|
uint[] array4 = this.state;
|
|
uint num4 = Pack.BE_To_UInt32(input, inOff);
|
|
array4[1] = num4;
|
|
uint[] array5 = this.subKeys;
|
|
int length = array5.Length;
|
|
int num5 = 0;
|
|
uint[] array6 = this.decryptKeys;
|
|
int num6 = 0;
|
|
Array.Copy(array5, num6, array6, num5, length);
|
|
uint[] array7 = this.decryptKeys;
|
|
uint[] array8 = NoekeonEngine.nullVector;
|
|
this.theta(array7, array8);
|
|
uint[] array9 = this.decryptKeys;
|
|
uint[] array10 = this.state;
|
|
this.theta(array10, array9);
|
|
uint[] array11 = this.state;
|
|
uint[] array12 = NoekeonEngine.roundConstants;
|
|
uint num7;
|
|
array11[0] = num7;
|
|
uint[] array13 = this.state;
|
|
this.pi1(array13);
|
|
uint[] array14 = this.state;
|
|
this.gamma(array14);
|
|
uint[] array15 = this.state;
|
|
this.pi2(array15);
|
|
uint[] array16 = this.decryptKeys;
|
|
uint[] array17 = this.state;
|
|
this.theta(array17, array16);
|
|
uint[] array18 = this.state;
|
|
uint[] array19 = NoekeonEngine.roundConstants;
|
|
uint num8;
|
|
array18[0] = num8;
|
|
uint num9 = this.state[0];
|
|
uint num10 = this.state[0];
|
|
uint num11 = this.state[1];
|
|
uint num12 = this.state[1];
|
|
return 16;
|
|
}
|
|
|
|
// Token: 0x0600BBCE RID: 48078 RVA: 0x00296844 File Offset: 0x00294A44
|
|
[Token(Token = "0x600BBCE")]
|
|
[Address(RVA = "0x272B250", Offset = "0x272A250", VA = "0x18272B250")]
|
|
private void gamma(uint[] a)
|
|
{
|
|
int length = a.Length;
|
|
uint num = a[1];
|
|
a[0] = num;
|
|
a[0] = num;
|
|
uint num2 = a[1];
|
|
a[1] = num;
|
|
a[0] = num2;
|
|
uint num3 = a[1];
|
|
a[1] = num3;
|
|
uint num4 = a[1];
|
|
a[0] = num4;
|
|
}
|
|
|
|
// Token: 0x0600BBCF RID: 48079 RVA: 0x002968B0 File Offset: 0x00294AB0
|
|
[Token(Token = "0x600BBCF")]
|
|
[Address(RVA = "0x272B6C0", Offset = "0x272A6C0", VA = "0x18272B6C0")]
|
|
private void theta(uint[] a, uint[] k)
|
|
{
|
|
int length = a.Length;
|
|
int num = 0;
|
|
uint num2 = k[num];
|
|
num++;
|
|
int length2 = a.Length;
|
|
}
|
|
|
|
// Token: 0x0600BBD0 RID: 48080 RVA: 0x002968E0 File Offset: 0x00294AE0
|
|
[Token(Token = "0x600BBD0")]
|
|
[Address(RVA = "0x272B490", Offset = "0x272A490", VA = "0x18272B490")]
|
|
private void pi1(uint[] a)
|
|
{
|
|
uint num = a[0];
|
|
num += num;
|
|
a[0] = num;
|
|
a[1] = num;
|
|
num = a[1];
|
|
a[1] = num;
|
|
}
|
|
|
|
// Token: 0x0600BBD1 RID: 48081 RVA: 0x00296920 File Offset: 0x00294B20
|
|
[Token(Token = "0x600BBD1")]
|
|
[Address(RVA = "0x272B520", Offset = "0x272A520", VA = "0x18272B520")]
|
|
private void pi2(uint[] a)
|
|
{
|
|
uint num = a[0];
|
|
a[0] = num;
|
|
a[1] = num;
|
|
num = a[1];
|
|
a[1] = num;
|
|
}
|
|
|
|
// Token: 0x0600BBD2 RID: 48082 RVA: 0x0029695C File Offset: 0x00294B5C
|
|
[Token(Token = "0x600BBD2")]
|
|
[Address(RVA = "0x272B5B0", Offset = "0x272A5B0", VA = "0x18272B5B0")]
|
|
private uint rotl(uint x, int y)
|
|
{
|
|
return x;
|
|
}
|
|
|
|
// Token: 0x0600BBD3 RID: 48083 RVA: 0x0029696C File Offset: 0x00294B6C
|
|
// Note: this type is marked as 'beforefieldinit'.
|
|
[Token(Token = "0x600BBD3")]
|
|
[Address(RVA = "0x272A980", Offset = "0x2729980", VA = "0x18272A980")]
|
|
static NoekeonEngine()
|
|
{
|
|
uint[] array = new uint[17];
|
|
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.AF3E960D2F0572119C78CAF04B900985A299000E).FieldHandle);
|
|
NoekeonEngine.roundConstants = array;
|
|
}
|
|
|
|
// Token: 0x04007667 RID: 30311
|
|
[Token(Token = "0x4007667")]
|
|
private const int GenericSize = 16;
|
|
|
|
// Token: 0x04007668 RID: 30312
|
|
[Token(Token = "0x4007668")]
|
|
private static readonly uint[] nullVector = new uint[4];
|
|
|
|
// Token: 0x04007669 RID: 30313
|
|
[Token(Token = "0x4007669")]
|
|
private static readonly uint[] roundConstants;
|
|
|
|
// Token: 0x0400766A RID: 30314
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x400766A")]
|
|
private uint[] state;
|
|
|
|
// Token: 0x0400766B RID: 30315
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x400766B")]
|
|
private uint[] subKeys;
|
|
|
|
// Token: 0x0400766C RID: 30316
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x400766C")]
|
|
private uint[] decryptKeys;
|
|
|
|
// Token: 0x0400766D RID: 30317
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x400766D")]
|
|
private bool _initialised;
|
|
|
|
// Token: 0x0400766E RID: 30318
|
|
[FieldOffset(Offset = "0x29")]
|
|
[Token(Token = "0x400766E")]
|
|
private bool _forEncryption;
|
|
}
|
|
}
|