220 lines
10 KiB
C#
220 lines
10 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Runtime.InteropServices;
|
|
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: 0x0200132F RID: 4911
|
|
[Token(Token = "0x200132F")]
|
|
[StructLayout(3)]
|
|
public class X509V1CertificateGenerator
|
|
{
|
|
// Token: 0x06007B48 RID: 31560 RVA: 0x0019ABD8 File Offset: 0x00198DD8
|
|
[Token(Token = "0x6007B48")]
|
|
[Address(RVA = "0x53A8B0", Offset = "0x5392B0", VA = "0x18053A8B0")]
|
|
public X509V1CertificateGenerator()
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = new V1TbsCertificateGenerator();
|
|
this.tbsGen = v1TbsCertificateGenerator;
|
|
}
|
|
|
|
// Token: 0x06007B49 RID: 31561 RVA: 0x0019ABF8 File Offset: 0x00198DF8
|
|
[Token(Token = "0x6007B49")]
|
|
[Address(RVA = "0x53A4A0", Offset = "0x538EA0", VA = "0x18053A4A0")]
|
|
public void Reset()
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = new V1TbsCertificateGenerator();
|
|
this.tbsGen = v1TbsCertificateGenerator;
|
|
}
|
|
|
|
// Token: 0x06007B4A RID: 31562 RVA: 0x0019AC14 File Offset: 0x00198E14
|
|
[Token(Token = "0x6007B4A")]
|
|
[Address(RVA = "0x53A6C0", Offset = "0x5390C0", VA = "0x18053A6C0")]
|
|
public void SetSerialNumber(BigInteger serialNumber)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06007B4A)
|
|
|
|
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.X509.X509V1CertificateGenerator::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: 0x06007B4B RID: 31563 RVA: 0x0019AC58 File Offset: 0x00198E58
|
|
[Token(Token = "0x6007B4B")]
|
|
[Address(RVA = "0x53A4F0", Offset = "0x538EF0", VA = "0x18053A4F0")]
|
|
public void SetIssuerDN(X509Name issuer)
|
|
{
|
|
this.tbsGen.issuer = issuer;
|
|
}
|
|
|
|
// Token: 0x06007B4C RID: 31564 RVA: 0x0019AC78 File Offset: 0x00198E78
|
|
[Token(Token = "0x6007B4C")]
|
|
[Address(RVA = "0x53A580", Offset = "0x538F80", VA = "0x18053A580")]
|
|
public void SetNotBefore(DateTime date)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
Time time = new Time(date);
|
|
v1TbsCertificateGenerator.startDate = time;
|
|
}
|
|
|
|
// Token: 0x06007B4D RID: 31565 RVA: 0x0019ACA0 File Offset: 0x00198EA0
|
|
[Token(Token = "0x6007B4D")]
|
|
[Address(RVA = "0x53A510", Offset = "0x538F10", VA = "0x18053A510")]
|
|
public void SetNotAfter(DateTime date)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
Time time = new Time(date);
|
|
v1TbsCertificateGenerator.endDate = time;
|
|
}
|
|
|
|
// Token: 0x06007B4E RID: 31566 RVA: 0x0019ACC8 File Offset: 0x00198EC8
|
|
[Token(Token = "0x6007B4E")]
|
|
[Address(RVA = "0x53A890", Offset = "0x539290", VA = "0x18053A890")]
|
|
public void SetSubjectDN(X509Name subject)
|
|
{
|
|
this.tbsGen.subject = subject;
|
|
}
|
|
|
|
// Token: 0x06007B4F RID: 31567 RVA: 0x0019ACE8 File Offset: 0x00198EE8
|
|
[Token(Token = "0x6007B4F")]
|
|
[Address(RVA = "0x53A5F0", Offset = "0x538FF0", VA = "0x18053A5F0")]
|
|
public void SetPublicKey(AsymmetricKeyParameter publicKey)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
|
|
v1TbsCertificateGenerator.subjectPublicKeyInfo = subjectPublicKeyInfo;
|
|
}
|
|
|
|
// Token: 0x06007B50 RID: 31568 RVA: 0x0019AD20 File Offset: 0x00198F20
|
|
[Token(Token = "0x6007B50")]
|
|
[Address(RVA = "0x53A780", Offset = "0x539180", VA = "0x18053A780")]
|
|
[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: 0x06007B51 RID: 31569 RVA: 0x0019AD70 File Offset: 0x00198F70
|
|
[Token(Token = "0x6007B51")]
|
|
[Address(RVA = "0x53A100", Offset = "0x538B00", VA = "0x18053A100")]
|
|
[Obsolete]
|
|
public X509Certificate Generate(AsymmetricKeyParameter privateKey)
|
|
{
|
|
int num;
|
|
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, num);
|
|
num = 0;
|
|
return this.Generate(asn1SignatureFactory);
|
|
}
|
|
|
|
// Token: 0x06007B52 RID: 31570 RVA: 0x0019AD94 File Offset: 0x00198F94
|
|
[Token(Token = "0x6007B52")]
|
|
[Address(RVA = "0x53A060", Offset = "0x538A60", VA = "0x18053A060")]
|
|
[Obsolete]
|
|
public X509Certificate Generate(AsymmetricKeyParameter privateKey, SecureRandom random)
|
|
{
|
|
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, random);
|
|
return this.Generate(asn1SignatureFactory);
|
|
}
|
|
|
|
// Token: 0x06007B53 RID: 31571 RVA: 0x0019ADB8 File Offset: 0x00198FB8
|
|
[Token(Token = "0x6007B53")]
|
|
[Address(RVA = "0x53A190", Offset = "0x538B90", VA = "0x18053A190")]
|
|
public X509Certificate Generate(ISignatureFactory signatureCalculatorFactory)
|
|
{
|
|
byte[] derEncoded;
|
|
for (;;)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
if (signatureCalculatorFactory != 0)
|
|
{
|
|
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: 0x06007B54 RID: 31572 RVA: 0x0019AE14 File Offset: 0x00199014
|
|
[Token(Token = "0x6007B54")]
|
|
[Address(RVA = "0x539FA0", Offset = "0x5389A0", VA = "0x180539FA0")]
|
|
private X509Certificate GenerateJcaObject(TbsCertificateStructure tbsCert, AlgorithmIdentifier sigAlg, byte[] signature)
|
|
{
|
|
DerBitString derBitString = new DerBitString(signature);
|
|
return new X509Certificate(new X509CertificateStructure(tbsCert, sigAlg, derBitString));
|
|
}
|
|
|
|
// Token: 0x17001418 RID: 5144
|
|
// (get) Token: 0x06007B55 RID: 31573 RVA: 0x0019AE38 File Offset: 0x00199038
|
|
[Token(Token = "0x17001418")]
|
|
public IEnumerable SignatureAlgNames
|
|
{
|
|
[Token(Token = "0x6007B55")]
|
|
[Address(RVA = "0x53A910", Offset = "0x539310", VA = "0x18053A910")]
|
|
get
|
|
{
|
|
return X509Utilities.GetAlgNames();
|
|
}
|
|
}
|
|
|
|
// Token: 0x04005865 RID: 22629
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x4005865")]
|
|
private V1TbsCertificateGenerator tbsGen;
|
|
|
|
// Token: 0x04005866 RID: 22630
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x4005866")]
|
|
private DerObjectIdentifier sigOID;
|
|
|
|
// Token: 0x04005867 RID: 22631
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x4005867")]
|
|
private AlgorithmIdentifier sigAlgId;
|
|
|
|
// Token: 0x04005868 RID: 22632
|
|
[global::Cpp2IlInjected.FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x4005868")]
|
|
private string signatureAlgorithm;
|
|
}
|
|
}
|