Files
2026-04-10 22:50:51 +02:00

364 lines
18 KiB
C#

using System;
using System.Collections;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Operators;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509
{
// Token: 0x02001910 RID: 6416
[Token(Token = "0x2001910")]
public class X509V3CertificateGenerator
{
// Token: 0x0600976E RID: 38766 RVA: 0x001F34C4 File Offset: 0x001F16C4
[Token(Token = "0x600976E")]
[Address(RVA = "0x1C4A9C0", Offset = "0x1C497C0", VA = "0x181C4A9C0")]
public X509V3CertificateGenerator()
{
X509ExtensionsGenerator x509ExtensionsGenerator = new X509ExtensionsGenerator();
this.extGenerator = x509ExtensionsGenerator;
base..ctor();
V3TbsCertificateGenerator v3TbsCertificateGenerator = new V3TbsCertificateGenerator();
this.tbsGen = v3TbsCertificateGenerator;
}
// Token: 0x0600976F RID: 38767 RVA: 0x001F34F4 File Offset: 0x001F16F4
[Token(Token = "0x600976F")]
[Address(RVA = "0x1C4A5C0", Offset = "0x1C493C0", VA = "0x181C4A5C0")]
public void Reset()
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = new V3TbsCertificateGenerator();
X509ExtensionsGenerator x509ExtensionsGenerator = this.extGenerator;
this.tbsGen = v3TbsCertificateGenerator;
x509ExtensionsGenerator.Reset();
}
// Token: 0x06009770 RID: 38768 RVA: 0x001F3524 File Offset: 0x001F1724
[Token(Token = "0x6009770")]
[Address(RVA = "0x1C4A790", Offset = "0x1C49590", VA = "0x181C4A790")]
public void SetSerialNumber(BigInteger serialNumber)
{
/*
An exception occurred when decompiling this method (06009770)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.X509.X509V3CertificateGenerator::SetSerialNumber(BestHTTP.SecureProtocol.Org.BouncyCastle.Math.BigInteger)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_25:
stloc:ArgumentException(var_2_34, newobj:ArgumentException(ArgumentException::.ctor, ldstr:string("serial number must be a positive integer"), ldstr:string("serialNumber")))
}
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: 0x06009771 RID: 38769 RVA: 0x001F3568 File Offset: 0x001F1768
[Token(Token = "0x6009771")]
[Address(RVA = "0x1C4A630", Offset = "0x1C49430", VA = "0x181C4A630")]
public void SetIssuerDN(X509Name issuer)
{
this.tbsGen.issuer = issuer;
}
// Token: 0x06009772 RID: 38770 RVA: 0x001F3588 File Offset: 0x001F1788
[Token(Token = "0x6009772")]
[Address(RVA = "0x1C4A6F0", Offset = "0x1C494F0", VA = "0x181C4A6F0")]
public void SetNotBefore(DateTime date)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
Time time = new Time(date);
v3TbsCertificateGenerator.startDate = time;
}
// Token: 0x06009773 RID: 38771 RVA: 0x001F35B0 File Offset: 0x001F17B0
[Token(Token = "0x6009773")]
[Address(RVA = "0x1C4A680", Offset = "0x1C49480", VA = "0x181C4A680")]
public void SetNotAfter(DateTime date)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
Time time = new Time(date);
v3TbsCertificateGenerator.endDate = time;
}
// Token: 0x06009774 RID: 38772 RVA: 0x001F35D8 File Offset: 0x001F17D8
[Token(Token = "0x6009774")]
[Address(RVA = "0x1C4A970", Offset = "0x1C49770", VA = "0x181C4A970")]
public void SetSubjectDN(X509Name subject)
{
this.tbsGen.subject = subject;
}
// Token: 0x06009775 RID: 38773 RVA: 0x001F35F8 File Offset: 0x001F17F8
[Token(Token = "0x6009775")]
[Address(RVA = "0x1C4A760", Offset = "0x1C49560", VA = "0x181C4A760")]
public void SetPublicKey(AsymmetricKeyParameter publicKey)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
v3TbsCertificateGenerator.subjectPublicKeyInfo = subjectPublicKeyInfo;
}
// Token: 0x06009776 RID: 38774 RVA: 0x001F3620 File Offset: 0x001F1820
[Token(Token = "0x6009776")]
[Address(RVA = "0x1C4A850", Offset = "0x1C49650", VA = "0x181C4A850")]
[Obsolete]
public void SetSignatureAlgorithm(string signatureAlgorithm)
{
this.signatureAlgorithm = signatureAlgorithm;
DerObjectIdentifier algorithmOid = X509Utilities.GetAlgorithmOid(signatureAlgorithm);
this.sigOid = algorithmOid;
AlgorithmIdentifier sigAlgID = X509Utilities.GetSigAlgID(algorithmOid, signatureAlgorithm);
this.sigAlgId = sigAlgID;
this.tbsGen.signature = sigAlgID;
}
// Token: 0x06009777 RID: 38775 RVA: 0x001F3670 File Offset: 0x001F1870
[Token(Token = "0x6009777")]
[Address(RVA = "0x1C4A990", Offset = "0x1C49790", VA = "0x181C4A990")]
public void SetSubjectUniqueID(bool[] uniqueID)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
DerBitString derBitString = this.booleanToBitString(uniqueID);
v3TbsCertificateGenerator.subjectUniqueID = derBitString;
}
// Token: 0x06009778 RID: 38776 RVA: 0x001F369C File Offset: 0x001F189C
[Token(Token = "0x6009778")]
[Address(RVA = "0x1C4A650", Offset = "0x1C49450", VA = "0x181C4A650")]
public void SetIssuerUniqueID(bool[] uniqueID)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
DerBitString derBitString = this.booleanToBitString(uniqueID);
v3TbsCertificateGenerator.issuerUniqueID = derBitString;
}
// Token: 0x06009779 RID: 38777 RVA: 0x001F36C8 File Offset: 0x001F18C8
[Token(Token = "0x6009779")]
[Address(RVA = "0x1C4AA40", Offset = "0x1C49840", VA = "0x181C4AA40")]
private DerBitString booleanToBitString(bool[] id)
{
int num = id.Length;
num += 7;
byte[] array = new byte[id];
int num2 = 0;
int num3 = id.Length;
if (num2 != num3)
{
num2 += id;
num2 -= id;
uint num4;
num4 -= (uint)num2;
num2++;
}
if (num2 < array.Length)
{
num3++;
}
uint num5;
DerBitString derBitString = new DerBitString(array, (int)num5);
if (num3 != 0)
{
num5 -= (uint)num3;
return derBitString;
}
return derBitString;
}
// Token: 0x0600977A RID: 38778 RVA: 0x001F3734 File Offset: 0x001F1934
[Token(Token = "0x600977A")]
[Address(RVA = "0x1C49DC0", Offset = "0x1C48BC0", VA = "0x181C49DC0")]
public void AddExtension(string oid, bool critical, Asn1Encodable extensionValue)
{
X509ExtensionsGenerator x509ExtensionsGenerator = this.extGenerator;
DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(oid);
x509ExtensionsGenerator.AddExtension(derObjectIdentifier, critical, extensionValue);
}
// Token: 0x0600977B RID: 38779 RVA: 0x001F3760 File Offset: 0x001F1960
[Token(Token = "0x600977B")]
[Address(RVA = "0x1C49080", Offset = "0x1C47E80", VA = "0x181C49080")]
public void AddExtension(DerObjectIdentifier oid, bool critical, Asn1Encodable extensionValue)
{
this.extGenerator.AddExtension(oid, critical, extensionValue);
}
// Token: 0x0600977C RID: 38780 RVA: 0x001F3784 File Offset: 0x001F1984
[Token(Token = "0x600977C")]
[Address(RVA = "0x1C49C50", Offset = "0x1C48A50", VA = "0x181C49C50")]
public void AddExtension(string oid, bool critical, byte[] extensionValue)
{
X509ExtensionsGenerator x509ExtensionsGenerator = this.extGenerator;
DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(oid);
DerOctetString derOctetString = new DerOctetString(extensionValue);
x509ExtensionsGenerator.AddExtension(derObjectIdentifier, critical, derOctetString);
}
// Token: 0x0600977D RID: 38781 RVA: 0x001F37B8 File Offset: 0x001F19B8
[Token(Token = "0x600977D")]
[Address(RVA = "0x1C49D10", Offset = "0x1C48B10", VA = "0x181C49D10")]
public void AddExtension(DerObjectIdentifier oid, bool critical, byte[] extensionValue)
{
X509ExtensionsGenerator x509ExtensionsGenerator = this.extGenerator;
DerOctetString derOctetString = new DerOctetString(extensionValue);
x509ExtensionsGenerator.AddExtension(oid, critical, derOctetString);
}
// Token: 0x0600977E RID: 38782 RVA: 0x001F37E4 File Offset: 0x001F19E4
[Token(Token = "0x600977E")]
[Address(RVA = "0x1C49FD0", Offset = "0x1C48DD0", VA = "0x181C49FD0")]
public void CopyAndAddExtension(string oid, bool critical, X509Certificate cert)
{
DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(oid);
this.CopyAndAddExtension(derObjectIdentifier, critical, cert);
}
// Token: 0x0600977F RID: 38783 RVA: 0x001F3804 File Offset: 0x001F1A04
[Token(Token = "0x600977F")]
[Address(RVA = "0x1C49E70", Offset = "0x1C48C70", VA = "0x181C49E70")]
public void CopyAndAddExtension(DerObjectIdentifier oid, bool critical, X509Certificate cert)
{
/*
An exception occurred when decompiling this method (0600977F)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.X509.X509V3CertificateGenerator::CopyAndAddExtension(BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.DerObjectIdentifier,System.Boolean,BestHTTP.SecureProtocol.Org.BouncyCastle.X509.X509Certificate)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_24:
stloc:CertificateParsingException(var_3_39, newobj:CertificateParsingException(CertificateParsingException::.ctor, call:string(string::Concat, ldstr:string[exp:object]("extension "), ldloc:DerObjectIdentifier[exp:object](oid), ldstr:string[exp:object](" not present"))))
}
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: 0x06009780 RID: 38784 RVA: 0x001F384C File Offset: 0x001F1A4C
[Token(Token = "0x6009780")]
[Address(RVA = "0x1C4A530", Offset = "0x1C49330", VA = "0x181C4A530")]
[Obsolete]
public X509Certificate Generate(AsymmetricKeyParameter privateKey)
{
int num;
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, num);
num = 0;
return this.Generate(asn1SignatureFactory);
}
// Token: 0x06009781 RID: 38785 RVA: 0x001F3870 File Offset: 0x001F1A70
[Token(Token = "0x6009781")]
[Address(RVA = "0x1C4A130", Offset = "0x1C48F30", VA = "0x181C4A130")]
[Obsolete]
public X509Certificate Generate(AsymmetricKeyParameter privateKey, SecureRandom random)
{
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, random);
return this.Generate(asn1SignatureFactory);
}
// Token: 0x06009782 RID: 38786 RVA: 0x001F3894 File Offset: 0x001F1A94
[Token(Token = "0x6009782")]
[Address(RVA = "0x1C4A1D0", Offset = "0x1C48FD0", VA = "0x181C4A1D0")]
public X509Certificate Generate(ISignatureFactory signatureCalculatorFactory)
{
byte[] derEncoded;
for (;;)
{
V3TbsCertificateGenerator v3TbsCertificateGenerator = this.tbsGen;
if (signatureCalculatorFactory != 0)
{
if (!this.extGenerator.IsEmpty)
{
X509ExtensionsGenerator x509ExtensionsGenerator = this.extGenerator;
V3TbsCertificateGenerator v3TbsCertificateGenerator2 = this.tbsGen;
X509Extensions x509Extensions = x509ExtensionsGenerator.Generate();
v3TbsCertificateGenerator2.SetExtensions(x509Extensions);
}
derEncoded = this.tbsGen.GenerateTbsCertificate().GetDerEncoded();
if (derEncoded != 0 && derEncoded != 0)
{
if (derEncoded == 0)
{
}
if (derEncoded != 0)
{
break;
}
}
}
}
DerBitString derBitString = new DerBitString(derEncoded);
X509CertificateStructure x509CertificateStructure;
return new X509Certificate(x509CertificateStructure);
}
// Token: 0x06009783 RID: 38787 RVA: 0x001F3924 File Offset: 0x001F1B24
[Token(Token = "0x6009783")]
[Address(RVA = "0x1C4A070", Offset = "0x1C48E70", VA = "0x181C4A070")]
private X509Certificate GenerateJcaObject(TbsCertificateStructure tbsCert, AlgorithmIdentifier sigAlg, byte[] signature)
{
DerBitString derBitString = new DerBitString(signature);
return new X509Certificate(new X509CertificateStructure(tbsCert, sigAlg, derBitString));
}
// Token: 0x17001824 RID: 6180
// (get) Token: 0x06009784 RID: 38788 RVA: 0x001F3948 File Offset: 0x001F1B48
[Token(Token = "0x17001824")]
public IEnumerable SignatureAlgNames
{
[Token(Token = "0x6009784")]
[Address(RVA = "0x1C4AB90", Offset = "0x1C49990", VA = "0x181C4AB90")]
get
{
return X509Utilities.GetAlgNames();
}
}
// Token: 0x040066B9 RID: 26297
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x40066B9")]
private readonly X509ExtensionsGenerator extGenerator;
// Token: 0x040066BA RID: 26298
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x40066BA")]
private V3TbsCertificateGenerator tbsGen;
// Token: 0x040066BB RID: 26299
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x40066BB")]
private DerObjectIdentifier sigOid;
// Token: 0x040066BC RID: 26300
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x40066BC")]
private AlgorithmIdentifier sigAlgId;
// Token: 0x040066BD RID: 26301
[FieldOffset(Offset = "0x30")]
[Token(Token = "0x40066BD")]
private string signatureAlgorithm;
}
}