223 lines
10 KiB
C#
223 lines
10 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 BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.X509
|
|
{
|
|
// Token: 0x0200190C RID: 6412
|
|
[Token(Token = "0x200190C")]
|
|
public class X509V1CertificateGenerator
|
|
{
|
|
// Token: 0x06009722 RID: 38690 RVA: 0x001F2584 File Offset: 0x001F0784
|
|
[Token(Token = "0x6009722")]
|
|
[Address(RVA = "0x1635700", Offset = "0x1634500", VA = "0x181635700")]
|
|
public X509V1CertificateGenerator()
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = new V1TbsCertificateGenerator();
|
|
this.tbsGen = v1TbsCertificateGenerator;
|
|
}
|
|
|
|
// Token: 0x06009723 RID: 38691 RVA: 0x001F25A4 File Offset: 0x001F07A4
|
|
[Token(Token = "0x6009723")]
|
|
[Address(RVA = "0x16351B0", Offset = "0x1633FB0", VA = "0x1816351B0")]
|
|
public void Reset()
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = new V1TbsCertificateGenerator();
|
|
this.tbsGen = v1TbsCertificateGenerator;
|
|
}
|
|
|
|
// Token: 0x06009724 RID: 38692 RVA: 0x001F25C0 File Offset: 0x001F07C0
|
|
[Token(Token = "0x6009724")]
|
|
[Address(RVA = "0x16353B0", Offset = "0x16341B0", VA = "0x1816353B0")]
|
|
public void SetSerialNumber(BigInteger serialNumber)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009724)
|
|
|
|
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: 0x06009725 RID: 38693 RVA: 0x001F2604 File Offset: 0x001F0804
|
|
[Token(Token = "0x6009725")]
|
|
[Address(RVA = "0x15D18A0", Offset = "0x15D06A0", VA = "0x1815D18A0")]
|
|
public void SetIssuerDN(X509Name issuer)
|
|
{
|
|
this.tbsGen.issuer = issuer;
|
|
}
|
|
|
|
// Token: 0x06009726 RID: 38694 RVA: 0x001F2624 File Offset: 0x001F0824
|
|
[Token(Token = "0x6009726")]
|
|
[Address(RVA = "0x1635270", Offset = "0x1634070", VA = "0x181635270")]
|
|
public void SetNotBefore(DateTime date)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
Time time = new Time(date);
|
|
v1TbsCertificateGenerator.startDate = time;
|
|
}
|
|
|
|
// Token: 0x06009727 RID: 38695 RVA: 0x001F264C File Offset: 0x001F084C
|
|
[Token(Token = "0x6009727")]
|
|
[Address(RVA = "0x1635200", Offset = "0x1634000", VA = "0x181635200")]
|
|
public void SetNotAfter(DateTime date)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
Time time = new Time(date);
|
|
v1TbsCertificateGenerator.endDate = time;
|
|
}
|
|
|
|
// Token: 0x06009728 RID: 38696 RVA: 0x001F2674 File Offset: 0x001F0874
|
|
[Token(Token = "0x6009728")]
|
|
[Address(RVA = "0x16356E0", Offset = "0x16344E0", VA = "0x1816356E0")]
|
|
public void SetSubjectDN(X509Name subject)
|
|
{
|
|
this.tbsGen.subject = subject;
|
|
}
|
|
|
|
// Token: 0x06009729 RID: 38697 RVA: 0x001F2694 File Offset: 0x001F0894
|
|
[Token(Token = "0x6009729")]
|
|
[Address(RVA = "0x16352E0", Offset = "0x16340E0", VA = "0x1816352E0")]
|
|
public void SetPublicKey(AsymmetricKeyParameter publicKey)
|
|
{
|
|
V1TbsCertificateGenerator v1TbsCertificateGenerator = this.tbsGen;
|
|
SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
|
|
v1TbsCertificateGenerator.subjectPublicKeyInfo = subjectPublicKeyInfo;
|
|
}
|
|
|
|
// Token: 0x0600972A RID: 38698 RVA: 0x001F26CC File Offset: 0x001F08CC
|
|
[Token(Token = "0x600972A")]
|
|
[Address(RVA = "0x1635470", Offset = "0x1634270", VA = "0x181635470")]
|
|
[Obsolete]
|
|
public void SetSignatureAlgorithm(string signatureAlgorithm)
|
|
{
|
|
this.signatureAlgorithm = signatureAlgorithm;
|
|
string text = Platform.ToUpperInvariant(signatureAlgorithm);
|
|
IDictionary algorithms = X509Utilities.algorithms;
|
|
DerObjectIdentifier derObjectIdentifier = new DerObjectIdentifier(text);
|
|
IDictionary algorithms2 = X509Utilities.algorithms;
|
|
IDictionary algorithms3 = X509Utilities.algorithms;
|
|
AlgorithmIdentifier algorithmIdentifier;
|
|
this.sigAlgId = algorithmIdentifier;
|
|
this.tbsGen.signature = algorithmIdentifier;
|
|
}
|
|
|
|
// Token: 0x0600972B RID: 38699 RVA: 0x001F273C File Offset: 0x001F093C
|
|
[Token(Token = "0x600972B")]
|
|
[Address(RVA = "0x1634E10", Offset = "0x1633C10", VA = "0x181634E10")]
|
|
[Obsolete]
|
|
public X509Certificate Generate(AsymmetricKeyParameter privateKey)
|
|
{
|
|
int num;
|
|
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, num);
|
|
num = 0;
|
|
return this.Generate(asn1SignatureFactory);
|
|
}
|
|
|
|
// Token: 0x0600972C RID: 38700 RVA: 0x001F2760 File Offset: 0x001F0960
|
|
[Token(Token = "0x600972C")]
|
|
[Address(RVA = "0x1634D70", Offset = "0x1633B70", VA = "0x181634D70")]
|
|
[Obsolete]
|
|
public X509Certificate Generate(AsymmetricKeyParameter privateKey, SecureRandom random)
|
|
{
|
|
Asn1SignatureFactory asn1SignatureFactory = new Asn1SignatureFactory(this.signatureAlgorithm, privateKey, random);
|
|
return this.Generate(asn1SignatureFactory);
|
|
}
|
|
|
|
// Token: 0x0600972D RID: 38701 RVA: 0x001F2784 File Offset: 0x001F0984
|
|
[Token(Token = "0x600972D")]
|
|
[Address(RVA = "0x1634EA0", Offset = "0x1633CA0", VA = "0x181634EA0")]
|
|
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: 0x0600972E RID: 38702 RVA: 0x001F27E0 File Offset: 0x001F09E0
|
|
[Token(Token = "0x600972E")]
|
|
[Address(RVA = "0x1634CB0", Offset = "0x1633AB0", VA = "0x181634CB0")]
|
|
private X509Certificate GenerateJcaObject(TbsCertificateStructure tbsCert, AlgorithmIdentifier sigAlg, byte[] signature)
|
|
{
|
|
DerBitString derBitString = new DerBitString(signature);
|
|
return new X509Certificate(new X509CertificateStructure(tbsCert, sigAlg, derBitString));
|
|
}
|
|
|
|
// Token: 0x17001819 RID: 6169
|
|
// (get) Token: 0x0600972F RID: 38703 RVA: 0x001F2804 File Offset: 0x001F0A04
|
|
[Token(Token = "0x17001819")]
|
|
public IEnumerable SignatureAlgNames
|
|
{
|
|
[Token(Token = "0x600972F")]
|
|
[Address(RVA = "0x1635760", Offset = "0x1634560", VA = "0x181635760")]
|
|
get
|
|
{
|
|
IDictionary algorithms = X509Utilities.algorithms;
|
|
throw new NullReferenceException();
|
|
}
|
|
}
|
|
|
|
// Token: 0x040066A8 RID: 26280
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40066A8")]
|
|
private V1TbsCertificateGenerator tbsGen;
|
|
|
|
// Token: 0x040066A9 RID: 26281
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40066A9")]
|
|
private DerObjectIdentifier sigOID;
|
|
|
|
// Token: 0x040066AA RID: 26282
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40066AA")]
|
|
private AlgorithmIdentifier sigAlgId;
|
|
|
|
// Token: 0x040066AB RID: 26283
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40066AB")]
|
|
private string signatureAlgorithm;
|
|
}
|
|
}
|