Files
Jan2021-Cpp2Il-Dump/Assembly-CSharp/BestHTTP/SecureProtocol/Org/BouncyCastle/Tsp/TspUtil.cs
T
2026-04-08 23:40:05 +02:00

302 lines
15 KiB
C#

using System;
using System.Collections;
using System.Runtime.InteropServices;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.CryptoPro;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.GM;
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.Rosstandart;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.TeleTrust;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Cms;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
using Cpp2IlInjected;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tsp
{
// Token: 0x0200138A RID: 5002
[Token(Token = "0x200138A")]
[StructLayout(3)]
public class TspUtil
{
// Token: 0x06007EAF RID: 32431 RVA: 0x001A8720 File Offset: 0x001A6920
[Token(Token = "0x6007EAF")]
[Address(RVA = "0x1C6E950", Offset = "0x1C6D350", VA = "0x181C6E950")]
static TspUtil()
{
IDictionary dictionary = Platform.CreateHashtable();
HashSet hashSet;
hashSet.impl = dictionary;
UnmodifiableSetProxy unmodifiableSetProxy;
unmodifiableSetProxy.s = hashSet;
TspUtil.EmptySet = unmodifiableSetProxy;
IList list = Platform.CreateArrayList();
UnmodifiableListProxy unmodifiableListProxy;
unmodifiableListProxy.l = list;
TspUtil.EmptyList = unmodifiableListProxy;
IDictionary dictionary2 = Platform.CreateHashtable();
TspUtil.digestLengths = dictionary2;
TspUtil.digestNames = Platform.CreateHashtable();
IDictionary dictionary3 = TspUtil.digestLengths;
DerObjectIdentifier md = PkcsObjectIdentifiers.MD5;
IDictionary dictionary4 = TspUtil.digestLengths;
DerObjectIdentifier idSha = OiwObjectIdentifiers.IdSha1;
IDictionary dictionary5 = TspUtil.digestLengths;
DerObjectIdentifier idSha2 = NistObjectIdentifiers.IdSha224;
IDictionary dictionary6 = TspUtil.digestLengths;
DerObjectIdentifier idSha3 = NistObjectIdentifiers.IdSha256;
IDictionary dictionary7 = TspUtil.digestLengths;
DerObjectIdentifier idSha4 = NistObjectIdentifiers.IdSha384;
IDictionary dictionary8 = TspUtil.digestLengths;
DerObjectIdentifier idSha5 = NistObjectIdentifiers.IdSha512;
IDictionary dictionary9 = TspUtil.digestLengths;
DerObjectIdentifier ripeMD = TeleTrusTObjectIdentifiers.RipeMD128;
IDictionary dictionary10 = TspUtil.digestLengths;
DerObjectIdentifier ripeMD2 = TeleTrusTObjectIdentifiers.RipeMD160;
IDictionary dictionary11 = TspUtil.digestLengths;
DerObjectIdentifier ripeMD3 = TeleTrusTObjectIdentifiers.RipeMD256;
IDictionary dictionary12 = TspUtil.digestLengths;
DerObjectIdentifier gostR = CryptoProObjectIdentifiers.GostR3411;
IDictionary dictionary13 = TspUtil.digestLengths;
DerObjectIdentifier id_tc26_gost_3411_12_ = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
IDictionary dictionary14 = TspUtil.digestLengths;
DerObjectIdentifier id_tc26_gost_3411_12_2 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
IDictionary dictionary15 = TspUtil.digestLengths;
DerObjectIdentifier sm = GMObjectIdentifiers.sm3;
IDictionary dictionary16 = TspUtil.digestNames;
DerObjectIdentifier md2 = PkcsObjectIdentifiers.MD5;
IDictionary dictionary17 = TspUtil.digestNames;
DerObjectIdentifier idSha6 = OiwObjectIdentifiers.IdSha1;
IDictionary dictionary18 = TspUtil.digestNames;
DerObjectIdentifier idSha7 = NistObjectIdentifiers.IdSha224;
IDictionary dictionary19 = TspUtil.digestNames;
DerObjectIdentifier idSha8 = NistObjectIdentifiers.IdSha256;
IDictionary dictionary20 = TspUtil.digestNames;
DerObjectIdentifier idSha9 = NistObjectIdentifiers.IdSha384;
IDictionary dictionary21 = TspUtil.digestNames;
DerObjectIdentifier idSha10 = NistObjectIdentifiers.IdSha512;
IDictionary dictionary22 = TspUtil.digestNames;
DerObjectIdentifier md5WithRsaEncryption = PkcsObjectIdentifiers.MD5WithRsaEncryption;
IDictionary dictionary23 = TspUtil.digestNames;
DerObjectIdentifier sha1WithRsaEncryption = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
IDictionary dictionary24 = TspUtil.digestNames;
DerObjectIdentifier sha224WithRsaEncryption = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
IDictionary dictionary25 = TspUtil.digestNames;
DerObjectIdentifier sha256WithRsaEncryption = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
IDictionary dictionary26 = TspUtil.digestNames;
DerObjectIdentifier sha384WithRsaEncryption = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
IDictionary dictionary27 = TspUtil.digestNames;
DerObjectIdentifier sha512WithRsaEncryption = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
IDictionary dictionary28 = TspUtil.digestNames;
DerObjectIdentifier ripeMD4 = TeleTrusTObjectIdentifiers.RipeMD128;
IDictionary dictionary29 = TspUtil.digestNames;
DerObjectIdentifier ripeMD5 = TeleTrusTObjectIdentifiers.RipeMD160;
IDictionary dictionary30 = TspUtil.digestNames;
DerObjectIdentifier ripeMD6 = TeleTrusTObjectIdentifiers.RipeMD256;
IDictionary dictionary31 = TspUtil.digestNames;
DerObjectIdentifier gostR2 = CryptoProObjectIdentifiers.GostR3411;
IDictionary dictionary32 = TspUtil.digestNames;
DerObjectIdentifier dsaWithSha = OiwObjectIdentifiers.DsaWithSha1;
IDictionary dictionary33 = TspUtil.digestNames;
DerObjectIdentifier sha1WithRsa = OiwObjectIdentifiers.Sha1WithRsa;
IDictionary dictionary34 = TspUtil.digestNames;
DerObjectIdentifier md5WithRsa = OiwObjectIdentifiers.MD5WithRsa;
IDictionary dictionary35 = TspUtil.digestNames;
DerObjectIdentifier id_tc26_gost_3411_12_3 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
IDictionary dictionary36 = TspUtil.digestNames;
DerObjectIdentifier id_tc26_gost_3411_12_4 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
IDictionary dictionary37 = TspUtil.digestNames;
DerObjectIdentifier sm2 = GMObjectIdentifiers.sm3;
}
// Token: 0x06007EB0 RID: 32432 RVA: 0x001A8974 File Offset: 0x001A6B74
[Token(Token = "0x6007EB0")]
[Address(RVA = "0x1C6E0B0", Offset = "0x1C6CAB0", VA = "0x181C6E0B0")]
public static ICollection GetSignatureTimestamps(SignerInformation signerInfo)
{
byte[] array;
do
{
IList list = Platform.CreateArrayList();
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.AttributeTable unsignedAttributes = signerInfo.UnsignedAttributes;
if (unsignedAttributes == 0)
{
break;
}
DerObjectIdentifier idAASignatureTimeStampToken = PkcsObjectIdentifiers.IdAASignatureTimeStampToken;
IEnumerator enumerator = unsignedAttributes.GetAll(idAASignatureTimeStampToken).GetEnumerator();
if (enumerator != 0)
{
if (enumerator == 0 || enumerator == 0)
{
goto IL_110;
}
BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.ContentInfo contentInfo;
TimeStampTokenInfo tstInfo = new TimeStampToken(contentInfo).tstInfo;
byte[] array2;
array = DigestUtilities.CalculateDigest(TspUtil.GetDigestAlgName(tstInfo.MessageImprintAlgOid), array2);
byte[] hashedMessage = tstInfo.tstInfo.messageImprint.hashedMessage;
if (!Arrays.ConstantTimeAreEqual(array, hashedMessage))
{
goto IL_BC;
}
if ((uint)(-1) != 0U)
{
}
if ((ulong)((uint)(-1)) != (ulong)(-1L))
{
}
if (array != 0)
{
goto IL_10A;
}
}
if ((uint)(-1) != 0U)
{
}
if ((ulong)((uint)(-1)) != (ulong)(-1L))
{
}
}
while (array != 0);
throw new NullReferenceException();
IL_BC:
TspValidationException ex = new TspValidationException("Incorrect digest in message imprint");
throw new NullReferenceException();
IL_10A:
throw new NullReferenceException();
IL_110:
throw new NullReferenceException();
}
// Token: 0x06007EB1 RID: 32433 RVA: 0x001A8A9C File Offset: 0x001A6C9C
[Token(Token = "0x6007EB1")]
[Address(RVA = "0x1C6E670", Offset = "0x1C6D070", VA = "0x181C6E670")]
public static void ValidateCertificate(X509Certificate cert)
{
/*
An exception occurred when decompiling this method (06007EB1)
ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void BestHTTP.SecureProtocol.Org.BouncyCastle.Tsp.TspUtil::ValidateCertificate(BestHTTP.SecureProtocol.Org.BouncyCastle.X509.X509Certificate)
---> System.Exception: Basic block has to end with unconditional control flow.
{
IL_57:
stloc:TspValidationException(var_6_61, newobj:TspValidationException(TspValidationException::.ctor, ldstr:string("Certificate must have an ExtendedKeyUsage extension marked as critical.")))
}
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: 0x06007EB2 RID: 32434 RVA: 0x001A8B0C File Offset: 0x001A6D0C
[Token(Token = "0x6007EB2")]
[Address(RVA = "0x1C6DD00", Offset = "0x1C6C700", VA = "0x181C6DD00")]
internal static string GetDigestAlgName(string digestAlgOID)
{
IDictionary dictionary = TspUtil.digestNames;
return digestAlgOID;
}
// Token: 0x06007EB3 RID: 32435 RVA: 0x001A8B28 File Offset: 0x001A6D28
[Token(Token = "0x6007EB3")]
[Address(RVA = "0x1C6DDB0", Offset = "0x1C6C7B0", VA = "0x181C6DDB0")]
internal static int GetDigestLength(string digestAlgOID)
{
IDictionary dictionary = TspUtil.digestLengths;
IDictionary dictionary2 = TspUtil.digestLengths;
ISet emptySet = TspUtil.EmptySet;
throw new NullReferenceException();
}
// Token: 0x06007EB4 RID: 32436 RVA: 0x001A8B5C File Offset: 0x001A6D5C
[Token(Token = "0x6007EB4")]
[Address(RVA = "0x1C6DBA0", Offset = "0x1C6C5A0", VA = "0x181C6DBA0")]
internal static IDigest CreateDigestInstance(string digestAlgOID)
{
return DigestUtilities.GetDigest(TspUtil.GetDigestAlgName(digestAlgOID));
}
// Token: 0x06007EB5 RID: 32437 RVA: 0x001A8B74 File Offset: 0x001A6D74
[Token(Token = "0x6007EB5")]
[Address(RVA = "0x1C6DC20", Offset = "0x1C6C620", VA = "0x181C6DC20")]
internal static ISet GetCriticalExtensionOids(X509Extensions extensions)
{
if (extensions != 0)
{
HashSet hashSet = new HashSet(extensions.GetCriticalExtensionOids());
UnmodifiableSetProxy unmodifiableSetProxy;
unmodifiableSetProxy.s = hashSet;
}
return TspUtil.EmptySet;
}
// Token: 0x06007EB6 RID: 32438 RVA: 0x001A8BA0 File Offset: 0x001A6DA0
[Token(Token = "0x6007EB6")]
[Address(RVA = "0x1C6DFD0", Offset = "0x1C6C9D0", VA = "0x181C6DFD0")]
internal static ISet GetNonCriticalExtensionOids(X509Extensions extensions)
{
if (extensions != 0)
{
HashSet hashSet = new HashSet(extensions.GetNonCriticalExtensionOids());
UnmodifiableSetProxy unmodifiableSetProxy;
unmodifiableSetProxy.s = hashSet;
}
return TspUtil.EmptySet;
}
// Token: 0x06007EB7 RID: 32439 RVA: 0x001A8BCC File Offset: 0x001A6DCC
[Token(Token = "0x6007EB7")]
[Address(RVA = "0x1C6DEE0", Offset = "0x1C6C8E0", VA = "0x181C6DEE0")]
internal static IList GetExtensionOids(X509Extensions extensions)
{
if (extensions != 0)
{
IList list = Platform.CreateArrayList(extensions.GetExtensionOids());
UnmodifiableListProxy unmodifiableListProxy;
unmodifiableListProxy.l = list;
}
return TspUtil.EmptyList;
}
// Token: 0x06007EB8 RID: 32440 RVA: 0x001A8BF8 File Offset: 0x001A6DF8
[Token(Token = "0x6007EB8")]
[Address(RVA = "0x3C1670", Offset = "0x3C0070", VA = "0x1803C1670")]
public TspUtil()
{
}
// Token: 0x04005A67 RID: 23143
[Token(Token = "0x4005A67")]
private static ISet EmptySet;
// Token: 0x04005A68 RID: 23144
[Token(Token = "0x4005A68")]
private static IList EmptyList;
// Token: 0x04005A69 RID: 23145
[Token(Token = "0x4005A69")]
private static readonly IDictionary digestLengths;
// Token: 0x04005A6A RID: 23146
[Token(Token = "0x4005A6A")]
private static readonly IDictionary digestNames;
}
}