using System; using System.IO; using System.Runtime.InteropServices; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1; using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs; using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto; using BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs; using Cpp2IlInjected; namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Security { // Token: 0x020013D4 RID: 5076 [Token(Token = "0x20013D4")] [StructLayout(3)] public sealed class PrivateKeyFactory { // Token: 0x06008149 RID: 33097 RVA: 0x001B7A78 File Offset: 0x001B5C78 [Token(Token = "0x6008149")] [Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")] private PrivateKeyFactory() { } // Token: 0x0600814A RID: 33098 RVA: 0x001B7A8C File Offset: 0x001B5C8C [Token(Token = "0x600814A")] [Address(RVA = "0x48A5A0", Offset = "0x488FA0", VA = "0x18048A5A0")] public static AsymmetricKeyParameter CreateKey(byte[] privateKeyInfoData) { return PrivateKeyFactory.CreateKey(PrivateKeyInfo.GetInstance(Asn1Object.FromByteArray(privateKeyInfoData))); } // Token: 0x0600814B RID: 33099 RVA: 0x001B7AAC File Offset: 0x001B5CAC [Token(Token = "0x600814B")] [Address(RVA = "0x48A5D0", Offset = "0x488FD0", VA = "0x18048A5D0")] public static AsymmetricKeyParameter CreateKey(Stream inStr) { return PrivateKeyFactory.CreateKey(PrivateKeyInfo.GetInstance(Asn1Object.FromStream(inStr))); } // Token: 0x0600814C RID: 33100 RVA: 0x001B7ACC File Offset: 0x001B5CCC [Token(Token = "0x600814C")] [Address(RVA = "0x489620", Offset = "0x488020", VA = "0x180489620")] public static AsymmetricKeyParameter CreateKey(PrivateKeyInfo keyInfo) { /* An exception occurred when decompiling this method (0600814C) ICSharpCode.Decompiler.DecompilerException: Error decompiling BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.AsymmetricKeyParameter BestHTTP.SecureProtocol.Org.BouncyCastle.Security.PrivateKeyFactory::CreateKey(BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs.PrivateKeyInfo) ---> System.Exception: Basic block has to end with unconditional control flow. { IL_2D9: stloc:ArgumentException(var_91_2E3, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("Unrecognized curve OID for GostR3410x2001 private key"))) } 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: 0x0600814D RID: 33101 RVA: 0x001B7DC0 File Offset: 0x001B5FC0 [Token(Token = "0x600814D")] [Address(RVA = "0x48A760", Offset = "0x489160", VA = "0x18048A760")] private static byte[] GetRawKey(PrivateKeyInfo keyInfo, int expectedSize) { /* An exception occurred when decompiling this method (0600814D) ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Security.PrivateKeyFactory::GetRawKey(BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs.PrivateKeyInfo,System.Int32) ---> System.Exception: Basic block has to end with unconditional control flow. { IL_1A: stloc:SecurityUtilityException(var_1_24, newobj:SecurityUtilityException(SecurityUtilityException::.ctor, ldstr:string("private key encoding has incorrect length"))) } 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: 0x0600814E RID: 33102 RVA: 0x001B7DF4 File Offset: 0x001B5FF4 [Token(Token = "0x600814E")] [Address(RVA = "0x48A680", Offset = "0x489080", VA = "0x18048A680")] public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, EncryptedPrivateKeyInfo encInfo) { return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, encInfo)); } // Token: 0x0600814F RID: 33103 RVA: 0x001B7E10 File Offset: 0x001B6010 [Token(Token = "0x600814F")] [Address(RVA = "0x48A600", Offset = "0x489000", VA = "0x18048A600")] public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, byte[] encryptedPrivateKeyInfoData) { EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(Asn1Object.FromByteArray(encryptedPrivateKeyInfoData)); return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance)); } // Token: 0x06008150 RID: 33104 RVA: 0x001B7E38 File Offset: 0x001B6038 [Token(Token = "0x6008150")] [Address(RVA = "0x48A6A0", Offset = "0x4890A0", VA = "0x18048A6A0")] public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, Stream encryptedPrivateKeyInfoStream) { EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(Asn1Object.FromStream(encryptedPrivateKeyInfoStream)); return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance)); } // Token: 0x06008151 RID: 33105 RVA: 0x001B7E60 File Offset: 0x001B6060 [Token(Token = "0x6008151")] [Address(RVA = "0x48A640", Offset = "0x489040", VA = "0x18048A640")] private static AsymmetricKeyParameter DecryptKey(char[] passPhrase, Asn1Object asn1Object) { EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(asn1Object); return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance)); } // Token: 0x06008152 RID: 33106 RVA: 0x001B7E80 File Offset: 0x001B6080 [Token(Token = "0x6008152")] [Address(RVA = "0x48A720", Offset = "0x489120", VA = "0x18048A720")] public static byte[] EncryptKey(DerObjectIdentifier algorithm, char[] passPhrase, byte[] salt, int iterationCount, AsymmetricKeyParameter key) { EncryptedPrivateKeyInfo encryptedPrivateKeyInfo; return encryptedPrivateKeyInfo.GetEncoded(); } // Token: 0x06008153 RID: 33107 RVA: 0x001B7E9C File Offset: 0x001B609C [Token(Token = "0x6008153")] [Address(RVA = "0x48A6E0", Offset = "0x4890E0", VA = "0x18048A6E0")] public static byte[] EncryptKey(string algorithm, char[] passPhrase, byte[] salt, int iterationCount, AsymmetricKeyParameter key) { EncryptedPrivateKeyInfo encryptedPrivateKeyInfo; return encryptedPrivateKeyInfo.GetEncoded(); } } }