using System; using System.Runtime.CompilerServices; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities; using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators { // Token: 0x02001D3E RID: 7486 [Token(Token = "0x2001D3E")] public sealed class BCrypt { // Token: 0x0600B9D2 RID: 47570 RVA: 0x002858F8 File Offset: 0x00283AF8 [Token(Token = "0x600B9D2")] [Address(RVA = "0x257CAF0", Offset = "0x257BAF0", VA = "0x18257CAF0")] private BCrypt() { uint[] array = new uint[1024]; this.S = array; uint[] array2 = new uint[18]; this.P = array2; } // Token: 0x0600B9D3 RID: 47571 RVA: 0x0028592C File Offset: 0x00283B2C [Token(Token = "0x600B9D3")] [Address(RVA = "0x257BF80", Offset = "0x257AF80", VA = "0x18257BF80")] private uint F(uint x) { int length = this.S.Length; return x; } // Token: 0x0600B9D4 RID: 47572 RVA: 0x0028594C File Offset: 0x00283B4C [Token(Token = "0x600B9D4")] [Address(RVA = "0x257C7B0", Offset = "0x257B7B0", VA = "0x18257C7B0")] 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: 0x0600B9D5 RID: 47573 RVA: 0x002859C4 File Offset: 0x00283BC4 [Token(Token = "0x600B9D5")] [Address(RVA = "0x257C250", Offset = "0x257B250", VA = "0x18257C250")] 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: 0x0600B9D6 RID: 47574 RVA: 0x00285A70 File Offset: 0x00283C70 [Token(Token = "0x600B9D6")] [Address(RVA = "0x257B480", Offset = "0x257A480", VA = "0x18257B480")] 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: 0x0600B9D7 RID: 47575 RVA: 0x00285AAC File Offset: 0x00283CAC [Token(Token = "0x600B9D7")] [Address(RVA = "0x257BAB0", Offset = "0x257AAB0", VA = "0x18257BAB0")] 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: 0x0600B9D8 RID: 47576 RVA: 0x00285C34 File Offset: 0x00283E34 [Token(Token = "0x600B9D8")] [Address(RVA = "0x257C400", Offset = "0x257B400", VA = "0x18257C400")] 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: 0x0600B9D9 RID: 47577 RVA: 0x00285D24 File Offset: 0x00283F24 [Token(Token = "0x600B9D9")] [Address(RVA = "0x257B540", Offset = "0x257A540", VA = "0x18257B540")] 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: 0x0600B9DA RID: 47578 RVA: 0x00285FB0 File Offset: 0x002841B0 [Token(Token = "0x600B9DA")] [Address(RVA = "0x257C390", Offset = "0x257B390", VA = "0x18257C390")] public static byte[] PasswordToByteArray(char[] password) { byte[] array = Strings.ToUtf8ByteArray(password); int num = 0; return Arrays.Append(array, (byte)num); } // Token: 0x0600B9DB RID: 47579 RVA: 0x00285FD0 File Offset: 0x002841D0 [Token(Token = "0x600B9DB")] [Address(RVA = "0x257C050", Offset = "0x257B050", VA = "0x18257C050")] public static byte[] Generate(byte[] password, byte[] salt, int cost) { /* An exception occurred when decompiling this method (0600B9DB) 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: 0x0600B9DC RID: 47580 RVA: 0x0028603C File Offset: 0x0028423C // Note: this type is marked as 'beforefieldinit'. [Token(Token = "0x600B9DC")] [Address(RVA = "0x257C970", Offset = "0x257B970", VA = "0x18257C970")] static BCrypt() { uint[] array = new uint[6]; RuntimeHelpers.InitializeArray(array, fieldof(.007AFA4B68442DD6E0877DE7624D0A5F508C474F).FieldHandle); BCrypt.MAGIC_STRING = array; uint[] array2 = new uint[18]; RuntimeHelpers.InitializeArray(array2, fieldof(.643A9D76937E94519B73BE072D65E79BAFF3C213).FieldHandle); BCrypt.KP = array2; uint[] array3 = new uint[256]; RuntimeHelpers.InitializeArray(array3, fieldof(.E117A40BF9A3AE32474AD7B22EB4C60E95D3BE2A).FieldHandle); BCrypt.KS0 = array3; uint[] array4 = new uint[256]; RuntimeHelpers.InitializeArray(array4, fieldof(.6F576E8737EAAC9B6B12BDFC370048CD205E2CDD).FieldHandle); BCrypt.KS1 = array4; uint[] array5 = new uint[256]; RuntimeHelpers.InitializeArray(array5, fieldof(.E2F8F75B7ABE5A6E4ECF5E32B935909BE2CC9F4B).FieldHandle); BCrypt.KS2 = array5; uint[] array6 = new uint[256]; RuntimeHelpers.InitializeArray(array6, fieldof(.1C1237F52E2ED7B4D229AE3978DA144B9E653F5E).FieldHandle); BCrypt.KS3 = array6; } // Token: 0x04007525 RID: 29989 [Token(Token = "0x4007525")] private static readonly uint[] MAGIC_STRING; // Token: 0x04007526 RID: 29990 [Token(Token = "0x4007526")] internal const int MAGIC_STRING_LENGTH = 6; // Token: 0x04007527 RID: 29991 [Token(Token = "0x4007527")] private static readonly uint[] KP; // Token: 0x04007528 RID: 29992 [Token(Token = "0x4007528")] private static readonly uint[] KS0; // Token: 0x04007529 RID: 29993 [Token(Token = "0x4007529")] private static readonly uint[] KS1; // Token: 0x0400752A RID: 29994 [Token(Token = "0x400752A")] private static readonly uint[] KS2; // Token: 0x0400752B RID: 29995 [Token(Token = "0x400752B")] private static readonly uint[] KS3; // Token: 0x0400752C RID: 29996 [Token(Token = "0x400752C")] private const int ROUNDS = 16; // Token: 0x0400752D RID: 29997 [Token(Token = "0x400752D")] private const int SBOX_SK = 256; // Token: 0x0400752E RID: 29998 [Token(Token = "0x400752E")] private const int SBOX_SK2 = 512; // Token: 0x0400752F RID: 29999 [Token(Token = "0x400752F")] private const int SBOX_SK3 = 768; // Token: 0x04007530 RID: 30000 [Token(Token = "0x4007530")] private const int P_SZ = 18; // Token: 0x04007531 RID: 30001 [FieldOffset(Offset = "0x10")] [Token(Token = "0x4007531")] private readonly uint[] S; // Token: 0x04007532 RID: 30002 [FieldOffset(Offset = "0x18")] [Token(Token = "0x4007532")] private readonly uint[] P; // Token: 0x04007533 RID: 30003 [Token(Token = "0x4007533")] internal const int SALT_SIZE_BYTES = 16; // Token: 0x04007534 RID: 30004 [Token(Token = "0x4007534")] internal const int MIN_COST = 4; // Token: 0x04007535 RID: 30005 [Token(Token = "0x4007535")] internal const int MAX_COST = 31; // Token: 0x04007536 RID: 30006 [Token(Token = "0x4007536")] internal const int MAX_PASSWORD_BYTES = 72; } }