Files
Aug2021-Cpp2IL-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Security/PrivateKeyFactory.cs
T
2026-04-10 22:50:51 +02:00

147 lines
10 KiB
C#

using System;
using System.IO;
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: 0x020019B1 RID: 6577
[Token(Token = "0x20019B1")]
public sealed class PrivateKeyFactory
{
// Token: 0x06009D23 RID: 40227 RVA: 0x0020F038 File Offset: 0x0020D238
[Token(Token = "0x6009D23")]
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
private PrivateKeyFactory()
{
}
// Token: 0x06009D24 RID: 40228 RVA: 0x0020F04C File Offset: 0x0020D24C
[Token(Token = "0x6009D24")]
[Address(RVA = "0x1B20110", Offset = "0x1B1EF10", VA = "0x181B20110")]
public static AsymmetricKeyParameter CreateKey(byte[] privateKeyInfoData)
{
return PrivateKeyFactory.CreateKey(PrivateKeyInfo.GetInstance(Asn1Object.FromByteArray(privateKeyInfoData)));
}
// Token: 0x06009D25 RID: 40229 RVA: 0x0020F06C File Offset: 0x0020D26C
[Token(Token = "0x6009D25")]
[Address(RVA = "0x1B20140", Offset = "0x1B1EF40", VA = "0x181B20140")]
public static AsymmetricKeyParameter CreateKey(Stream inStr)
{
return PrivateKeyFactory.CreateKey(PrivateKeyInfo.GetInstance(Asn1Object.FromStream(inStr)));
}
// Token: 0x06009D26 RID: 40230 RVA: 0x0020F08C File Offset: 0x0020D28C
[Token(Token = "0x6009D26")]
[Address(RVA = "0x1B1F190", Offset = "0x1B1DF90", VA = "0x181B1F190")]
public static AsymmetricKeyParameter CreateKey(PrivateKeyInfo keyInfo)
{
/*
An exception occurred when decompiling this method (06009D26)
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: 0x06009D27 RID: 40231 RVA: 0x0020F380 File Offset: 0x0020D580
[Token(Token = "0x6009D27")]
[Address(RVA = "0x1B202D0", Offset = "0x1B1F0D0", VA = "0x181B202D0")]
private static byte[] GetRawKey(PrivateKeyInfo keyInfo, int expectedSize)
{
/*
An exception occurred when decompiling this method (06009D27)
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: 0x06009D28 RID: 40232 RVA: 0x0020F3B4 File Offset: 0x0020D5B4
[Token(Token = "0x6009D28")]
[Address(RVA = "0x1B201F0", Offset = "0x1B1EFF0", VA = "0x181B201F0")]
public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, EncryptedPrivateKeyInfo encInfo)
{
return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, encInfo));
}
// Token: 0x06009D29 RID: 40233 RVA: 0x0020F3D0 File Offset: 0x0020D5D0
[Token(Token = "0x6009D29")]
[Address(RVA = "0x1B20170", Offset = "0x1B1EF70", VA = "0x181B20170")]
public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, byte[] encryptedPrivateKeyInfoData)
{
EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(Asn1Object.FromByteArray(encryptedPrivateKeyInfoData));
return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance));
}
// Token: 0x06009D2A RID: 40234 RVA: 0x0020F3F8 File Offset: 0x0020D5F8
[Token(Token = "0x6009D2A")]
[Address(RVA = "0x1B20210", Offset = "0x1B1F010", VA = "0x181B20210")]
public static AsymmetricKeyParameter DecryptKey(char[] passPhrase, Stream encryptedPrivateKeyInfoStream)
{
EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(Asn1Object.FromStream(encryptedPrivateKeyInfoStream));
return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance));
}
// Token: 0x06009D2B RID: 40235 RVA: 0x0020F420 File Offset: 0x0020D620
[Token(Token = "0x6009D2B")]
[Address(RVA = "0x1B201B0", Offset = "0x1B1EFB0", VA = "0x181B201B0")]
private static AsymmetricKeyParameter DecryptKey(char[] passPhrase, Asn1Object asn1Object)
{
EncryptedPrivateKeyInfo instance = EncryptedPrivateKeyInfo.GetInstance(asn1Object);
return PrivateKeyFactory.CreateKey(PrivateKeyInfoFactory.CreatePrivateKeyInfo(passPhrase, instance));
}
// Token: 0x06009D2C RID: 40236 RVA: 0x0020F440 File Offset: 0x0020D640
[Token(Token = "0x6009D2C")]
[Address(RVA = "0x1B20290", Offset = "0x1B1F090", VA = "0x181B20290")]
public static byte[] EncryptKey(DerObjectIdentifier algorithm, char[] passPhrase, byte[] salt, int iterationCount, AsymmetricKeyParameter key)
{
EncryptedPrivateKeyInfo encryptedPrivateKeyInfo;
return encryptedPrivateKeyInfo.GetEncoded();
}
// Token: 0x06009D2D RID: 40237 RVA: 0x0020F45C File Offset: 0x0020D65C
[Token(Token = "0x6009D2D")]
[Address(RVA = "0x1B20250", Offset = "0x1B1F050", VA = "0x181B20250")]
public static byte[] EncryptKey(string algorithm, char[] passPhrase, byte[] salt, int iterationCount, AsymmetricKeyParameter key)
{
EncryptedPrivateKeyInfo encryptedPrivateKeyInfo;
return encryptedPrivateKeyInfo.GetEncoded();
}
}
}