114 lines
6.1 KiB
C#
114 lines
6.1 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.Asn1.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Security
|
|
{
|
|
// Token: 0x02001A92 RID: 6802
|
|
[Token(Token = "0x2001A92")]
|
|
public sealed class PublicKeyFactory
|
|
{
|
|
// Token: 0x0600A0FC RID: 41212 RVA: 0x00218510 File Offset: 0x00216710
|
|
[Token(Token = "0x600A0FC")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
private PublicKeyFactory()
|
|
{
|
|
}
|
|
|
|
// Token: 0x0600A0FD RID: 41213 RVA: 0x00218524 File Offset: 0x00216724
|
|
[Token(Token = "0x600A0FD")]
|
|
[Address(RVA = "0x5E72A0", Offset = "0x5E62A0", VA = "0x1805E72A0")]
|
|
public static AsymmetricKeyParameter CreateKey(byte[] keyInfoData)
|
|
{
|
|
return PublicKeyFactory.CreateKey(SubjectPublicKeyInfo.GetInstance(Asn1Object.FromByteArray(keyInfoData)));
|
|
}
|
|
|
|
// Token: 0x0600A0FE RID: 41214 RVA: 0x00218544 File Offset: 0x00216744
|
|
[Token(Token = "0x600A0FE")]
|
|
[Address(RVA = "0x5E5E00", Offset = "0x5E4E00", VA = "0x1805E5E00")]
|
|
public static AsymmetricKeyParameter CreateKey(Stream inStr)
|
|
{
|
|
return PublicKeyFactory.CreateKey(SubjectPublicKeyInfo.GetInstance(Asn1Object.FromStream(inStr)));
|
|
}
|
|
|
|
// Token: 0x0600A0FF RID: 41215 RVA: 0x0000220F File Offset: 0x0000040F
|
|
[Token(Token = "0x600A0FF")]
|
|
[Address(RVA = "0x5E5E30", Offset = "0x5E4E30", VA = "0x1805E5E30")]
|
|
public static AsymmetricKeyParameter CreateKey(SubjectPublicKeyInfo keyInfo)
|
|
{
|
|
throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
|
|
}
|
|
|
|
// Token: 0x0600A100 RID: 41216 RVA: 0x00218564 File Offset: 0x00216764
|
|
[Token(Token = "0x600A100")]
|
|
[Address(RVA = "0x5E72D0", Offset = "0x5E62D0", VA = "0x1805E72D0")]
|
|
private static byte[] GetRawKey(SubjectPublicKeyInfo keyInfo, int expectedSize)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (0600A100)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Byte[] BestHTTP.SecureProtocol.Org.BouncyCastle.Security.PublicKeyFactory::GetRawKey(BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509.SubjectPublicKeyInfo,System.Int32)
|
|
|
|
---> System.Exception: Basic block has to end with unconditional control flow.
|
|
{
|
|
Block_0:
|
|
stloc:string(var_0_0B, callvirt:string(DerBitString::GetString, ldfld:DerBitString(SubjectPublicKeyInfo::keyData, ldloc:SubjectPublicKeyInfo(keyInfo))))
|
|
stloc:SecurityUtilityException(var_1_16, newobj:SecurityUtilityException(SecurityUtilityException::.ctor, ldstr:string("public 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: 0x0600A101 RID: 41217 RVA: 0x00218588 File Offset: 0x00216788
|
|
[Token(Token = "0x600A101")]
|
|
[Address(RVA = "0x5E7370", Offset = "0x5E6370", VA = "0x1805E7370")]
|
|
private static bool IsPkcsDHParam(Asn1Sequence seq)
|
|
{
|
|
Asn1Encodable asn1Encodable;
|
|
if (asn1Encodable != (ulong)2L)
|
|
{
|
|
Asn1SequenceParser parser = seq.Parser;
|
|
Asn1SequenceParser parser2 = seq.Parser;
|
|
DerInteger derInteger;
|
|
BigInteger value = derInteger.Value;
|
|
DerInteger derInteger2;
|
|
BigInteger bigInteger = BigInteger.ValueOf((long)derInteger2.Value.BitLength);
|
|
return value.CompareTo(bigInteger) <= 0;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Token: 0x0600A102 RID: 41218 RVA: 0x002185E0 File Offset: 0x002167E0
|
|
[Token(Token = "0x600A102")]
|
|
[Address(RVA = "0x5E74E0", Offset = "0x5E64E0", VA = "0x1805E74E0")]
|
|
private static DHPublicKeyParameters ReadPkcsDHParam(DerObjectIdentifier algOid, BigInteger y, Asn1Sequence seq)
|
|
{
|
|
DHParameter dhparameter = new DHParameter(seq);
|
|
BigInteger l = dhparameter.L;
|
|
if (l == 0)
|
|
{
|
|
}
|
|
int intValue = l.IntValue;
|
|
BigInteger p = dhparameter.P;
|
|
BigInteger g = dhparameter.G;
|
|
int num;
|
|
DHParameters dhparameters = new DHParameters(p, g, num, intValue);
|
|
num = 0;
|
|
return new DHPublicKeyParameters(y, dhparameters, algOid);
|
|
}
|
|
}
|
|
}
|