278 lines
11 KiB
C#
278 lines
11 KiB
C#
using System;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Digests;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Engines;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators
|
|
{
|
|
// Token: 0x02001C7D RID: 7293
|
|
[Token(Token = "0x2001C7D")]
|
|
public class SCrypt
|
|
{
|
|
// Token: 0x0600B6AA RID: 46762 RVA: 0x002810A8 File Offset: 0x0027F2A8
|
|
[Token(Token = "0x600B6AA")]
|
|
[Address(RVA = "0x1C2ED70", Offset = "0x1C2DB70", VA = "0x181C2ED70")]
|
|
public static byte[] Generate(byte[] P, byte[] S, int N, int r, int p, int dkLen)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600B6AA)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators.SCrypt::Generate(System.Byte[],System.Byte[],System.Int32,System.Int32,System.Int32,System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_2D:
|
|
stloc:ArgumentException(var_4_37, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("Cost parameter N must be > 1 and < 65536.")))
|
|
}
|
|
|
|
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.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.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.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: 0x0600B6AB RID: 46763 RVA: 0x002810F0 File Offset: 0x0027F2F0
|
|
[Token(Token = "0x600B6AB")]
|
|
[Address(RVA = "0x1C2F0D0", Offset = "0x1C2DED0", VA = "0x181C2F0D0")]
|
|
private static byte[] MFcrypt(byte[] P, byte[] S, int N, int r, int p, int dkLen)
|
|
{
|
|
do
|
|
{
|
|
int num = 0;
|
|
byte[] array = SCrypt.SingleIterationPBKDF2(P, S, N);
|
|
int length = array.Length;
|
|
uint[] array2 = new uint[length];
|
|
int num2 = 0;
|
|
Pack.LE_To_UInt32(array, num2, array2);
|
|
if (num < length)
|
|
{
|
|
num += r;
|
|
}
|
|
int num3 = 0;
|
|
Pack.UInt32_To_LE(array2, array, num3);
|
|
int num4 = 0;
|
|
Array[] array3 = new Array[2];
|
|
if (array != 0)
|
|
{
|
|
}
|
|
array3[0] = array;
|
|
if (array2 != 0)
|
|
{
|
|
}
|
|
array3[1] = array2;
|
|
int length2 = array3.Length;
|
|
if (num4 < length2)
|
|
{
|
|
Array array4 = array3[num4];
|
|
if (array4 != 0)
|
|
{
|
|
int num5 = array4.System.Collections.ICollection.Count;
|
|
int num6 = 0;
|
|
Array.Clear(array4, num6, num5);
|
|
}
|
|
num4++;
|
|
}
|
|
}
|
|
while (r != 0);
|
|
byte[] array5;
|
|
return array5;
|
|
}
|
|
|
|
// Token: 0x0600B6AC RID: 46764 RVA: 0x002811B4 File Offset: 0x0027F3B4
|
|
[Token(Token = "0x600B6AC")]
|
|
[Address(RVA = "0x1C2F8F0", Offset = "0x1C2E6F0", VA = "0x181C2F8F0")]
|
|
private static byte[] SingleIterationPBKDF2(byte[] P, byte[] S, int dkLen)
|
|
{
|
|
ICipherParameters cipherParameters;
|
|
do
|
|
{
|
|
string text = new Pkcs5S2ParametersGenerator(new Sha256Digest()).ToString();
|
|
}
|
|
while (cipherParameters == 0 || cipherParameters == 0);
|
|
byte[] array;
|
|
return array;
|
|
}
|
|
|
|
// Token: 0x0600B6AD RID: 46765 RVA: 0x002811E8 File Offset: 0x0027F3E8
|
|
[Token(Token = "0x600B6AD")]
|
|
[Address(RVA = "0x1C2F350", Offset = "0x1C2E150", VA = "0x181C2F350")]
|
|
private static void SMix(uint[] B, int BOff, int N, int r)
|
|
{
|
|
uint[] array7;
|
|
do
|
|
{
|
|
int num = 0;
|
|
uint[] array = new uint[0];
|
|
uint[] array2 = new uint[0];
|
|
uint[] array3 = new uint[r];
|
|
uint[] array4 = new uint[r];
|
|
uint[][] array5 = new uint[r][];
|
|
if (num < N)
|
|
{
|
|
if (array5 != 0 && (array5 == 0 || array5 == 0))
|
|
{
|
|
goto IL_144;
|
|
}
|
|
array5[0] = num;
|
|
num++;
|
|
}
|
|
if (num < N)
|
|
{
|
|
int num2 = array4.Length;
|
|
uint num3 = array4[num];
|
|
uint[] array6 = array5[(int)num3];
|
|
num2--;
|
|
num++;
|
|
}
|
|
int num4 = 0;
|
|
int length = array5.Length;
|
|
if (num4 < length)
|
|
{
|
|
array7 = array5[num4];
|
|
if (array7 != 0)
|
|
{
|
|
int num5 = 0;
|
|
Array.Clear(array7, num5, num4);
|
|
}
|
|
num4++;
|
|
}
|
|
Array[] array8 = new Array[4];
|
|
if (array4 != 0)
|
|
{
|
|
}
|
|
array8[0] = array4;
|
|
if (typeof(uint[]).TypeHandle != 0)
|
|
{
|
|
}
|
|
array8[1] = typeof(uint[]).TypeHandle;
|
|
if (array8 != 0)
|
|
{
|
|
}
|
|
array8[2] = array8;
|
|
if (array8 != 0)
|
|
{
|
|
}
|
|
array8[3] = array8;
|
|
int length2 = array8.Length;
|
|
if (num4 < length2)
|
|
{
|
|
Array array9 = array8[num4];
|
|
if (array9 != 0)
|
|
{
|
|
int num6 = array9.System.Collections.ICollection.Count;
|
|
int num7 = 0;
|
|
Array.Clear(array9, num7, num6);
|
|
}
|
|
num4++;
|
|
}
|
|
}
|
|
while (array7 != 0);
|
|
return;
|
|
IL_144:
|
|
throw new IndexOutOfRangeException();
|
|
}
|
|
|
|
// Token: 0x0600B6AE RID: 46766 RVA: 0x00281388 File Offset: 0x0027F588
|
|
[Token(Token = "0x600B6AE")]
|
|
[Address(RVA = "0x1C2EB40", Offset = "0x1C2D940", VA = "0x181C2EB40")]
|
|
private static void BlockMix(uint[] B, uint[] X1, uint[] X2, uint[] Y, int r)
|
|
{
|
|
int length = B.Length;
|
|
int num = 0;
|
|
ulong num2;
|
|
Array.Copy(B, length, X1, num, (int)num2);
|
|
int num3 = B.Length;
|
|
int num4 = 0;
|
|
int num5 = 0;
|
|
SCrypt.Xor(X1, B, num4, X2);
|
|
Salsa20Engine.SalsaCore(8, X2, X1);
|
|
int num6 = 0;
|
|
ulong num7;
|
|
Array.Copy(X1, num6, Y, num5, (int)num7);
|
|
num3 -= num5;
|
|
num3 += num4;
|
|
num4 += 16;
|
|
int length2 = Y.Length;
|
|
int num8 = 0;
|
|
int num9 = 0;
|
|
Array.Copy(Y, num9, B, num8, (int)num2);
|
|
}
|
|
|
|
// Token: 0x0600B6AF RID: 46767 RVA: 0x00281410 File Offset: 0x0027F610
|
|
[Token(Token = "0x600B6AF")]
|
|
[Address(RVA = "0x1C2FA60", Offset = "0x1C2E860", VA = "0x181C2FA60")]
|
|
private static void Xor(uint[] a, uint[] b, int bOff, uint[] output)
|
|
{
|
|
int length = output.Length;
|
|
uint num = b[bOff];
|
|
output[0] = num;
|
|
}
|
|
|
|
// Token: 0x0600B6B0 RID: 46768 RVA: 0x0028143C File Offset: 0x0027F63C
|
|
[Token(Token = "0x600B6B0")]
|
|
[Address(RVA = "0x1C2ED40", Offset = "0x1C2DB40", VA = "0x181C2ED40")]
|
|
private static void Clear(Array array)
|
|
{
|
|
if (array != 0)
|
|
{
|
|
int num = array.System.Collections.ICollection.Count;
|
|
int num2 = 0;
|
|
Array.Clear(array, num2, num);
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B6B1 RID: 46769 RVA: 0x00281460 File Offset: 0x0027F660
|
|
[Token(Token = "0x600B6B1")]
|
|
[Address(RVA = "0x1C2ECC0", Offset = "0x1C2DAC0", VA = "0x181C2ECC0")]
|
|
private static void ClearAll(params Array[] arrays)
|
|
{
|
|
int num = 0;
|
|
int length = arrays.Length;
|
|
if (num < length)
|
|
{
|
|
Array array = arrays[num];
|
|
if (array != 0)
|
|
{
|
|
int num2 = array.System.Collections.ICollection.Count;
|
|
int num3 = 0;
|
|
Array.Clear(array, num3, num2);
|
|
}
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600B6B2 RID: 46770 RVA: 0x002814A4 File Offset: 0x0027F6A4
|
|
[Token(Token = "0x600B6B2")]
|
|
[Address(RVA = "0x1C2F0C0", Offset = "0x1C2DEC0", VA = "0x181C2F0C0")]
|
|
private static bool IsPowerOf2(int x)
|
|
{
|
|
int num = x - 1;
|
|
return x == num;
|
|
}
|
|
|
|
// Token: 0x0600B6B3 RID: 46771 RVA: 0x002814BC File Offset: 0x0027F6BC
|
|
[Token(Token = "0x600B6B3")]
|
|
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
|
|
public SCrypt()
|
|
{
|
|
}
|
|
}
|
|
}
|