332 lines
15 KiB
C#
332 lines
15 KiB
C#
using System;
|
|
using System.Collections;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Generators;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Security
|
|
{
|
|
// Token: 0x020019A9 RID: 6569
|
|
[Token(Token = "0x20019A9")]
|
|
public sealed class GeneratorUtilities
|
|
{
|
|
// Token: 0x06009CD8 RID: 40152 RVA: 0x0020C1F4 File Offset: 0x0020A3F4
|
|
[Token(Token = "0x6009CD8")]
|
|
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
|
|
private GeneratorUtilities()
|
|
{
|
|
}
|
|
|
|
// Token: 0x06009CD9 RID: 40153 RVA: 0x0020C208 File Offset: 0x0020A408
|
|
[Token(Token = "0x6009CD9")]
|
|
[Address(RVA = "0x19AEEF0", Offset = "0x19ADCF0", VA = "0x1819AEEF0")]
|
|
static GeneratorUtilities()
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009CD9)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Security.GeneratorUtilities::.cctor()
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_F31:
|
|
stelem:string([mscorlib]System.String, ldloc:string[](var_140_F12), ldc.i4:int32(1), ldstr:string("HMACSHA1"))
|
|
}
|
|
|
|
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: 0x06009CDA RID: 40154 RVA: 0x0020D154 File Offset: 0x0020B354
|
|
[Token(Token = "0x6009CDA")]
|
|
[Address(RVA = "0x19ADA50", Offset = "0x19AC850", VA = "0x1819ADA50")]
|
|
private static void AddDefaultKeySizeEntries(int size, params string[] algorithms)
|
|
{
|
|
int num = 0;
|
|
int length = algorithms.Length;
|
|
if (num < length)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.defaultKeySizes;
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009CDB RID: 40155 RVA: 0x0020D180 File Offset: 0x0020B380
|
|
[Token(Token = "0x6009CDB")]
|
|
[Address(RVA = "0x19ADD80", Offset = "0x19ACB80", VA = "0x1819ADD80")]
|
|
private static void AddKgAlgorithm(string canonicalName, params object[] aliases)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.kgAlgorithms;
|
|
string text = Platform.ToUpperInvariant(canonicalName);
|
|
int num = 0;
|
|
int length = aliases.Length;
|
|
if (num < length)
|
|
{
|
|
object obj = aliases[num];
|
|
IDictionary dictionary2 = GeneratorUtilities.kgAlgorithms;
|
|
int hashCode = obj.GetHashCode();
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009CDC RID: 40156 RVA: 0x0020D1CC File Offset: 0x0020B3CC
|
|
[Token(Token = "0x6009CDC")]
|
|
[Address(RVA = "0x19ADF40", Offset = "0x19ACD40", VA = "0x1819ADF40")]
|
|
private static void AddKpgAlgorithm(string canonicalName, params object[] aliases)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.kpgAlgorithms;
|
|
string text = Platform.ToUpperInvariant(canonicalName);
|
|
int num = 0;
|
|
int length = aliases.Length;
|
|
if (num < length)
|
|
{
|
|
object obj = aliases[num];
|
|
IDictionary dictionary2 = GeneratorUtilities.kpgAlgorithms;
|
|
int hashCode = obj.GetHashCode();
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009CDD RID: 40157 RVA: 0x0020D218 File Offset: 0x0020B418
|
|
[Token(Token = "0x6009CDD")]
|
|
[Address(RVA = "0x19ADB50", Offset = "0x19AC950", VA = "0x1819ADB50")]
|
|
private static void AddHMacKeyGenerator(string algorithm, params object[] aliases)
|
|
{
|
|
string text = "HMAC" + algorithm;
|
|
IDictionary dictionary = GeneratorUtilities.kgAlgorithms;
|
|
IDictionary dictionary2 = GeneratorUtilities.kgAlgorithms;
|
|
string text2 = "HMAC-" + algorithm;
|
|
IDictionary dictionary3 = GeneratorUtilities.kgAlgorithms;
|
|
string text3 = "HMAC/" + algorithm;
|
|
int num = 0;
|
|
int length = aliases.Length;
|
|
if (num < length)
|
|
{
|
|
object obj = aliases[num];
|
|
IDictionary dictionary4 = GeneratorUtilities.kgAlgorithms;
|
|
int hashCode = obj.GetHashCode();
|
|
num++;
|
|
}
|
|
}
|
|
|
|
// Token: 0x06009CDE RID: 40158 RVA: 0x0020D294 File Offset: 0x0020B494
|
|
[Token(Token = "0x6009CDE")]
|
|
[Address(RVA = "0x19AE210", Offset = "0x19AD010", VA = "0x1819AE210")]
|
|
internal static string GetCanonicalKeyGeneratorAlgorithm(string algorithm)
|
|
{
|
|
string text;
|
|
for (;;)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.kgAlgorithms;
|
|
text = Platform.ToUpperInvariant(algorithm);
|
|
if (text == 0)
|
|
{
|
|
break;
|
|
}
|
|
if (text != 0)
|
|
{
|
|
goto Block_1;
|
|
}
|
|
}
|
|
return text;
|
|
Block_1:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009CDF RID: 40159 RVA: 0x0020D2C0 File Offset: 0x0020B4C0
|
|
[Token(Token = "0x6009CDF")]
|
|
[Address(RVA = "0x19AE2F0", Offset = "0x19AD0F0", VA = "0x1819AE2F0")]
|
|
internal static string GetCanonicalKeyPairGeneratorAlgorithm(string algorithm)
|
|
{
|
|
string text;
|
|
for (;;)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.kpgAlgorithms;
|
|
text = Platform.ToUpperInvariant(algorithm);
|
|
if (text == 0)
|
|
{
|
|
break;
|
|
}
|
|
if (text != 0)
|
|
{
|
|
goto Block_1;
|
|
}
|
|
}
|
|
return text;
|
|
Block_1:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009CE0 RID: 40160 RVA: 0x0020D2EC File Offset: 0x0020B4EC
|
|
[Token(Token = "0x6009CE0")]
|
|
[Address(RVA = "0x19AE630", Offset = "0x19AD430", VA = "0x1819AE630")]
|
|
public static CipherKeyGenerator GetKeyGenerator(DerObjectIdentifier oid)
|
|
{
|
|
return GeneratorUtilities.GetKeyGenerator(oid.identifier);
|
|
}
|
|
|
|
// Token: 0x06009CE1 RID: 40161 RVA: 0x0020D30C File Offset: 0x0020B50C
|
|
[Token(Token = "0x6009CE1")]
|
|
[Address(RVA = "0x19AE690", Offset = "0x19AD490", VA = "0x1819AE690")]
|
|
public static CipherKeyGenerator GetKeyGenerator(string algorithm)
|
|
{
|
|
string canonicalKeyGeneratorAlgorithm = GeneratorUtilities.GetCanonicalKeyGeneratorAlgorithm(algorithm);
|
|
if (canonicalKeyGeneratorAlgorithm != 0)
|
|
{
|
|
int num = GeneratorUtilities.FindDefaultKeySize(canonicalKeyGeneratorAlgorithm);
|
|
if (num == -1)
|
|
{
|
|
goto IL_6C;
|
|
}
|
|
if (!string.Equals(canonicalKeyGeneratorAlgorithm, "DES"))
|
|
{
|
|
if (!string.Equals(canonicalKeyGeneratorAlgorithm, "DESEDE") && !string.Equals(canonicalKeyGeneratorAlgorithm, "DESEDE3"))
|
|
{
|
|
return new CipherKeyGenerator(num);
|
|
}
|
|
DesEdeKeyGenerator desEdeKeyGenerator = new DesEdeKeyGenerator(num);
|
|
}
|
|
DesKeyGenerator desKeyGenerator = new DesKeyGenerator(num);
|
|
}
|
|
SecurityUtilityException ex = new SecurityUtilityException("KeyGenerator " + algorithm + " not recognised.");
|
|
IL_6C:
|
|
string[] array = new string[5];
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009CE2 RID: 40162 RVA: 0x0020D3F4 File Offset: 0x0020B5F4
|
|
[Token(Token = "0x6009CE2")]
|
|
[Address(RVA = "0x19AE940", Offset = "0x19AD740", VA = "0x1819AE940")]
|
|
public static IAsymmetricCipherKeyPairGenerator GetKeyPairGenerator(DerObjectIdentifier oid)
|
|
{
|
|
return GeneratorUtilities.GetKeyPairGenerator(oid.identifier);
|
|
}
|
|
|
|
// Token: 0x06009CE3 RID: 40163 RVA: 0x0020D414 File Offset: 0x0020B614
|
|
[Token(Token = "0x6009CE3")]
|
|
[Address(RVA = "0x19AE9A0", Offset = "0x19AD7A0", VA = "0x1819AE9A0")]
|
|
public static IAsymmetricCipherKeyPairGenerator GetKeyPairGenerator(string algorithm)
|
|
{
|
|
string text;
|
|
do
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.kpgAlgorithms;
|
|
text = Platform.ToUpperInvariant(algorithm);
|
|
}
|
|
while (text == 0 || text == 0);
|
|
if (text == 0)
|
|
{
|
|
if (text == 0)
|
|
{
|
|
bool flag = Platform.StartsWith(text, "EC");
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
if (!flag)
|
|
{
|
|
string[] array = new string[5];
|
|
throw new NullReferenceException();
|
|
}
|
|
X448KeyPairGenerator x448KeyPairGenerator = new X448KeyPairGenerator();
|
|
}
|
|
X25519KeyPairGenerator x25519KeyPairGenerator = new X25519KeyPairGenerator();
|
|
}
|
|
RsaKeyPairGenerator rsaKeyPairGenerator = new RsaKeyPairGenerator();
|
|
}
|
|
Gost3410KeyPairGenerator gost3410KeyPairGenerator = new Gost3410KeyPairGenerator();
|
|
}
|
|
ElGamalKeyPairGenerator elGamalKeyPairGenerator = new ElGamalKeyPairGenerator();
|
|
}
|
|
Ed448KeyPairGenerator ed448KeyPairGenerator = new Ed448KeyPairGenerator();
|
|
}
|
|
Ed25519KeyPairGenerator ed25519KeyPairGenerator = new Ed25519KeyPairGenerator();
|
|
}
|
|
ECKeyPairGenerator eckeyPairGenerator = new ECKeyPairGenerator(text);
|
|
}
|
|
DsaKeyPairGenerator dsaKeyPairGenerator = new DsaKeyPairGenerator();
|
|
}
|
|
DHKeyPairGenerator dhkeyPairGenerator = new DHKeyPairGenerator();
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009CE4 RID: 40164 RVA: 0x0020D528 File Offset: 0x0020B728
|
|
[Token(Token = "0x6009CE4")]
|
|
[Address(RVA = "0x19AE5D0", Offset = "0x19AD3D0", VA = "0x1819AE5D0")]
|
|
internal static int GetDefaultKeySize(DerObjectIdentifier oid)
|
|
{
|
|
return GeneratorUtilities.GetDefaultKeySize(oid.identifier);
|
|
}
|
|
|
|
// Token: 0x06009CE5 RID: 40165 RVA: 0x0020D548 File Offset: 0x0020B748
|
|
[Token(Token = "0x6009CE5")]
|
|
[Address(RVA = "0x19AE3D0", Offset = "0x19AD1D0", VA = "0x1819AE3D0")]
|
|
internal static int GetDefaultKeySize(string algorithm)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009CE5)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Int32 BestHTTP.SecureProtocol.Org.BouncyCastle.Security.GeneratorUtilities::GetDefaultKeySize(System.String)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
IL_85:
|
|
stloc:SecurityUtilityException(var_4_9A, newobj:SecurityUtilityException(SecurityUtilityException::.ctor, call:string(string::Concat, ldstr:string("KeyGenerator "), ldloc:string(algorithm), ldstr:string(" not recognised."))))
|
|
}
|
|
|
|
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 1663
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06009CE6 RID: 40166 RVA: 0x0020D5F0 File Offset: 0x0020B7F0
|
|
[Token(Token = "0x6009CE6")]
|
|
[Address(RVA = "0x19AE100", Offset = "0x19ACF00", VA = "0x1819AE100")]
|
|
private static int FindDefaultKeySize(string canonicalName)
|
|
{
|
|
IDictionary dictionary = GeneratorUtilities.defaultKeySizes;
|
|
IDictionary dictionary2 = GeneratorUtilities.defaultKeySizes;
|
|
IDictionary dictionary3 = GeneratorUtilities.kgAlgorithms;
|
|
return -1;
|
|
}
|
|
|
|
// Token: 0x040069DD RID: 27101
|
|
[Token(Token = "0x40069DD")]
|
|
private static readonly IDictionary kgAlgorithms;
|
|
|
|
// Token: 0x040069DE RID: 27102
|
|
[Token(Token = "0x40069DE")]
|
|
private static readonly IDictionary kpgAlgorithms;
|
|
|
|
// Token: 0x040069DF RID: 27103
|
|
[Token(Token = "0x40069DF")]
|
|
private static readonly IDictionary defaultKeySizes;
|
|
}
|
|
}
|