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: 0x02001D5D RID: 7517
|
|
[Token(Token = "0x2001D5D")]
|
|
public class SCrypt
|
|
{
|
|
// Token: 0x0600BA78 RID: 47736 RVA: 0x0028A1B4 File Offset: 0x002883B4
|
|
[Token(Token = "0x600BA78")]
|
|
[Address(RVA = "0x25C5F10", Offset = "0x25C4F10", VA = "0x1825C5F10")]
|
|
public static byte[] Generate(byte[] P, byte[] S, int N, int r, int p, int dkLen)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600BA78)
|
|
|
|
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 1663
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x0600BA79 RID: 47737 RVA: 0x0028A1FC File Offset: 0x002883FC
|
|
[Token(Token = "0x600BA79")]
|
|
[Address(RVA = "0x25C6270", Offset = "0x25C5270", VA = "0x1825C6270")]
|
|
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: 0x0600BA7A RID: 47738 RVA: 0x0028A2C0 File Offset: 0x002884C0
|
|
[Token(Token = "0x600BA7A")]
|
|
[Address(RVA = "0x25C6A90", Offset = "0x25C5A90", VA = "0x1825C6A90")]
|
|
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: 0x0600BA7B RID: 47739 RVA: 0x0028A2F4 File Offset: 0x002884F4
|
|
[Token(Token = "0x600BA7B")]
|
|
[Address(RVA = "0x25C64F0", Offset = "0x25C54F0", VA = "0x1825C64F0")]
|
|
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: 0x0600BA7C RID: 47740 RVA: 0x0028A494 File Offset: 0x00288694
|
|
[Token(Token = "0x600BA7C")]
|
|
[Address(RVA = "0x25C5CE0", Offset = "0x25C4CE0", VA = "0x1825C5CE0")]
|
|
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: 0x0600BA7D RID: 47741 RVA: 0x0028A51C File Offset: 0x0028871C
|
|
[Token(Token = "0x600BA7D")]
|
|
[Address(RVA = "0x25C6C00", Offset = "0x25C5C00", VA = "0x1825C6C00")]
|
|
private static void Xor(uint[] a, uint[] b, int bOff, uint[] output)
|
|
{
|
|
int length = output.Length;
|
|
uint num = b[bOff];
|
|
output[0] = num;
|
|
}
|
|
|
|
// Token: 0x0600BA7E RID: 47742 RVA: 0x0028A548 File Offset: 0x00288748
|
|
[Token(Token = "0x600BA7E")]
|
|
[Address(RVA = "0x25C5EE0", Offset = "0x25C4EE0", VA = "0x1825C5EE0")]
|
|
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: 0x0600BA7F RID: 47743 RVA: 0x0028A56C File Offset: 0x0028876C
|
|
[Token(Token = "0x600BA7F")]
|
|
[Address(RVA = "0x25C5E60", Offset = "0x25C4E60", VA = "0x1825C5E60")]
|
|
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: 0x0600BA80 RID: 47744 RVA: 0x0028A5B0 File Offset: 0x002887B0
|
|
[Token(Token = "0x600BA80")]
|
|
[Address(RVA = "0x25C6260", Offset = "0x25C5260", VA = "0x1825C6260")]
|
|
private static bool IsPowerOf2(int x)
|
|
{
|
|
int num = x - 1;
|
|
return x == num;
|
|
}
|
|
|
|
// Token: 0x0600BA81 RID: 47745 RVA: 0x0028A5C8 File Offset: 0x002887C8
|
|
[Token(Token = "0x600BA81")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
public SCrypt()
|
|
{
|
|
}
|
|
}
|
|
}
|