scripts
This commit is contained in:
@@ -0,0 +1,423 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
|
||||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
||||
using Cpp2IlInjected;
|
||||
|
||||
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators
|
||||
{
|
||||
// Token: 0x02001681 RID: 5761
|
||||
[Token(Token = "0x2001681")]
|
||||
[StructLayout(3)]
|
||||
public sealed class BCrypt
|
||||
{
|
||||
// Token: 0x06009A2A RID: 39466 RVA: 0x0022518C File Offset: 0x0022338C
|
||||
[Token(Token = "0x6009A2A")]
|
||||
[Address(RVA = "0x1F4D1A0", Offset = "0x1F4BBA0", VA = "0x181F4D1A0")]
|
||||
private BCrypt()
|
||||
{
|
||||
uint[] array = new uint[1024];
|
||||
this.S = array;
|
||||
uint[] array2 = new uint[18];
|
||||
this.P = array2;
|
||||
}
|
||||
|
||||
// Token: 0x06009A2B RID: 39467 RVA: 0x002251C0 File Offset: 0x002233C0
|
||||
[Token(Token = "0x6009A2B")]
|
||||
[Address(RVA = "0x1F4C630", Offset = "0x1F4B030", VA = "0x181F4C630")]
|
||||
private uint F(uint x)
|
||||
{
|
||||
int length = this.S.Length;
|
||||
return x;
|
||||
}
|
||||
|
||||
// Token: 0x06009A2C RID: 39468 RVA: 0x002251E0 File Offset: 0x002233E0
|
||||
[Token(Token = "0x6009A2C")]
|
||||
[Address(RVA = "0x1F4CE60", Offset = "0x1F4B860", VA = "0x181F4CE60")]
|
||||
private void ProcessTable(uint xl, uint xr, uint[] table)
|
||||
{
|
||||
int length = table.Length;
|
||||
int num = 0;
|
||||
if (length > 0)
|
||||
{
|
||||
uint[] p = this.P;
|
||||
uint num2 = this.F(xl);
|
||||
uint[] p2 = this.P;
|
||||
uint num3 = this.F(xl);
|
||||
uint[] p3 = this.P;
|
||||
int length2 = p3.Length;
|
||||
uint num5;
|
||||
uint num4 = num5 + 1U;
|
||||
num5 += (uint)2;
|
||||
uint num6 = p3[8];
|
||||
num++;
|
||||
table[0] = xl;
|
||||
num += 2;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06009A2D RID: 39469 RVA: 0x00225258 File Offset: 0x00223458
|
||||
[Token(Token = "0x6009A2D")]
|
||||
[Address(RVA = "0x1F4C900", Offset = "0x1F4B300", VA = "0x181F4C900")]
|
||||
private void InitState()
|
||||
{
|
||||
uint[] s = this.S;
|
||||
int num = 0;
|
||||
int num2 = 0;
|
||||
ulong num3;
|
||||
Array.Copy(BCrypt.KS0, num2, s, num, (int)num3);
|
||||
uint[] s2 = this.S;
|
||||
int num4 = 0;
|
||||
ulong num5;
|
||||
Array.Copy(BCrypt.KS1, num4, s2, 256, (int)num5);
|
||||
uint[] s3 = this.S;
|
||||
int num6 = 0;
|
||||
ulong num7;
|
||||
Array.Copy(BCrypt.KS2, num6, s3, 512, (int)num7);
|
||||
uint[] s4 = this.S;
|
||||
int num8 = 0;
|
||||
ulong num9;
|
||||
Array.Copy(BCrypt.KS3, num8, s4, 768, (int)num9);
|
||||
int num10 = 0;
|
||||
uint[] p = this.P;
|
||||
int num11 = 0;
|
||||
ulong num12;
|
||||
Array.Copy(BCrypt.KP, num11, p, num10, (int)num12);
|
||||
}
|
||||
|
||||
// Token: 0x06009A2E RID: 39470 RVA: 0x00225304 File Offset: 0x00223504
|
||||
[Token(Token = "0x6009A2E")]
|
||||
[Address(RVA = "0x1F4BB30", Offset = "0x1F4A530", VA = "0x181F4BB30")]
|
||||
private void CyclicXorKey(byte[] key)
|
||||
{
|
||||
int length = key.Length;
|
||||
int num = 0;
|
||||
int length2 = key.Length;
|
||||
int num2 = 0;
|
||||
num2++;
|
||||
uint[] p = this.P;
|
||||
num++;
|
||||
}
|
||||
|
||||
// Token: 0x06009A2F RID: 39471 RVA: 0x00225340 File Offset: 0x00223540
|
||||
[Token(Token = "0x6009A2F")]
|
||||
[Address(RVA = "0x1F4C160", Offset = "0x1F4AB60", VA = "0x181F4C160")]
|
||||
private byte[] EncryptMagicString()
|
||||
{
|
||||
uint[] array = new uint[6];
|
||||
uint num = BCrypt.MAGIC_STRING[0];
|
||||
array[0] = num;
|
||||
uint num2 = BCrypt.MAGIC_STRING[0];
|
||||
array[0] = num2;
|
||||
uint num3 = BCrypt.MAGIC_STRING[1];
|
||||
array[1] = num3;
|
||||
uint num4 = BCrypt.MAGIC_STRING[1];
|
||||
array[1] = num4;
|
||||
uint num5 = BCrypt.MAGIC_STRING[2];
|
||||
array[2] = num5;
|
||||
uint num6 = BCrypt.MAGIC_STRING[2];
|
||||
array[2] = num6;
|
||||
int num7 = 0;
|
||||
int length = array.Length;
|
||||
uint num8 = this.P[0];
|
||||
num7 += 8;
|
||||
uint num9 = this.F(num8);
|
||||
uint[] p = this.P;
|
||||
uint num10 = this.F(num8);
|
||||
uint[] p2 = this.P;
|
||||
int length2 = p2.Length;
|
||||
uint num12;
|
||||
uint num11 = num12 + 1U;
|
||||
num12 += (uint)2;
|
||||
uint num13 = p2[8];
|
||||
num7.m_value = (int)num13;
|
||||
num7 += 2;
|
||||
array[0] = num8;
|
||||
ulong num14;
|
||||
num14 += (ulong)1L;
|
||||
byte[] array2 = new byte[24];
|
||||
int num15 = 0;
|
||||
Pack.UInt32_To_BE(array, array2, num15);
|
||||
int length3 = array.Length;
|
||||
int num16 = 0;
|
||||
Array.Clear(array, num16, length3);
|
||||
uint[] p3 = this.P;
|
||||
int length4 = p3.Length;
|
||||
int num17 = 0;
|
||||
Array.Clear(p3, num17, length4);
|
||||
uint[] s = this.S;
|
||||
int length5 = s.Length;
|
||||
int num18 = 0;
|
||||
Array.Clear(s, num18, length5);
|
||||
return array2;
|
||||
}
|
||||
|
||||
// Token: 0x06009A30 RID: 39472 RVA: 0x002254C8 File Offset: 0x002236C8
|
||||
[Token(Token = "0x6009A30")]
|
||||
[Address(RVA = "0x1F4CAB0", Offset = "0x1F4B4B0", VA = "0x181F4CAB0")]
|
||||
private void ProcessTableWithSalt(uint[] table, uint[] salt32Bit, uint iv1, uint iv2)
|
||||
{
|
||||
int length = salt32Bit.Length;
|
||||
uint num = salt32Bit[0];
|
||||
int length2 = table.Length;
|
||||
int num2 = 0;
|
||||
if (length2 > 0)
|
||||
{
|
||||
uint[] p = this.P;
|
||||
uint num3 = this.F(iv1);
|
||||
uint[] p2 = this.P;
|
||||
uint num4 = this.F(iv1);
|
||||
int length3 = this.P.Length;
|
||||
uint num6;
|
||||
uint num5 = num6 + 1U;
|
||||
num6 += (uint)2;
|
||||
table[0] = num;
|
||||
table[0] = iv1;
|
||||
int length4 = salt32Bit.Length;
|
||||
num2 += 2;
|
||||
uint num7 = this.P[0];
|
||||
uint num8 = this.F(num7);
|
||||
uint[] p3 = this.P;
|
||||
uint num9 = this.F(iv1);
|
||||
int length5 = this.P.Length;
|
||||
uint num11;
|
||||
uint num10 = num11 + 1U;
|
||||
num11 += (uint)2;
|
||||
table[0] = iv1;
|
||||
table[0] = iv1;
|
||||
int length6 = salt32Bit.Length;
|
||||
num2 += 4;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06009A31 RID: 39473 RVA: 0x002255B8 File Offset: 0x002237B8
|
||||
[Token(Token = "0x6009A31")]
|
||||
[Address(RVA = "0x1F4BBF0", Offset = "0x1F4A5F0", VA = "0x181F4BBF0")]
|
||||
private byte[] DeriveRawKey(int cost, byte[] salt, byte[] psw)
|
||||
{
|
||||
while (salt.Length != 16)
|
||||
{
|
||||
}
|
||||
if (psw.Length == 0)
|
||||
{
|
||||
byte[] array = new byte[4];
|
||||
}
|
||||
int num = 0;
|
||||
uint[] s = this.S;
|
||||
int num2 = 0;
|
||||
int num3 = 0;
|
||||
ulong num4;
|
||||
Array.Copy(BCrypt.KS0, num3, s, num2, (int)num4);
|
||||
uint[] s2 = this.S;
|
||||
int num5 = 0;
|
||||
ulong num6;
|
||||
Array.Copy(BCrypt.KS1, num5, s2, 256, (int)num6);
|
||||
uint[] s3 = this.S;
|
||||
int num7 = 0;
|
||||
ulong num8;
|
||||
Array.Copy(BCrypt.KS2, num7, s3, 512, (int)num8);
|
||||
uint[] s4 = this.S;
|
||||
int num9 = 0;
|
||||
ulong num10;
|
||||
Array.Copy(BCrypt.KS3, num9, s4, 768, (int)num10);
|
||||
int num11 = 0;
|
||||
uint[] p = this.P;
|
||||
int num12 = 0;
|
||||
ulong num13;
|
||||
Array.Copy(BCrypt.KP, num12, p, num11, (int)num13);
|
||||
uint[] array2 = new uint[0];
|
||||
int num14 = 0;
|
||||
Pack.BE_To_UInt32(salt, num14, array2);
|
||||
uint[] array3 = new uint[salt.Length];
|
||||
uint num15 = array2[1];
|
||||
array3[0] = num15;
|
||||
uint num16 = array2[1];
|
||||
array3[0] = num16;
|
||||
uint num17 = array2[0];
|
||||
array3[1] = num17;
|
||||
uint num18 = array2[0];
|
||||
array3[1] = num18;
|
||||
this.CyclicXorKey(psw);
|
||||
uint[] p2 = this.P;
|
||||
int num19 = 0;
|
||||
this.ProcessTableWithSalt(p2, array2, (uint)num19, (uint)num);
|
||||
int num20 = array2.Length;
|
||||
int num21 = 0;
|
||||
Array.Clear(array2, num21, num20);
|
||||
uint[] p3 = this.P;
|
||||
num20 = p3.Length;
|
||||
uint num22 = p3[num21];
|
||||
uint num23 = p3[num20];
|
||||
uint[] s5 = this.S;
|
||||
this.ProcessTableWithSalt(s5, array3, num22, num23);
|
||||
int length = array3.Length;
|
||||
int num24 = 0;
|
||||
Array.Clear(array3, num24, length);
|
||||
this.CyclicXorKey(psw);
|
||||
uint[] p4 = this.P;
|
||||
int num25 = 0;
|
||||
int num26 = 0;
|
||||
this.ProcessTable((uint)num26, (uint)num25, p4);
|
||||
uint[] p5 = this.P;
|
||||
int length2 = p5.Length;
|
||||
uint[] s6 = this.S;
|
||||
uint num27 = p5[8];
|
||||
uint num28 = p5[8];
|
||||
this.ProcessTable(num28, num27, s6);
|
||||
this.CyclicXorKey(salt);
|
||||
uint[] p6 = this.P;
|
||||
int num29 = 0;
|
||||
int num30 = 0;
|
||||
this.ProcessTable((uint)num30, (uint)num29, p6);
|
||||
uint[] p7 = this.P;
|
||||
int length3 = p7.Length;
|
||||
uint[] s7 = this.S;
|
||||
uint num31 = p7[8];
|
||||
uint num32 = p7[8];
|
||||
this.ProcessTable(num32, num31, s7);
|
||||
num++;
|
||||
while (num != 1)
|
||||
{
|
||||
}
|
||||
return this.EncryptMagicString();
|
||||
}
|
||||
|
||||
// Token: 0x06009A32 RID: 39474 RVA: 0x00225844 File Offset: 0x00223A44
|
||||
[Token(Token = "0x6009A32")]
|
||||
[Address(RVA = "0x1F4CA40", Offset = "0x1F4B440", VA = "0x181F4CA40")]
|
||||
public static byte[] PasswordToByteArray(char[] password)
|
||||
{
|
||||
byte[] array = Strings.ToUtf8ByteArray(password);
|
||||
int num = 0;
|
||||
return Arrays.Append(array, (byte)num);
|
||||
}
|
||||
|
||||
// Token: 0x06009A33 RID: 39475 RVA: 0x00225864 File Offset: 0x00223A64
|
||||
[Token(Token = "0x6009A33")]
|
||||
[Address(RVA = "0x1F4C700", Offset = "0x1F4B100", VA = "0x181F4C700")]
|
||||
public static byte[] Generate(byte[] password, byte[] salt, int cost)
|
||||
{
|
||||
/*
|
||||
An exception occurred when decompiling this method (06009A33)
|
||||
|
||||
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators.BCrypt::Generate(System.Byte[],System.Byte[],System.Int32)
|
||||
|
||||
---> System.Exception: Basic block has to end with unconditional control flow.
|
||||
{
|
||||
IL_43:
|
||||
stloc:ArgumentNullException(var_4_4D, newobj:ArgumentNullException(ArgumentNullException::.ctor, ldstr:string("password")))
|
||||
stloc:ArgumentException(var_5_5E, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("BCrypt cost must be from 4..31"), ldstr:string("cost")))
|
||||
}
|
||||
|
||||
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: 0x06009A34 RID: 39476 RVA: 0x002258D0 File Offset: 0x00223AD0
|
||||
// Note: this type is marked as 'beforefieldinit'.
|
||||
[Token(Token = "0x6009A34")]
|
||||
[Address(RVA = "0x1F4D020", Offset = "0x1F4BA20", VA = "0x181F4D020")]
|
||||
static BCrypt()
|
||||
{
|
||||
uint[] array = new uint[6];
|
||||
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.007AFA4B68442DD6E0877DE7624D0A5F508C474F).FieldHandle);
|
||||
BCrypt.MAGIC_STRING = array;
|
||||
uint[] array2 = new uint[18];
|
||||
RuntimeHelpers.InitializeArray(array2, fieldof(<PrivateImplementationDetails>.643A9D76937E94519B73BE072D65E79BAFF3C213).FieldHandle);
|
||||
BCrypt.KP = array2;
|
||||
uint[] array3 = new uint[256];
|
||||
RuntimeHelpers.InitializeArray(array3, fieldof(<PrivateImplementationDetails>.E117A40BF9A3AE32474AD7B22EB4C60E95D3BE2A).FieldHandle);
|
||||
BCrypt.KS0 = array3;
|
||||
uint[] array4 = new uint[256];
|
||||
RuntimeHelpers.InitializeArray(array4, fieldof(<PrivateImplementationDetails>.6F576E8737EAAC9B6B12BDFC370048CD205E2CDD).FieldHandle);
|
||||
BCrypt.KS1 = array4;
|
||||
uint[] array5 = new uint[256];
|
||||
RuntimeHelpers.InitializeArray(array5, fieldof(<PrivateImplementationDetails>.E2F8F75B7ABE5A6E4ECF5E32B935909BE2CC9F4B).FieldHandle);
|
||||
BCrypt.KS2 = array5;
|
||||
uint[] array6 = new uint[256];
|
||||
RuntimeHelpers.InitializeArray(array6, fieldof(<PrivateImplementationDetails>.1C1237F52E2ED7B4D229AE3978DA144B9E653F5E).FieldHandle);
|
||||
BCrypt.KS3 = array6;
|
||||
}
|
||||
|
||||
// Token: 0x04006529 RID: 25897
|
||||
[Token(Token = "0x4006529")]
|
||||
private static readonly uint[] MAGIC_STRING;
|
||||
|
||||
// Token: 0x0400652A RID: 25898
|
||||
[Token(Token = "0x400652A")]
|
||||
internal const int MAGIC_STRING_LENGTH = 6;
|
||||
|
||||
// Token: 0x0400652B RID: 25899
|
||||
[Token(Token = "0x400652B")]
|
||||
private static readonly uint[] KP;
|
||||
|
||||
// Token: 0x0400652C RID: 25900
|
||||
[Token(Token = "0x400652C")]
|
||||
private static readonly uint[] KS0;
|
||||
|
||||
// Token: 0x0400652D RID: 25901
|
||||
[Token(Token = "0x400652D")]
|
||||
private static readonly uint[] KS1;
|
||||
|
||||
// Token: 0x0400652E RID: 25902
|
||||
[Token(Token = "0x400652E")]
|
||||
private static readonly uint[] KS2;
|
||||
|
||||
// Token: 0x0400652F RID: 25903
|
||||
[Token(Token = "0x400652F")]
|
||||
private static readonly uint[] KS3;
|
||||
|
||||
// Token: 0x04006530 RID: 25904
|
||||
[Token(Token = "0x4006530")]
|
||||
private const int ROUNDS = 16;
|
||||
|
||||
// Token: 0x04006531 RID: 25905
|
||||
[Token(Token = "0x4006531")]
|
||||
private const int SBOX_SK = 256;
|
||||
|
||||
// Token: 0x04006532 RID: 25906
|
||||
[Token(Token = "0x4006532")]
|
||||
private const int SBOX_SK2 = 512;
|
||||
|
||||
// Token: 0x04006533 RID: 25907
|
||||
[Token(Token = "0x4006533")]
|
||||
private const int SBOX_SK3 = 768;
|
||||
|
||||
// Token: 0x04006534 RID: 25908
|
||||
[Token(Token = "0x4006534")]
|
||||
private const int P_SZ = 18;
|
||||
|
||||
// Token: 0x04006535 RID: 25909
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
||||
[Token(Token = "0x4006535")]
|
||||
private readonly uint[] S;
|
||||
|
||||
// Token: 0x04006536 RID: 25910
|
||||
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
||||
[Token(Token = "0x4006536")]
|
||||
private readonly uint[] P;
|
||||
|
||||
// Token: 0x04006537 RID: 25911
|
||||
[Token(Token = "0x4006537")]
|
||||
internal const int SALT_SIZE_BYTES = 16;
|
||||
|
||||
// Token: 0x04006538 RID: 25912
|
||||
[Token(Token = "0x4006538")]
|
||||
internal const int MIN_COST = 4;
|
||||
|
||||
// Token: 0x04006539 RID: 25913
|
||||
[Token(Token = "0x4006539")]
|
||||
internal const int MAX_COST = 31;
|
||||
|
||||
// Token: 0x0400653A RID: 25914
|
||||
[Token(Token = "0x400653A")]
|
||||
internal const int MAX_PASSWORD_BYTES = 72;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user