Files
Apr2020-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Crypto/Generators/OpenBsdBCrypt.cs
T
niko 8fc35183db a
2026-04-11 22:19:20 +02:00

232 lines
15 KiB
C#

using System;
using System.IO;
using System.Runtime.CompilerServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators
{
// Token: 0x02001C75 RID: 7285
[Token(Token = "0x2001C75")]
public class OpenBsdBCrypt
{
// Token: 0x0600B673 RID: 46707 RVA: 0x0027FEB8 File Offset: 0x0027E0B8
[Token(Token = "0x600B673")]
[Address(RVA = "0x1A33EF0", Offset = "0x1A32CF0", VA = "0x181A33EF0")]
static OpenBsdBCrypt()
{
byte[] array = new byte[64];
RuntimeHelpers.InitializeArray(array, fieldof(<PrivateImplementationDetails>.2CDACAA27B7865A56A57B156CFB369245964BD2B).FieldHandle);
OpenBsdBCrypt.EncodingTable = array;
OpenBsdBCrypt.DecodingTable = new byte[128];
OpenBsdBCrypt.DefaultVersion = "2y";
OpenBsdBCrypt.AllowedVersions = new HashSet();
ISet allowedVersions = OpenBsdBCrypt.AllowedVersions;
ISet allowedVersions2 = OpenBsdBCrypt.AllowedVersions;
ISet allowedVersions3 = OpenBsdBCrypt.AllowedVersions;
int num = 0;
byte[] decodingTable = OpenBsdBCrypt.DecodingTable;
byte[] decodingTable2;
if (num < decodingTable.Length)
{
num++;
decodingTable2 = OpenBsdBCrypt.DecodingTable;
}
if (num < decodingTable2.Length)
{
num++;
}
}
// Token: 0x0600B674 RID: 46708 RVA: 0x0027FF50 File Offset: 0x0027E150
[Token(Token = "0x600B674")]
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
public OpenBsdBCrypt()
{
}
// Token: 0x0600B675 RID: 46709 RVA: 0x0027FF64 File Offset: 0x0027E164
[Token(Token = "0x600B675")]
[Address(RVA = "0x1A32F10", Offset = "0x1A31D10", VA = "0x181A32F10")]
private static string CreateBcryptString(string version, byte[] password, byte[] salt, int cost)
{
/*
An exception occurred when decompiling this method (0600B675)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.String BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators.OpenBsdBCrypt::CreateBcryptString(System.String,System.Byte[],System.Byte[],System.Int32)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_A6:
stloc:ArgumentException(var_21_B5, 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.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: 0x0600B676 RID: 46710 RVA: 0x00280028 File Offset: 0x0027E228
[Token(Token = "0x600B676")]
[Address(RVA = "0x1A33B50", Offset = "0x1A32950", VA = "0x181A33B50")]
public static string Generate(char[] password, byte[] salt, int cost)
{
return OpenBsdBCrypt.Generate(OpenBsdBCrypt.DefaultVersion, password, salt, cost);
}
// Token: 0x0600B677 RID: 46711 RVA: 0x00280044 File Offset: 0x0027E244
[Token(Token = "0x600B677")]
[Address(RVA = "0x1A33BE0", Offset = "0x1A329E0", VA = "0x181A33BE0")]
public static string Generate(string version, char[] password, byte[] salt, int cost)
{
do
{
ISet allowedVersions = OpenBsdBCrypt.AllowedVersions;
}
while (password == 0 || salt == 0 || salt.Length != 16);
byte[] array = Strings.ToUtf8ByteArray(password);
if (array.Length < 72)
{
}
byte[] array2 = new byte[72];
int length = array2.Length;
int num = Math.Min(array.Length, length);
int num2 = 0;
int num3 = 0;
Array.Copy(array, num3, array2, num2, num);
int length2 = array.Length;
int num4 = 0;
Array.Clear(array, num4, length2);
string text = OpenBsdBCrypt.CreateBcryptString(version, array2, salt, cost);
int length3 = array2.Length;
int num5 = 0;
Array.Clear(array2, num5, length3);
return text;
}
// Token: 0x0600B678 RID: 46712 RVA: 0x002800F8 File Offset: 0x0027E2F8
[Token(Token = "0x600B678")]
[Address(RVA = "0x1A32B30", Offset = "0x1A31930", VA = "0x181A32B30")]
public static bool CheckPassword(string bcryptString, char[] password)
{
/*
An exception occurred when decompiling this method (0600B678)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Boolean BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators.OpenBsdBCrypt::CheckPassword(System.String,System.Char[])
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_9D:
stloc:ArgumentException(var_14_B3, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string[exp:object]("Invalid cost factor: "), ldloc:int32[exp:object](var_13), ldstr:string[exp:object](", 4 < cost < 31 expected."))))
}
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: 0x0600B679 RID: 46713 RVA: 0x002801BC File Offset: 0x0027E3BC
[Token(Token = "0x600B679")]
[Address(RVA = "0x1A33770", Offset = "0x1A32570", VA = "0x181A33770")]
private static string EncodeData(byte[] data)
{
int length = data.Length;
int num = 0;
if (length != 16)
{
int num2 = length - 1;
}
byte[] array = new byte[18];
int length2 = data.Length;
int num3 = 0;
int num4 = 0;
Array.Copy(data, num4, array, num3, length2);
MemoryStream memoryStream = new MemoryStream();
if (array.Length > 0)
{
int length3 = array.Length;
num += 2;
byte b = array[num];
byte[] encodingTable = OpenBsdBCrypt.EncodingTable;
byte[] encodingTable2 = OpenBsdBCrypt.EncodingTable;
byte[] encodingTable3 = OpenBsdBCrypt.EncodingTable;
byte[] encodingTable4 = OpenBsdBCrypt.EncodingTable;
num += 3;
}
ulong num5;
if (num5 != (ulong)0L)
{
}
string text;
int stringLength = text.m_stringLength;
int num6 = 0;
return text.Substring(num6, stringLength);
}
// Token: 0x0600B67A RID: 46714 RVA: 0x0028026C File Offset: 0x0027E46C
[Token(Token = "0x600B67A")]
[Address(RVA = "0x1A33320", Offset = "0x1A32120", VA = "0x181A33320")]
private static byte[] DecodeSaltString(string saltString)
{
/*
An exception occurred when decompiling this method (0600B67A)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators.OpenBsdBCrypt::DecodeSaltString(System.String)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_C4:
stloc:ArgumentException(var_24_DA, newobj:ArgumentException(ArgumentException::.ctor, call:string(string::Concat, ldstr:string[exp:object]("Salt string contains invalid character: "), ldloc:int32[exp:object](var_23)), ldstr:string("saltString")))
}
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.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: 0x040073AD RID: 29613
[Token(Token = "0x40073AD")]
private static readonly byte[] EncodingTable;
// Token: 0x040073AE RID: 29614
[Token(Token = "0x40073AE")]
private static readonly byte[] DecodingTable;
// Token: 0x040073AF RID: 29615
[Token(Token = "0x40073AF")]
private static readonly string DefaultVersion;
// Token: 0x040073B0 RID: 29616
[Token(Token = "0x40073B0")]
private static readonly ISet AllowedVersions;
}
}