a
This commit is contained in:
@@ -0,0 +1,422 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
||||
using Cpp2IlInjected;
|
||||
|
||||
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Macs
|
||||
{
|
||||
// Token: 0x02001C50 RID: 7248
|
||||
[Token(Token = "0x2001C50")]
|
||||
public class Gost28147Mac : IMac
|
||||
{
|
||||
// Token: 0x0600B564 RID: 46436 RVA: 0x00279DFC File Offset: 0x00277FFC
|
||||
[Token(Token = "0x600B564")]
|
||||
[Address(RVA = "0x1C27810", Offset = "0x1C26610", VA = "0x181C27810")]
|
||||
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: 0x0600B565 RID: 46437 RVA: 0x00279E58 File Offset: 0x00278058
|
||||
[Token(Token = "0x600B565")]
|
||||
[Address(RVA = "0x1C271C0", Offset = "0x1C25FC0", VA = "0x181C271C0")]
|
||||
private static int[] GenerateWorkingKey(byte[] userKey)
|
||||
{
|
||||
/*
|
||||
An exception occurred when decompiling this method (0600B565)
|
||||
|
||||
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 1660
|
||||
*/;
|
||||
}
|
||||
|
||||
// Token: 0x0600B566 RID: 46438 RVA: 0x00279EA4 File Offset: 0x002780A4
|
||||
[Token(Token = "0x600B566")]
|
||||
[Address(RVA = "0x1C272A0", Offset = "0x1C260A0", VA = "0x181C272A0", 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: 0x17001C91 RID: 7313
|
||||
// (get) Token: 0x0600B567 RID: 46439 RVA: 0x00279FA8 File Offset: 0x002781A8
|
||||
[Token(Token = "0x17001C91")]
|
||||
public string AlgorithmName
|
||||
{
|
||||
[Token(Token = "0x600B567")]
|
||||
[Address(RVA = "0x1C27970", Offset = "0x1C26770", VA = "0x181C27970", Slot = "5")]
|
||||
get
|
||||
{
|
||||
return "Gost28147Mac";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600B568 RID: 46440 RVA: 0x00279FBC File Offset: 0x002781BC
|
||||
[Token(Token = "0x600B568")]
|
||||
[Address(RVA = "0x4101C0", Offset = "0x40EFC0", VA = "0x1804101C0", Slot = "6")]
|
||||
public int GetMacSize()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Token: 0x0600B569 RID: 46441 RVA: 0x00279FCC File Offset: 0x002781CC
|
||||
[Token(Token = "0x600B569")]
|
||||
[Address(RVA = "0x1C27BB0", Offset = "0x1C269B0", VA = "0x181C27BB0")]
|
||||
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: 0x0600B56A RID: 46442 RVA: 0x0027A008 File Offset: 0x00278208
|
||||
[Token(Token = "0x600B56A")]
|
||||
[Address(RVA = "0x1C279A0", Offset = "0x1C267A0", VA = "0x181C279A0")]
|
||||
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: 0x0600B56B RID: 46443 RVA: 0x0027A038 File Offset: 0x00278238
|
||||
[Token(Token = "0x600B56B")]
|
||||
[Address(RVA = "0x1C278B0", Offset = "0x1C266B0", VA = "0x181C278B0")]
|
||||
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: 0x0600B56C RID: 46444 RVA: 0x0027A074 File Offset: 0x00278274
|
||||
[Token(Token = "0x600B56C")]
|
||||
[Address(RVA = "0x1C27DF0", Offset = "0x1C26BF0", VA = "0x181C27DF0")]
|
||||
private static void intTobytes(int num, byte[] output, int outOff)
|
||||
{
|
||||
int num2 = outOff + 1;
|
||||
}
|
||||
|
||||
// Token: 0x0600B56D RID: 46445 RVA: 0x0027A08C File Offset: 0x0027828C
|
||||
[Token(Token = "0x600B56D")]
|
||||
[Address(RVA = "0x1C26F40", Offset = "0x1C25D40", VA = "0x181C26F40")]
|
||||
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: 0x0600B56E RID: 46446 RVA: 0x0027A0DC File Offset: 0x002782DC
|
||||
[Token(Token = "0x600B56E")]
|
||||
[Address(RVA = "0x1C276E0", Offset = "0x1C264E0", VA = "0x181C276E0", 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: 0x0600B56F RID: 46447 RVA: 0x0027A1A8 File Offset: 0x002783A8
|
||||
[Token(Token = "0x600B56F")]
|
||||
[Address(RVA = "0x1C26D50", Offset = "0x1C25B50", VA = "0x181C26D50", 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: 0x0600B570 RID: 46448 RVA: 0x0027A2CC File Offset: 0x002784CC
|
||||
[Token(Token = "0x600B570")]
|
||||
[Address(RVA = "0x1C27030", Offset = "0x1C25E30", VA = "0x181C27030", 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: 0x0600B571 RID: 46449 RVA: 0x0027A3EC File Offset: 0x002785EC
|
||||
[Token(Token = "0x600B571")]
|
||||
[Address(RVA = "0x1C276A0", Offset = "0x1C264A0", VA = "0x181C276A0", 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: 0x0400730F RID: 29455
|
||||
[Token(Token = "0x400730F")]
|
||||
private const int blockSize = 8;
|
||||
|
||||
// Token: 0x04007310 RID: 29456
|
||||
[Token(Token = "0x4007310")]
|
||||
private const int macSize = 4;
|
||||
|
||||
// Token: 0x04007311 RID: 29457
|
||||
[FieldOffset(Offset = "0x10")]
|
||||
[Token(Token = "0x4007311")]
|
||||
private int bufOff;
|
||||
|
||||
// Token: 0x04007312 RID: 29458
|
||||
[FieldOffset(Offset = "0x18")]
|
||||
[Token(Token = "0x4007312")]
|
||||
private byte[] buf;
|
||||
|
||||
// Token: 0x04007313 RID: 29459
|
||||
[FieldOffset(Offset = "0x20")]
|
||||
[Token(Token = "0x4007313")]
|
||||
private byte[] mac;
|
||||
|
||||
// Token: 0x04007314 RID: 29460
|
||||
[FieldOffset(Offset = "0x28")]
|
||||
[Token(Token = "0x4007314")]
|
||||
private bool firstStep = true;
|
||||
|
||||
// Token: 0x04007315 RID: 29461
|
||||
[FieldOffset(Offset = "0x30")]
|
||||
[Token(Token = "0x4007315")]
|
||||
private int[] workingKey;
|
||||
|
||||
// Token: 0x04007316 RID: 29462
|
||||
[FieldOffset(Offset = "0x38")]
|
||||
[Token(Token = "0x4007316")]
|
||||
private byte[] macIV;
|
||||
|
||||
// Token: 0x04007317 RID: 29463
|
||||
[FieldOffset(Offset = "0x40")]
|
||||
[Token(Token = "0x4007317")]
|
||||
private byte[] S;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user