Files
2026-04-08 23:40:05 +02:00

425 lines
14 KiB
C#

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs
{
// Token: 0x02001673 RID: 5747
[Token(Token = "0x2001673")]
[StructLayout(3)]
public class Gost28147Mac : IMac
{
// Token: 0x0600998A RID: 39306 RVA: 0x002227E4 File Offset: 0x002209E4
[Token(Token = "0x600998A")]
[Address(RVA = "0x20F07B0", Offset = "0x20EF1B0", VA = "0x1820F07B0")]
public Gost28147Mac()
{
byte[] array = new byte[128];
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.2BA9E4B370D477F8C7FE286262D7ADC69CAF290E).FieldHandle);
this.S = array;
base..ctor();
byte[] array2 = new byte[8];
this.mac = array2;
byte[] array3 = new byte[8];
this.buf = array3;
this.bufOff = (int)((ulong)0L);
}
// Token: 0x0600998B RID: 39307 RVA: 0x00222840 File Offset: 0x00220A40
[Token(Token = "0x600998B")]
[Address(RVA = "0x20F0160", Offset = "0x20EEB60", VA = "0x1820F0160")]
private static int[] GenerateWorkingKey(byte[] userKey)
{
/*
An exception occurred when decompiling this method (0600998B)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs.Gost28147Mac::GenerateWorkingKey(System.Byte[])
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_33:
stloc:ArgumentException(var_3_3D, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("Key length invalid. Key needs to be 32 byte - 256 bit!!!")))
}
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: 0x0600998C RID: 39308 RVA: 0x0022288C File Offset: 0x00220A8C
[Token(Token = "0x600998C")]
[Address(RVA = "0x20F0240", Offset = "0x20EEC40", VA = "0x1820F0240", Slot = "4")]
public void Init(ICipherParameters parameters)
{
for (;;)
{
byte[] array = this.buf;
int length = array.Length;
int num = 0;
Array.Clear(array, num, length);
int num2 = 0;
this.bufOff = num2;
byte[] array2 = new byte[0];
this.buf = array2;
this.macIV = num2;
if (parameters != 0)
{
if ("{il2cpp array field local7->}" == typeof(ParametersWithSBox).TypeHandle)
{
}
int num3;
if (parameters == 0)
{
if (parameters == 0)
{
if (parameters != 0 && parameters != 0)
{
break;
}
continue;
}
else
{
if (parameters == 0)
{
continue;
}
num3 = 0;
if (parameters == 0)
{
continue;
}
}
}
if (parameters != 0)
{
while (num3 == 0)
{
}
if (num3 != 0 && num3 != 0)
{
goto Block_8;
}
}
}
}
byte[] array4;
int[] array3 = Gost28147Mac.GenerateWorkingKey(array4);
this.workingKey = array3;
byte[] array5 = this.mac;
int length2 = array5.Length;
int num4 = 0;
int num5 = 0;
byte[] array6;
Array.Copy(array6, num5, array5, num4, length2);
byte[] array7;
this.macIV = array7;
return;
Block_8:
byte[] array9;
int[] array8 = Gost28147Mac.GenerateWorkingKey(array9);
throw new NullReferenceException();
}
// Token: 0x17001890 RID: 6288
// (get) Token: 0x0600998D RID: 39309 RVA: 0x00222990 File Offset: 0x00220B90
[Token(Token = "0x17001890")]
public string AlgorithmName
{
[Token(Token = "0x600998D")]
[Address(RVA = "0x20F0910", Offset = "0x20EF310", VA = "0x1820F0910", Slot = "5")]
get
{
return "Gost28147Mac";
}
}
// Token: 0x0600998E RID: 39310 RVA: 0x002229A4 File Offset: 0x00220BA4
[Token(Token = "0x600998E")]
[Address(RVA = "0x600D80", Offset = "0x5FF780", VA = "0x180600D80", Slot = "6")]
public int GetMacSize()
{
return 4;
}
// Token: 0x0600998F RID: 39311 RVA: 0x002229B4 File Offset: 0x00220BB4
[Token(Token = "0x600998F")]
[Address(RVA = "0x20F0B50", Offset = "0x20EF550", VA = "0x1820F0B50")]
private int gost28147_mainStep(int n1, int key)
{
int length = this.S.Length;
byte b;
byte b2;
b += b2;
b += b2;
b += b2;
b += b2;
b += b2;
b += b2;
b += b2;
b2 = b;
throw new NullReferenceException();
}
// Token: 0x06009990 RID: 39312 RVA: 0x002229F0 File Offset: 0x00220BF0
[Token(Token = "0x6009990")]
[Address(RVA = "0x20F0940", Offset = "0x20EF340", VA = "0x1820F0940")]
private void gost28147MacFunc(int[] workingKey, byte[] input, int inOff, byte[] output, int outOff)
{
int num = 0;
int num2 = 0;
int num3 = workingKey[num2];
int num4 = this.gost28147_mainStep(inOff, num3);
num2++;
num++;
}
// Token: 0x06009991 RID: 39313 RVA: 0x00222A20 File Offset: 0x00220C20
[Token(Token = "0x6009991")]
[Address(RVA = "0x20F0850", Offset = "0x20EF250", VA = "0x1820F0850")]
private static int bytesToint(byte[] input, int inOff)
{
int length = input.Length;
byte b = input[input];
byte b2 = input[input];
int num = inOff + 1;
b += b2;
b += b2;
byte b3;
b += b3;
throw new NullReferenceException();
}
// Token: 0x06009992 RID: 39314 RVA: 0x00222A5C File Offset: 0x00220C5C
[Token(Token = "0x6009992")]
[Address(RVA = "0x20F0D90", Offset = "0x20EF790", VA = "0x1820F0D90")]
private static void intTobytes(int num, byte[] output, int outOff)
{
int num2 = outOff + 1;
}
// Token: 0x06009993 RID: 39315 RVA: 0x00222A74 File Offset: 0x00220C74
[Token(Token = "0x6009993")]
[Address(RVA = "0x20EFEE0", Offset = "0x20EE8E0", VA = "0x1820EFEE0")]
private static byte[] CM5func(byte[] buf, int bufOff, byte[] mac)
{
int num = buf.Length;
num -= bufOff;
byte[] array = new byte[num];
int length = mac.Length;
int num2 = 0;
int num3 = 0;
Array.Copy(buf, bufOff, array, num3, length);
int length2 = mac.Length;
if (num2 != length2)
{
num2++;
}
return array;
}
// Token: 0x06009994 RID: 39316 RVA: 0x00222AC4 File Offset: 0x00220CC4
[Token(Token = "0x6009994")]
[Address(RVA = "0x20F0680", Offset = "0x20EF080", VA = "0x1820F0680", Slot = "7")]
public void Update(byte input)
{
byte[] array = this.buf;
int num = this.bufOff;
int length = array.Length;
if (num == length)
{
byte[] array2 = new byte[length];
int length2 = this.mac.Length;
int num2 = 0;
int num3 = 0;
byte[] array3 = this.buf;
int num4 = 0;
Array.Copy(array3, num4, array2, num3, length2);
if ((this.firstStep ? 1 : 0) == num2)
{
}
byte[] array4 = this.macIV;
this.firstStep = num2 != 0;
byte[] array6;
if (array4 != 0)
{
byte[] array5 = this.buf;
int num5 = 0;
array6 = Gost28147Mac.CM5func(array5, num5, array4);
}
byte[] array7 = this.mac;
int num6 = 0;
int[] array8 = this.workingKey;
this.gost28147MacFunc(array8, array6, num6, array7, num2);
}
int num7 = num + 1;
this.bufOff = num7;
}
// Token: 0x06009995 RID: 39317 RVA: 0x00222B90 File Offset: 0x00220D90
[Token(Token = "0x6009995")]
[Address(RVA = "0x20EFCF0", Offset = "0x20EE6F0", VA = "0x1820EFCF0", Slot = "8")]
public void BlockUpdate(byte[] input, int inOff, int len)
{
int num = this.bufOff;
uint num2;
num2 -= (uint)num;
int num3 = 0;
if (len > (int)num2)
{
byte[] array = this.buf;
Array.Copy(input, inOff, array, num, (int)num2);
byte[] array2 = new byte[this.buf.Length];
int length = this.mac.Length;
int num4 = 0;
int num5 = 0;
Array.Copy(this.buf, num5, array2, num4, length);
if ((this.firstStep ? 1 : 0) == num3)
{
}
byte[] array3 = this.macIV;
this.firstStep = num3 != 0;
byte[] array5;
if (array3 != 0)
{
byte[] array4 = this.buf;
int num6 = 0;
array5 = Gost28147Mac.CM5func(array4, num6, array3);
}
byte[] array6 = this.mac;
int num7 = 0;
int[] array7 = this.workingKey;
this.gost28147MacFunc(array7, array5, num7, array6, num3);
this.bufOff = num3;
if (len > 8)
{
byte[] array8 = this.mac;
byte[] array9 = Gost28147Mac.CM5func(input, inOff, array8);
byte[] array10 = this.mac;
int num8 = 0;
int[] array11 = this.workingKey;
this.gost28147MacFunc(array11, array9, num8, array10, num3);
while (len != 8)
{
}
}
}
byte[] array12 = this.buf;
Array.Copy(input, inOff, array12, num, len);
}
// Token: 0x06009996 RID: 39318 RVA: 0x00222CB4 File Offset: 0x00220EB4
[Token(Token = "0x6009996")]
[Address(RVA = "0x20EFFD0", Offset = "0x20EE9D0", VA = "0x1820EFFD0", Slot = "9")]
public int DoFinal(byte[] output, int outOff)
{
int num = this.bufOff;
if (num < 8)
{
byte[] array = this.buf;
int num2 = num + 1;
this.bufOff = num2;
int num3 = this.bufOff;
}
byte[] array2 = new byte[this.buf.Length];
int length = this.mac.Length;
int num4 = 0;
int num5 = 0;
byte[] array3 = this.buf;
int num6 = 0;
Array.Copy(array3, num6, array2, num5, length);
byte[] array6;
if ((this.firstStep ? 1 : 0) == num4)
{
byte[] array4 = this.mac;
byte[] array5 = this.buf;
int num7 = 0;
array6 = Gost28147Mac.CM5func(array5, num7, array4);
}
this.firstStep = num4 != 0;
byte[] array7 = this.mac;
int num8 = 0;
int[] array8 = this.workingKey;
this.gost28147MacFunc(array8, array6, num8, array7, num4);
byte[] array9 = this.mac;
int num9 = array9.Length;
num9 -= array8;
ulong num10;
Array.Copy(array9, array8, output, outOff, (int)num10);
byte[] array10 = this.buf;
int length2 = array10.Length;
int num11 = 0;
Array.Clear(array10, num11, length2);
this.bufOff = num4;
this.firstStep = true;
throw new NullReferenceException();
}
// Token: 0x06009997 RID: 39319 RVA: 0x00222DD4 File Offset: 0x00220FD4
[Token(Token = "0x6009997")]
[Address(RVA = "0x20F0640", Offset = "0x20EF040", VA = "0x1820F0640", Slot = "10")]
public void Reset()
{
byte[] array = this.buf;
int length = array.Length;
int num = 0;
Array.Clear(array, num, length);
this.bufOff = (int)((ulong)0L);
this.firstStep = true;
}
// Token: 0x040064CC RID: 25804
[Token(Token = "0x40064CC")]
private const int blockSize = 8;
// Token: 0x040064CD RID: 25805
[Token(Token = "0x40064CD")]
private const int macSize = 4;
// Token: 0x040064CE RID: 25806
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
[Token(Token = "0x40064CE")]
private int bufOff;
// Token: 0x040064CF RID: 25807
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
[Token(Token = "0x40064CF")]
private byte[] buf;
// Token: 0x040064D0 RID: 25808
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
[Token(Token = "0x40064D0")]
private byte[] mac;
// Token: 0x040064D1 RID: 25809
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
[Token(Token = "0x40064D1")]
private bool firstStep = true;
// Token: 0x040064D2 RID: 25810
[global::Cpp2IlInjected.FieldOffset(Offset = "0x30")]
[Token(Token = "0x40064D2")]
private int[] workingKey;
// Token: 0x040064D3 RID: 25811
[global::Cpp2IlInjected.FieldOffset(Offset = "0x38")]
[Token(Token = "0x40064D3")]
private byte[] macIV;
// Token: 0x040064D4 RID: 25812
[global::Cpp2IlInjected.FieldOffset(Offset = "0x40")]
[Token(Token = "0x40064D4")]
private byte[] S;
}
}