Files
Apr2020-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Tsp/TimeStampToken.cs
T
niko 8fc35183db a
2026-04-11 22:19:20 +02:00

389 lines
12 KiB
C#

using System;
using System.Collections;
using System.IO;
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.Nist;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Oiw;
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.Utilities;
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tsp
{
// Token: 0x0200196E RID: 6510
[Token(Token = "0x200196E")]
public class TimeStampToken
{
// Token: 0x06009AC6 RID: 39622 RVA: 0x00200E9C File Offset: 0x001FF09C
[Token(Token = "0x6009AC6")]
[Address(RVA = "0x1B2CBA0", Offset = "0x1B2B9A0", VA = "0x181B2CBA0")]
public TimeStampToken(BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.ContentInfo contentInfo)
{
CmsSignedData cmsSignedData = new CmsSignedData(contentInfo);
}
// Token: 0x06009AC7 RID: 39623 RVA: 0x00200EB0 File Offset: 0x001FF0B0
[Token(Token = "0x6009AC7")]
[Address(RVA = "0x1B2CC10", Offset = "0x1B2BA10", VA = "0x181B2CC10")]
public TimeStampToken(CmsSignedData signedData)
{
this.tsToken = signedData;
DerObjectIdentifier signedContentType = signedData.SignedContentType;
ICollection signers = this.tsToken.GetSignerInfos().GetSigners();
if (signers == (ulong)1L)
{
if (signers == 0)
{
}
int num = 0;
if (signers != 0)
{
this.tsaSignerInfo = signers;
CmsProcessable signedContent = this.tsToken.signedContent;
MemoryStream memoryStream = new MemoryStream();
if (num < signers)
{
num += num;
num++;
}
Asn1Object asn1Object;
TimeStampTokenInfo timeStampTokenInfo = new TimeStampTokenInfo(TstInfo.GetInstance(asn1Object));
this.tstInfo = timeStampTokenInfo;
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable signedAttributes = this.tsaSignerInfo.SignedAttributes;
DerObjectIdentifier idAASigningCertificate = PkcsObjectIdentifiers.IdAASigningCertificate;
TimeStampToken.CertID certID;
if (signedAttributes[idAASigningCertificate] == 0)
{
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable signedAttributes2 = this.tsaSignerInfo.SignedAttributes;
DerObjectIdentifier idAASigningCertificateV = PkcsObjectIdentifiers.IdAASigningCertificateV2;
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.Attribute attribute = signedAttributes2[idAASigningCertificateV];
if (attribute == 0)
{
TspValidationException ex = new TspValidationException("no signing certificate attribute found, time stamp invalid.");
throw new NullReferenceException();
}
IEnumerator enumerator = attribute.attrValues.GetEnumerator();
int num2 = 0;
SigningCertificateV2 signingCertificateV;
EssCertIDv2[] certs = signingCertificateV.GetCerts();
num2 += num2;
EssCertIDv2 instance = EssCertIDv2.GetInstance(certs[0]);
certID.certIDv2 = instance;
certID.certID = num;
}
EssCertIDv2 certIDv = certID.certIDv2;
SigningCertificate signingCertificate;
EssCertID instance2 = EssCertID.GetInstance(signingCertificate.GetCerts()[0]);
TimeStampToken.CertID certID2;
certID2.certID = instance2;
certID2.certIDv2 = num;
this.certID = certID2;
return;
}
}
throw new NullReferenceException();
}
// Token: 0x170018C2 RID: 6338
// (get) Token: 0x06009AC8 RID: 39624 RVA: 0x00201098 File Offset: 0x001FF298
[Token(Token = "0x170018C2")]
public TimeStampTokenInfo TimeStampInfo
{
[Token(Token = "0x6009AC8")]
[Address(RVA = "0x3F6400", Offset = "0x3F5200", VA = "0x1803F6400")]
get
{
return this.tstInfo;
}
}
// Token: 0x170018C3 RID: 6339
// (get) Token: 0x06009AC9 RID: 39625 RVA: 0x002010AC File Offset: 0x001FF2AC
[Token(Token = "0x170018C3")]
public SignerID SignerID
{
[Token(Token = "0x6009AC9")]
[Address(RVA = "0x3F71E0", Offset = "0x3F5FE0", VA = "0x1803F71E0")]
get
{
return this.tsaSignerInfo.sid;
}
}
// Token: 0x170018C4 RID: 6340
// (get) Token: 0x06009ACA RID: 39626 RVA: 0x002010CC File Offset: 0x001FF2CC
[Token(Token = "0x170018C4")]
public BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable SignedAttributes
{
[Token(Token = "0x6009ACA")]
[Address(RVA = "0x1B2D290", Offset = "0x1B2C090", VA = "0x181B2D290")]
get
{
return this.tsaSignerInfo.SignedAttributes;
}
}
// Token: 0x170018C5 RID: 6341
// (get) Token: 0x06009ACB RID: 39627 RVA: 0x002010EC File Offset: 0x001FF2EC
[Token(Token = "0x170018C5")]
public BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable UnsignedAttributes
{
[Token(Token = "0x6009ACB")]
[Address(RVA = "0x1B2D2B0", Offset = "0x1B2C0B0", VA = "0x181B2D2B0")]
get
{
return this.tsaSignerInfo.UnsignedAttributes;
}
}
// Token: 0x06009ACC RID: 39628 RVA: 0x0020110C File Offset: 0x001FF30C
[Token(Token = "0x6009ACC")]
[Address(RVA = "0x1B2C450", Offset = "0x1B2B250", VA = "0x181B2C450")]
public IX509Store GetCertificates(string type)
{
return this.tsToken.GetCertificates(type);
}
// Token: 0x06009ACD RID: 39629 RVA: 0x0020112C File Offset: 0x001FF32C
[Token(Token = "0x6009ACD")]
[Address(RVA = "0x1B2C470", Offset = "0x1B2B270", VA = "0x181B2C470")]
public IX509Store GetCrls(string type)
{
return this.tsToken.GetCrls(type);
}
// Token: 0x06009ACE RID: 39630 RVA: 0x0020114C File Offset: 0x001FF34C
[Token(Token = "0x6009ACE")]
[Address(RVA = "0x1B2C430", Offset = "0x1B2B230", VA = "0x181B2C430")]
public IX509Store GetAttributeCertificates(string type)
{
return this.tsToken.GetAttributeCertificates(type);
}
// Token: 0x06009ACF RID: 39631 RVA: 0x0020116C File Offset: 0x001FF36C
[Token(Token = "0x6009ACF")]
[Address(RVA = "0x1B2C4B0", Offset = "0x1B2B2B0", VA = "0x181B2C4B0")]
public void Validate(X509Certificate cert)
{
EssCertID essCertID3;
for (;;)
{
TimeStampToken.CertID certID = this.certID;
if (certID.certID == (ulong)0L)
{
DerObjectIdentifier idSha = NistObjectIdentifiers.IdSha256;
if (certID.certIDv2.hashAlgorithm.ToAsn1Object() == 0)
{
Asn1Object asn1Object = certID.certIDv2.hashAlgorithm.ToAsn1Object();
}
}
AsymmetricKeyParameter publicKey = cert.GetPublicKey();
EssCertID essCertID = this.certID.certID;
if (essCertID != 0)
{
int length = essCertID.GetCertHash().Length;
byte[] array;
byte[] array2;
if (!Arrays.ConstantTimeAreEqual(array, array2))
{
goto IL_21A;
}
TimeStampToken.CertID certID2 = this.certID;
EssCertID essCertID2 = certID2.certID;
if (essCertID2 != 0)
{
}
if (certID2.certIDv2.issuerSerial == 0)
{
goto IL_12E;
}
if (essCertID2 != 0)
{
DerInteger serial = essCertID2.issuerSerial.serial;
if (cert.Version == 0)
{
goto IL_1C6;
}
essCertID3 = this.certID.certID;
if (essCertID3 != 0)
{
break;
}
}
}
}
byte[] bytes = essCertID3.issuerSerial.serial.bytes;
X509Name issuerX509Principal = PrincipalUtilities.GetIssuerX509Principal(cert);
int num = 0;
GeneralName[] array3;
if (num == array3.Length)
{
TspValidationException ex = new TspValidationException("certificate name does not match certID for signature. ");
throw new NullReferenceException();
}
GeneralName generalName = array3[num];
if (generalName.tag != 4 || !X509Name.GetInstance(generalName.obj).Equivalent(issuerX509Principal))
{
num++;
}
IL_12E:
TspUtil.ValidateCertificate(cert);
DateTime genTime = this.tstInfo.genTime;
if (!this.tsaSignerInfo.Verify(cert))
{
TspValidationException ex2 = new TspValidationException("signature not created by certificate.");
throw new NullReferenceException();
}
if (!cert.hashValueSet)
{
return;
}
throw new NullReferenceException();
IL_1C6:
TspValidationException ex3 = new TspValidationException("certificate serial number does not match certID for signature.");
throw new NullReferenceException();
IL_21A:
TspValidationException ex4 = new TspValidationException("certificate hash does not match certID hash.");
throw new NullReferenceException();
}
// Token: 0x06009AD0 RID: 39632 RVA: 0x002013D0 File Offset: 0x001FF5D0
[Token(Token = "0x6009AD0")]
[Address(RVA = "0x3F6E20", Offset = "0x3F5C20", VA = "0x1803F6E20")]
public CmsSignedData ToCmsSignedData()
{
return this.tsToken;
}
// Token: 0x06009AD1 RID: 39633 RVA: 0x002013E4 File Offset: 0x001FF5E4
[Token(Token = "0x6009AD1")]
[Address(RVA = "0x1B2C490", Offset = "0x1B2B290", VA = "0x181B2C490")]
public byte[] GetEncoded()
{
return this.tsToken.GetEncoded();
}
// Token: 0x040068BE RID: 26814
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x40068BE")]
private readonly CmsSignedData tsToken;
// Token: 0x040068BF RID: 26815
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x40068BF")]
private readonly SignerInformation tsaSignerInfo;
// Token: 0x040068C0 RID: 26816
[FieldOffset(Offset = "0x20")]
[Token(Token = "0x40068C0")]
private readonly TimeStampTokenInfo tstInfo;
// Token: 0x040068C1 RID: 26817
[FieldOffset(Offset = "0x28")]
[Token(Token = "0x40068C1")]
private readonly TimeStampToken.CertID certID;
// Token: 0x0200196F RID: 6511
[Token(Token = "0x200196F")]
private class CertID
{
// Token: 0x06009AD2 RID: 39634 RVA: 0x00201404 File Offset: 0x001FF604
[Token(Token = "0x6009AD2")]
[Address(RVA = "0x1B151E0", Offset = "0x1B13FE0", VA = "0x181B151E0")]
internal CertID(EssCertID certID)
{
this.certID = certID;
this.certIDv2 = (ulong)0L;
}
// Token: 0x06009AD3 RID: 39635 RVA: 0x00201428 File Offset: 0x001FF628
[Token(Token = "0x6009AD3")]
[Address(RVA = "0x1B15210", Offset = "0x1B14010", VA = "0x181B15210")]
internal CertID(EssCertIDv2 certID)
{
this.certIDv2 = certID;
this.certID = (ulong)0L;
}
// Token: 0x06009AD4 RID: 39636 RVA: 0x0020144C File Offset: 0x001FF64C
[Token(Token = "0x6009AD4")]
[Address(RVA = "0x1B15020", Offset = "0x1B13E20", VA = "0x181B15020")]
public string GetHashAlgorithmName()
{
if (this.certID == (ulong)0L)
{
EssCertIDv2 essCertIDv = this.certIDv2;
DerObjectIdentifier idSha = NistObjectIdentifiers.IdSha256;
if (essCertIDv.hashAlgorithm.ToAsn1Object() == 0)
{
Asn1Object asn1Object = this.certIDv2.hashAlgorithm.ToAsn1Object();
}
return "SHA-256";
}
return "SHA-1";
}
// Token: 0x06009AD5 RID: 39637 RVA: 0x002014A4 File Offset: 0x001FF6A4
[Token(Token = "0x6009AD5")]
[Address(RVA = "0x1B15130", Offset = "0x1B13F30", VA = "0x181B15130")]
public AlgorithmIdentifier GetHashAlgorithm()
{
if (this.certID != (ulong)0L)
{
return new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1);
}
return this.certIDv2.hashAlgorithm;
}
// Token: 0x06009AD6 RID: 39638 RVA: 0x002014D8 File Offset: 0x001FF6D8
[Token(Token = "0x6009AD6")]
[Address(RVA = "0x1B14FE0", Offset = "0x1B13DE0", VA = "0x181B14FE0")]
public byte[] GetCertHash()
{
EssCertID essCertID = this.certID;
if (essCertID != 0)
{
return essCertID.GetCertHash();
}
return this.certIDv2.GetCertHash();
}
// Token: 0x170018C6 RID: 6342
// (get) Token: 0x06009AD7 RID: 39639 RVA: 0x00201508 File Offset: 0x001FF708
[Token(Token = "0x170018C6")]
public IssuerSerial IssuerSerial
{
[Token(Token = "0x6009AD7")]
[Address(RVA = "0x1B15240", Offset = "0x1B14040", VA = "0x181B15240")]
get
{
EssCertID essCertID = this.certID;
if (essCertID != 0)
{
return essCertID.issuerSerial;
}
return this.certIDv2.issuerSerial;
}
}
// Token: 0x040068C2 RID: 26818
[FieldOffset(Offset = "0x10")]
[Token(Token = "0x40068C2")]
private EssCertID certID;
// Token: 0x040068C3 RID: 26819
[FieldOffset(Offset = "0x18")]
[Token(Token = "0x40068C3")]
private EssCertIDv2 certIDv2;
}
}
}