291 lines
7.7 KiB
C#
291 lines
7.7 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.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
|
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509.Store;
|
|
using Cpp2IlInjected;
|
|
|
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Cms
|
|
{
|
|
// Token: 0x02001E32 RID: 7730
|
|
[Token(Token = "0x2001E32")]
|
|
internal class CmsUtilities
|
|
{
|
|
// Token: 0x17001E0E RID: 7694
|
|
// (get) Token: 0x0600C1F9 RID: 49657 RVA: 0x002BD8D0 File Offset: 0x002BBAD0
|
|
[Token(Token = "0x17001E0E")]
|
|
internal static int MaximumMemory
|
|
{
|
|
[Token(Token = "0x600C1F9")]
|
|
[Address(RVA = "0x2928DC0", Offset = "0x2927DC0", VA = "0x182928DC0")]
|
|
get
|
|
{
|
|
return int.MaxValue;
|
|
}
|
|
}
|
|
|
|
// Token: 0x0600C1FA RID: 49658 RVA: 0x002BD8E4 File Offset: 0x002BBAE4
|
|
[Token(Token = "0x600C1FA")]
|
|
[Address(RVA = "0x2928BD0", Offset = "0x2927BD0", VA = "0x182928BD0")]
|
|
internal static ContentInfo ReadContentInfo(byte[] input)
|
|
{
|
|
return CmsUtilities.ReadContentInfo(new Asn1InputStream(input));
|
|
}
|
|
|
|
// Token: 0x0600C1FB RID: 49659 RVA: 0x002BD8FC File Offset: 0x002BBAFC
|
|
[Token(Token = "0x600C1FB")]
|
|
[Address(RVA = "0x2928C30", Offset = "0x2927C30", VA = "0x182928C30")]
|
|
internal static ContentInfo ReadContentInfo(Stream input)
|
|
{
|
|
return CmsUtilities.ReadContentInfo(new Asn1InputStream(input, int.MaxValue));
|
|
}
|
|
|
|
// Token: 0x0600C1FC RID: 49660 RVA: 0x002BD91C File Offset: 0x002BBB1C
|
|
[Token(Token = "0x600C1FC")]
|
|
[Address(RVA = "0x2928C90", Offset = "0x2927C90", VA = "0x182928C90")]
|
|
private static ContentInfo ReadContentInfo(Asn1InputStream aIn)
|
|
{
|
|
return ContentInfo.GetInstance(aIn.ReadObject());
|
|
}
|
|
|
|
// Token: 0x0600C1FD RID: 49661 RVA: 0x002BD93C File Offset: 0x002BBB3C
|
|
[Token(Token = "0x600C1FD")]
|
|
[Address(RVA = "0x2928DA0", Offset = "0x2927DA0", VA = "0x182928DA0")]
|
|
public static byte[] StreamToByteArray(Stream inStream)
|
|
{
|
|
return Streams.ReadAll(inStream);
|
|
}
|
|
|
|
// Token: 0x0600C1FE RID: 49662 RVA: 0x002BD950 File Offset: 0x002BBB50
|
|
[Token(Token = "0x600C1FE")]
|
|
[Address(RVA = "0x2928DB0", Offset = "0x2927DB0", VA = "0x182928DB0")]
|
|
public static byte[] StreamToByteArray(Stream inStream, int limit)
|
|
{
|
|
return Streams.ReadAllLimited(inStream, limit);
|
|
}
|
|
|
|
// Token: 0x0600C1FF RID: 49663 RVA: 0x002BD964 File Offset: 0x002BBB64
|
|
[Token(Token = "0x600C1FF")]
|
|
[Address(RVA = "0x2928480", Offset = "0x2927480", VA = "0x182928480")]
|
|
public static IList GetCertificatesFromStore(IX509Store certStore)
|
|
{
|
|
int num = 0;
|
|
IList list = Platform.CreateArrayList();
|
|
if (certStore != 0)
|
|
{
|
|
if (list != 0)
|
|
{
|
|
if (num < list)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
ulong num2;
|
|
num2 += (ulong)1L;
|
|
if (list == 0)
|
|
{
|
|
throw new NullReferenceException();
|
|
}
|
|
Asn1Object asn1Object;
|
|
X509CertificateStructure x509CertificateStructure = X509CertificateStructure.GetInstance(asn1Object);
|
|
if (num < list)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
x509CertificateStructure += x509CertificateStructure;
|
|
num += 2;
|
|
num += 19;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
}
|
|
if (num != 0)
|
|
{
|
|
throw new NullReferenceException();
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
// Token: 0x0600C200 RID: 49664 RVA: 0x002BD9E4 File Offset: 0x002BBBE4
|
|
[Token(Token = "0x600C200")]
|
|
[Address(RVA = "0x29287B0", Offset = "0x29277B0", VA = "0x1829287B0")]
|
|
public static IList GetCrlsFromStore(IX509Store crlStore)
|
|
{
|
|
int num = 0;
|
|
IList list = Platform.CreateArrayList();
|
|
if (crlStore != 0)
|
|
{
|
|
if (list != 0)
|
|
{
|
|
if (num < list)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
ulong num2;
|
|
num2 += (ulong)1L;
|
|
if (list == 0)
|
|
{
|
|
throw new NullReferenceException();
|
|
}
|
|
Asn1Object asn1Object;
|
|
CertificateList certificateList = CertificateList.GetInstance(asn1Object);
|
|
if (num < list)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
certificateList += certificateList;
|
|
num += 2;
|
|
num += 19;
|
|
}
|
|
if (num != 0)
|
|
{
|
|
}
|
|
if (num != 0)
|
|
{
|
|
throw new NullReferenceException();
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
// Token: 0x0600C201 RID: 49665 RVA: 0x002BDA64 File Offset: 0x002BBC64
|
|
[Token(Token = "0x600C201")]
|
|
[Address(RVA = "0x2927F20", Offset = "0x2926F20", VA = "0x182927F20")]
|
|
public static Asn1Set CreateBerSetFromList(IList berObjects)
|
|
{
|
|
int num;
|
|
Asn1EncodableVector asn1EncodableVector;
|
|
do
|
|
{
|
|
num = 0;
|
|
Asn1Encodable[] array;
|
|
if (asn1EncodableVector != 0)
|
|
{
|
|
if (num < asn1EncodableVector)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
num++;
|
|
num += 19;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
goto IL_71;
|
|
}
|
|
array = new Asn1Encodable[1];
|
|
if (num != 0)
|
|
{
|
|
}
|
|
array[0] = num;
|
|
asn1EncodableVector.Add(array);
|
|
}
|
|
if (array != 0)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
BerSet berSet = new BerSet(asn1EncodableVector);
|
|
throw new NullReferenceException();
|
|
IL_71:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600C202 RID: 49666 RVA: 0x002BDAE8 File Offset: 0x002BBCE8
|
|
[Token(Token = "0x600C202")]
|
|
[Address(RVA = "0x29281D0", Offset = "0x29271D0", VA = "0x1829281D0")]
|
|
public static Asn1Set CreateDerSetFromList(IList derObjects)
|
|
{
|
|
int num;
|
|
Asn1EncodableVector asn1EncodableVector;
|
|
do
|
|
{
|
|
num = 0;
|
|
Asn1Encodable[] array;
|
|
if (asn1EncodableVector != 0)
|
|
{
|
|
if (num < asn1EncodableVector)
|
|
{
|
|
num += num;
|
|
num++;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
num++;
|
|
num += 19;
|
|
}
|
|
if (num == 0)
|
|
{
|
|
goto IL_71;
|
|
}
|
|
array = new Asn1Encodable[1];
|
|
if (num != 0)
|
|
{
|
|
}
|
|
array[0] = num;
|
|
asn1EncodableVector.Add(array);
|
|
}
|
|
if (array != 0)
|
|
{
|
|
}
|
|
}
|
|
while (num != 0);
|
|
DerSet derSet = new DerSet(asn1EncodableVector);
|
|
throw new NullReferenceException();
|
|
IL_71:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x0600C203 RID: 49667 RVA: 0x002BDB6C File Offset: 0x002BBD6C
|
|
[Token(Token = "0x600C203")]
|
|
[Address(RVA = "0x2927E80", Offset = "0x2926E80", VA = "0x182927E80")]
|
|
internal static Stream CreateBerOctetOutputStream(Stream s, int tagNo, bool isExplicit, int bufferSize)
|
|
{
|
|
return new BerOctetStringGenerator(s, tagNo, isExplicit).GetOctetOutputStream(bufferSize);
|
|
}
|
|
|
|
// Token: 0x0600C204 RID: 49668 RVA: 0x002BDB90 File Offset: 0x002BBD90
|
|
[Token(Token = "0x600C204")]
|
|
[Address(RVA = "0x2928B90", Offset = "0x2927B90", VA = "0x182928B90")]
|
|
internal static TbsCertificateStructure GetTbsCertificateStructure(X509Certificate cert)
|
|
{
|
|
DateTime notAfter = cert.NotAfter;
|
|
Asn1Object asn1Object;
|
|
return TbsCertificateStructure.GetInstance(asn1Object);
|
|
}
|
|
|
|
// Token: 0x0600C205 RID: 49669 RVA: 0x002BDBB0 File Offset: 0x002BBDB0
|
|
[Token(Token = "0x600C205")]
|
|
[Address(RVA = "0x2928AE0", Offset = "0x2927AE0", VA = "0x182928AE0")]
|
|
internal static IssuerAndSerialNumber GetIssuerAndSerialNumber(X509Certificate cert)
|
|
{
|
|
DateTime notAfter = cert.NotAfter;
|
|
Asn1Object asn1Object;
|
|
TbsCertificateStructure instance = TbsCertificateStructure.GetInstance(asn1Object);
|
|
DerInteger serialNumber = instance.serialNumber;
|
|
X509Name issuer = instance.issuer;
|
|
BigInteger value = serialNumber.Value;
|
|
return new IssuerAndSerialNumber(issuer, value);
|
|
}
|
|
|
|
// Token: 0x0600C206 RID: 49670 RVA: 0x002BDBF4 File Offset: 0x002BBDF4
|
|
[Token(Token = "0x600C206")]
|
|
[Address(RVA = "0x412370", Offset = "0x411370", VA = "0x180412370")]
|
|
public CmsUtilities()
|
|
{
|
|
}
|
|
}
|
|
}
|