262 lines
9.4 KiB
C#
262 lines
9.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Ess;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Tsp;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Cms;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tsp
|
|
{
|
|
// Token: 0x02001970 RID: 6512
|
|
[Token(Token = "0x2001970")]
|
|
public class TimeStampTokenGenerator
|
|
{
|
|
// Token: 0x06009AD8 RID: 39640 RVA: 0x00201538 File Offset: 0x001FF738
|
|
[Token(Token = "0x6009AD8")]
|
|
[Address(RVA = "0x1B2C120", Offset = "0x1B2AF20", VA = "0x181B2C120")]
|
|
public TimeStampTokenGenerator(AsymmetricKeyParameter key, X509Certificate cert, string digestOID, string tsaPolicyOID)
|
|
{
|
|
}
|
|
|
|
// Token: 0x06009AD9 RID: 39641 RVA: 0x00201548 File Offset: 0x001FF748
|
|
[Token(Token = "0x6009AD9")]
|
|
[Address(RVA = "0x1B2BE40", Offset = "0x1B2AC40", VA = "0x181B2BE40")]
|
|
public TimeStampTokenGenerator(AsymmetricKeyParameter key, X509Certificate cert, string digestOID, string tsaPolicyOID, BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable signedAttr, BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable unsignedAttr)
|
|
{
|
|
this.accuracySeconds = (int)((ulong)(-1L));
|
|
this.accuracyMicros = (int)((ulong)4294967295L);
|
|
base..ctor();
|
|
this.key = key;
|
|
this.cert = cert;
|
|
this.digestOID = digestOID;
|
|
this.tsaPolicyOID = 0;
|
|
this.unsignedAttr = 0;
|
|
TspUtil.ValidateCertificate(cert);
|
|
if (cert == 0)
|
|
{
|
|
IDictionary dictionary = Platform.CreateHashtable();
|
|
}
|
|
AsymmetricKeyParameter publicKey = cert.GetPublicKey();
|
|
byte[] array;
|
|
EssCertID essCertID = new EssCertID(array);
|
|
DerObjectIdentifier idAASigningCertificate = PkcsObjectIdentifiers.IdAASigningCertificate;
|
|
DerSet derSet = new DerSet(new SigningCertificate(essCertID));
|
|
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.Attribute attribute = new BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.Attribute(idAASigningCertificate, derSet);
|
|
IDictionary dictionary2;
|
|
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable attributeTable = new BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable(dictionary2);
|
|
this.signedAttr = attributeTable;
|
|
}
|
|
|
|
// Token: 0x06009ADA RID: 39642 RVA: 0x0020161C File Offset: 0x001FF81C
|
|
[Token(Token = "0x6009ADA")]
|
|
[Address(RVA = "0x466B90", Offset = "0x465990", VA = "0x180466B90")]
|
|
public void SetCertificates(IX509Store certificates)
|
|
{
|
|
this.x509Certs = certificates;
|
|
}
|
|
|
|
// Token: 0x06009ADB RID: 39643 RVA: 0x00201630 File Offset: 0x001FF830
|
|
[Token(Token = "0x6009ADB")]
|
|
[Address(RVA = "0x567490", Offset = "0x566290", VA = "0x180567490")]
|
|
public void SetCrls(IX509Store crls)
|
|
{
|
|
this.x509Crls = crls;
|
|
}
|
|
|
|
// Token: 0x06009ADC RID: 39644 RVA: 0x00201644 File Offset: 0x001FF844
|
|
[Token(Token = "0x6009ADC")]
|
|
[Address(RVA = "0x536480", Offset = "0x535280", VA = "0x180536480")]
|
|
public void SetAccuracySeconds(int accuracySeconds)
|
|
{
|
|
this.accuracySeconds = accuracySeconds;
|
|
}
|
|
|
|
// Token: 0x06009ADD RID: 39645 RVA: 0x00201658 File Offset: 0x001FF858
|
|
[Token(Token = "0x6009ADD")]
|
|
[Address(RVA = "0x52EC20", Offset = "0x52DA20", VA = "0x18052EC20")]
|
|
public void SetAccuracyMillis(int accuracyMillis)
|
|
{
|
|
this.accuracyMillis = accuracyMillis;
|
|
}
|
|
|
|
// Token: 0x06009ADE RID: 39646 RVA: 0x0020166C File Offset: 0x001FF86C
|
|
[Token(Token = "0x6009ADE")]
|
|
[Address(RVA = "0x41F740", Offset = "0x41E540", VA = "0x18041F740")]
|
|
public void SetAccuracyMicros(int accuracyMicros)
|
|
{
|
|
this.accuracyMicros = accuracyMicros;
|
|
}
|
|
|
|
// Token: 0x06009ADF RID: 39647 RVA: 0x00201680 File Offset: 0x001FF880
|
|
[Token(Token = "0x6009ADF")]
|
|
[Address(RVA = "0x8EE5B0", Offset = "0x8ED3B0", VA = "0x1808EE5B0")]
|
|
public void SetOrdering(bool ordering)
|
|
{
|
|
this.ordering = ordering;
|
|
}
|
|
|
|
// Token: 0x06009AE0 RID: 39648 RVA: 0x00201694 File Offset: 0x001FF894
|
|
[Token(Token = "0x6009AE0")]
|
|
[Address(RVA = "0x460F90", Offset = "0x45FD90", VA = "0x180460F90")]
|
|
public void SetTsa(GeneralName tsa)
|
|
{
|
|
this.tsa = tsa;
|
|
}
|
|
|
|
// Token: 0x06009AE1 RID: 39649 RVA: 0x002016A8 File Offset: 0x001FF8A8
|
|
[Token(Token = "0x6009AE1")]
|
|
[Address(RVA = "0x1B2B7D0", Offset = "0x1B2A5D0", VA = "0x181B2B7D0")]
|
|
public TimeStampToken Generate(TimeStampRequest request, BigInteger serialNumber, DateTime genTime)
|
|
{
|
|
Asn1Object asn1Object = request.req.messageImprint.hashAlgorithm.ToAsn1Object();
|
|
DerNull instance = DerNull.Instance;
|
|
DerObjectIdentifier derObjectIdentifier;
|
|
AlgorithmIdentifier algorithmIdentifier = new AlgorithmIdentifier(derObjectIdentifier, instance);
|
|
byte[] hashedMessage = request.req.messageImprint.hashedMessage;
|
|
MessageImprint messageImprint = new MessageImprint(algorithmIdentifier, hashedMessage);
|
|
int num = this.accuracySeconds;
|
|
if (this.accuracyMicros > 0)
|
|
{
|
|
int num2 = 0;
|
|
if (num > 0)
|
|
{
|
|
DerInteger derInteger = new DerInteger(num);
|
|
}
|
|
int num3 = this.accuracyMillis;
|
|
DerInteger derInteger2;
|
|
if (num3 > 0)
|
|
{
|
|
derInteger2 = new DerInteger(num3);
|
|
}
|
|
int num4 = this.accuracyMicros;
|
|
DerInteger derInteger3;
|
|
if (num4 > 0)
|
|
{
|
|
derInteger3 = new DerInteger(num3);
|
|
}
|
|
Accuracy accuracy = new Accuracy(num2, derInteger2, derInteger3);
|
|
}
|
|
bool flag = this.ordering;
|
|
if (flag)
|
|
{
|
|
DerBoolean instance2 = DerBoolean.GetInstance(flag);
|
|
}
|
|
DerInteger nonce = request.req.nonce;
|
|
if (nonce != 0 && nonce.Value != 0)
|
|
{
|
|
DerInteger nonce2 = request.req.nonce;
|
|
if (nonce2 == 0)
|
|
{
|
|
}
|
|
DerInteger derInteger4 = new DerInteger(nonce2.Value);
|
|
}
|
|
DerObjectIdentifier derObjectIdentifier2 = new DerObjectIdentifier(this.tsaPolicyOID);
|
|
DerObjectIdentifier tsaPolicy = request.req.tsaPolicy;
|
|
if (tsaPolicy != 0)
|
|
{
|
|
string identifier = tsaPolicy.identifier;
|
|
if (identifier != 0)
|
|
{
|
|
DerObjectIdentifier derObjectIdentifier3 = new DerObjectIdentifier(identifier);
|
|
}
|
|
}
|
|
DerGeneralizedTime derGeneralizedTime = new DerGeneralizedTime(genTime);
|
|
X509Extensions extensions = request.req.extensions;
|
|
CmsSignedDataGenerator cmsSignedDataGenerator = new CmsSignedDataGenerator();
|
|
TstInfo tstInfo;
|
|
byte[] derEncoded = tstInfo.GetDerEncoded();
|
|
DerBoolean certReq = request.req.certReq;
|
|
if (certReq != 0 && certReq.IsTrue)
|
|
{
|
|
IX509Store ix509Store = this.x509Certs;
|
|
cmsSignedDataGenerator.AddCertificates(ix509Store);
|
|
}
|
|
IX509Store ix509Store2 = this.x509Crls;
|
|
cmsSignedDataGenerator.AddCrls(ix509Store2);
|
|
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable attributeTable = this.signedAttr;
|
|
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable attributeTable2 = this.unsignedAttr;
|
|
string text = this.digestOID;
|
|
X509Certificate x509Certificate = this.cert;
|
|
AsymmetricKeyParameter asymmetricKeyParameter = this.key;
|
|
cmsSignedDataGenerator.AddSigner(asymmetricKeyParameter, x509Certificate, text, attributeTable, attributeTable2);
|
|
string identifier2 = PkcsObjectIdentifiers.IdCTTstInfo.identifier;
|
|
CmsProcessableByteArray cmsProcessableByteArray = new CmsProcessableByteArray(derEncoded);
|
|
return new TimeStampToken(cmsSignedDataGenerator.Generate(identifier2, cmsProcessableByteArray, true));
|
|
}
|
|
|
|
// Token: 0x040068C4 RID: 26820
|
|
[FieldOffset(Offset = "0x10")]
|
|
[Token(Token = "0x40068C4")]
|
|
private int accuracySeconds;
|
|
|
|
// Token: 0x040068C5 RID: 26821
|
|
[FieldOffset(Offset = "0x14")]
|
|
[Token(Token = "0x40068C5")]
|
|
private int accuracyMillis;
|
|
|
|
// Token: 0x040068C6 RID: 26822
|
|
[FieldOffset(Offset = "0x18")]
|
|
[Token(Token = "0x40068C6")]
|
|
private int accuracyMicros;
|
|
|
|
// Token: 0x040068C7 RID: 26823
|
|
[FieldOffset(Offset = "0x1C")]
|
|
[Token(Token = "0x40068C7")]
|
|
private bool ordering;
|
|
|
|
// Token: 0x040068C8 RID: 26824
|
|
[FieldOffset(Offset = "0x20")]
|
|
[Token(Token = "0x40068C8")]
|
|
private GeneralName tsa;
|
|
|
|
// Token: 0x040068C9 RID: 26825
|
|
[FieldOffset(Offset = "0x28")]
|
|
[Token(Token = "0x40068C9")]
|
|
private string tsaPolicyOID;
|
|
|
|
// Token: 0x040068CA RID: 26826
|
|
[FieldOffset(Offset = "0x30")]
|
|
[Token(Token = "0x40068CA")]
|
|
private AsymmetricKeyParameter key;
|
|
|
|
// Token: 0x040068CB RID: 26827
|
|
[FieldOffset(Offset = "0x38")]
|
|
[Token(Token = "0x40068CB")]
|
|
private X509Certificate cert;
|
|
|
|
// Token: 0x040068CC RID: 26828
|
|
[FieldOffset(Offset = "0x40")]
|
|
[Token(Token = "0x40068CC")]
|
|
private string digestOID;
|
|
|
|
// Token: 0x040068CD RID: 26829
|
|
[FieldOffset(Offset = "0x48")]
|
|
[Token(Token = "0x40068CD")]
|
|
private BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable signedAttr;
|
|
|
|
// Token: 0x040068CE RID: 26830
|
|
[FieldOffset(Offset = "0x50")]
|
|
[Token(Token = "0x40068CE")]
|
|
private BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable unsignedAttr;
|
|
|
|
// Token: 0x040068CF RID: 26831
|
|
[FieldOffset(Offset = "0x58")]
|
|
[Token(Token = "0x40068CF")]
|
|
private IX509Store x509Certs;
|
|
|
|
// Token: 0x040068D0 RID: 26832
|
|
[FieldOffset(Offset = "0x60")]
|
|
[Token(Token = "0x40068D0")]
|
|
private IX509Store x509Crls;
|
|
}
|
|
}
|