296 lines
14 KiB
C#
296 lines
14 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.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: 0x02001967 RID: 6503
|
|
[Token(Token = "0x2001967")]
|
|
public class TspUtil
|
|
{
|
|
// Token: 0x06009A89 RID: 39561 RVA: 0x001FFD50 File Offset: 0x001FDF50
|
|
[Token(Token = "0x6009A89")]
|
|
[Address(RVA = "0x18E92B0", Offset = "0x18E80B0", VA = "0x1818E92B0")]
|
|
static TspUtil()
|
|
{
|
|
HashSet hashSet = new HashSet();
|
|
Hashtable hashtable = new Hashtable();
|
|
hashSet.impl = hashtable;
|
|
UnmodifiableSetProxy unmodifiableSetProxy;
|
|
unmodifiableSetProxy.s = hashSet;
|
|
TspUtil.EmptySet = unmodifiableSetProxy;
|
|
ArrayList arrayList = new ArrayList();
|
|
UnmodifiableListProxy unmodifiableListProxy;
|
|
unmodifiableListProxy.l = arrayList;
|
|
TspUtil.EmptyList = unmodifiableListProxy;
|
|
TspUtil.digestLengths = new Hashtable();
|
|
TspUtil.digestNames = new Hashtable();
|
|
IDictionary dictionary = TspUtil.digestLengths;
|
|
DerObjectIdentifier md = PkcsObjectIdentifiers.MD5;
|
|
IDictionary dictionary2 = TspUtil.digestLengths;
|
|
DerObjectIdentifier idSha = OiwObjectIdentifiers.IdSha1;
|
|
IDictionary dictionary3 = TspUtil.digestLengths;
|
|
DerObjectIdentifier idSha2 = NistObjectIdentifiers.IdSha224;
|
|
IDictionary dictionary4 = TspUtil.digestLengths;
|
|
DerObjectIdentifier idSha3 = NistObjectIdentifiers.IdSha256;
|
|
IDictionary dictionary5 = TspUtil.digestLengths;
|
|
DerObjectIdentifier idSha4 = NistObjectIdentifiers.IdSha384;
|
|
IDictionary dictionary6 = TspUtil.digestLengths;
|
|
DerObjectIdentifier idSha5 = NistObjectIdentifiers.IdSha512;
|
|
IDictionary dictionary7 = TspUtil.digestLengths;
|
|
DerObjectIdentifier ripeMD = TeleTrusTObjectIdentifiers.RipeMD128;
|
|
IDictionary dictionary8 = TspUtil.digestLengths;
|
|
DerObjectIdentifier ripeMD2 = TeleTrusTObjectIdentifiers.RipeMD160;
|
|
IDictionary dictionary9 = TspUtil.digestLengths;
|
|
DerObjectIdentifier ripeMD3 = TeleTrusTObjectIdentifiers.RipeMD256;
|
|
IDictionary dictionary10 = TspUtil.digestLengths;
|
|
DerObjectIdentifier gostR = CryptoProObjectIdentifiers.GostR3411;
|
|
IDictionary dictionary11 = TspUtil.digestLengths;
|
|
DerObjectIdentifier id_tc26_gost_3411_12_ = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
|
|
IDictionary dictionary12 = TspUtil.digestLengths;
|
|
DerObjectIdentifier id_tc26_gost_3411_12_2 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
|
|
IDictionary dictionary13 = TspUtil.digestLengths;
|
|
DerObjectIdentifier sm = GMObjectIdentifiers.sm3;
|
|
IDictionary dictionary14 = TspUtil.digestNames;
|
|
DerObjectIdentifier md2 = PkcsObjectIdentifiers.MD5;
|
|
IDictionary dictionary15 = TspUtil.digestNames;
|
|
DerObjectIdentifier idSha6 = OiwObjectIdentifiers.IdSha1;
|
|
IDictionary dictionary16 = TspUtil.digestNames;
|
|
DerObjectIdentifier idSha7 = NistObjectIdentifiers.IdSha224;
|
|
IDictionary dictionary17 = TspUtil.digestNames;
|
|
DerObjectIdentifier idSha8 = NistObjectIdentifiers.IdSha256;
|
|
IDictionary dictionary18 = TspUtil.digestNames;
|
|
DerObjectIdentifier idSha9 = NistObjectIdentifiers.IdSha384;
|
|
IDictionary dictionary19 = TspUtil.digestNames;
|
|
DerObjectIdentifier idSha10 = NistObjectIdentifiers.IdSha512;
|
|
IDictionary dictionary20 = TspUtil.digestNames;
|
|
DerObjectIdentifier md5WithRsaEncryption = PkcsObjectIdentifiers.MD5WithRsaEncryption;
|
|
IDictionary dictionary21 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha1WithRsaEncryption = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
|
|
IDictionary dictionary22 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha224WithRsaEncryption = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
|
|
IDictionary dictionary23 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha256WithRsaEncryption = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
|
|
IDictionary dictionary24 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha384WithRsaEncryption = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
|
|
IDictionary dictionary25 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha512WithRsaEncryption = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
|
|
IDictionary dictionary26 = TspUtil.digestNames;
|
|
DerObjectIdentifier ripeMD4 = TeleTrusTObjectIdentifiers.RipeMD128;
|
|
IDictionary dictionary27 = TspUtil.digestNames;
|
|
DerObjectIdentifier ripeMD5 = TeleTrusTObjectIdentifiers.RipeMD160;
|
|
IDictionary dictionary28 = TspUtil.digestNames;
|
|
DerObjectIdentifier ripeMD6 = TeleTrusTObjectIdentifiers.RipeMD256;
|
|
IDictionary dictionary29 = TspUtil.digestNames;
|
|
DerObjectIdentifier gostR2 = CryptoProObjectIdentifiers.GostR3411;
|
|
IDictionary dictionary30 = TspUtil.digestNames;
|
|
DerObjectIdentifier dsaWithSha = OiwObjectIdentifiers.DsaWithSha1;
|
|
IDictionary dictionary31 = TspUtil.digestNames;
|
|
DerObjectIdentifier sha1WithRsa = OiwObjectIdentifiers.Sha1WithRsa;
|
|
IDictionary dictionary32 = TspUtil.digestNames;
|
|
DerObjectIdentifier md5WithRsa = OiwObjectIdentifiers.MD5WithRsa;
|
|
IDictionary dictionary33 = TspUtil.digestNames;
|
|
DerObjectIdentifier id_tc26_gost_3411_12_3 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_256;
|
|
IDictionary dictionary34 = TspUtil.digestNames;
|
|
DerObjectIdentifier id_tc26_gost_3411_12_4 = RosstandartObjectIdentifiers.id_tc26_gost_3411_12_512;
|
|
IDictionary dictionary35 = TspUtil.digestNames;
|
|
DerObjectIdentifier sm2 = GMObjectIdentifiers.sm3;
|
|
}
|
|
|
|
// Token: 0x06009A8A RID: 39562 RVA: 0x001FFF98 File Offset: 0x001FE198
|
|
[Token(Token = "0x6009A8A")]
|
|
[Address(RVA = "0x18E8A20", Offset = "0x18E7820", VA = "0x1818E8A20")]
|
|
public static ICollection GetSignatureTimestamps(SignerInformation signerInfo)
|
|
{
|
|
byte[] array;
|
|
do
|
|
{
|
|
ArrayList arrayList = new ArrayList();
|
|
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_EF;
|
|
}
|
|
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[] messageImprintDigest = tstInfo.GetMessageImprintDigest();
|
|
if (!Arrays.ConstantTimeAreEqual(array, messageImprintDigest))
|
|
{
|
|
goto IL_A7;
|
|
}
|
|
if ((uint)(-1) != 0U)
|
|
{
|
|
}
|
|
if (array != 0)
|
|
{
|
|
goto IL_E9;
|
|
}
|
|
while ((ulong)((uint)(-1)) == (ulong)(-1L))
|
|
{
|
|
}
|
|
}
|
|
if ((uint)(-1) != 0U)
|
|
{
|
|
}
|
|
}
|
|
while (array != 0);
|
|
throw new NullReferenceException();
|
|
IL_A7:
|
|
TspValidationException ex = new TspValidationException("Incorrect digest in message imprint");
|
|
throw new NullReferenceException();
|
|
IL_E9:
|
|
throw new NullReferenceException();
|
|
IL_EF:
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009A8B RID: 39563 RVA: 0x002000A0 File Offset: 0x001FE2A0
|
|
[Token(Token = "0x6009A8B")]
|
|
[Address(RVA = "0x18E8FD0", Offset = "0x18E7DD0", VA = "0x1818E8FD0")]
|
|
public static void ValidateCertificate(X509Certificate cert)
|
|
{
|
|
/*
|
|
An exception occurred when decompiling this method (06009A8B)
|
|
|
|
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 1660
|
|
*/;
|
|
}
|
|
|
|
// Token: 0x06009A8C RID: 39564 RVA: 0x00200110 File Offset: 0x001FE310
|
|
[Token(Token = "0x6009A8C")]
|
|
[Address(RVA = "0x18E8640", Offset = "0x18E7440", VA = "0x1818E8640")]
|
|
internal static string GetDigestAlgName(string digestAlgOID)
|
|
{
|
|
IDictionary dictionary = TspUtil.digestNames;
|
|
return digestAlgOID;
|
|
}
|
|
|
|
// Token: 0x06009A8D RID: 39565 RVA: 0x0020012C File Offset: 0x001FE32C
|
|
[Token(Token = "0x6009A8D")]
|
|
[Address(RVA = "0x18E86F0", Offset = "0x18E74F0", VA = "0x1818E86F0")]
|
|
internal static int GetDigestLength(string digestAlgOID)
|
|
{
|
|
IDictionary dictionary = TspUtil.digestLengths;
|
|
IDictionary dictionary2 = TspUtil.digestLengths;
|
|
ISet emptySet = TspUtil.EmptySet;
|
|
throw new NullReferenceException();
|
|
}
|
|
|
|
// Token: 0x06009A8E RID: 39566 RVA: 0x00200160 File Offset: 0x001FE360
|
|
[Token(Token = "0x6009A8E")]
|
|
[Address(RVA = "0x18E84E0", Offset = "0x18E72E0", VA = "0x1818E84E0")]
|
|
internal static IDigest CreateDigestInstance(string digestAlgOID)
|
|
{
|
|
return DigestUtilities.GetDigest(TspUtil.GetDigestAlgName(digestAlgOID));
|
|
}
|
|
|
|
// Token: 0x06009A8F RID: 39567 RVA: 0x00200178 File Offset: 0x001FE378
|
|
[Token(Token = "0x6009A8F")]
|
|
[Address(RVA = "0x18E8560", Offset = "0x18E7360", VA = "0x1818E8560")]
|
|
internal static ISet GetCriticalExtensionOids(X509Extensions extensions)
|
|
{
|
|
if (extensions != 0)
|
|
{
|
|
HashSet hashSet = new HashSet(extensions.GetCriticalExtensionOids());
|
|
UnmodifiableSetProxy unmodifiableSetProxy;
|
|
unmodifiableSetProxy.s = hashSet;
|
|
}
|
|
return TspUtil.EmptySet;
|
|
}
|
|
|
|
// Token: 0x06009A90 RID: 39568 RVA: 0x002001A4 File Offset: 0x001FE3A4
|
|
[Token(Token = "0x6009A90")]
|
|
[Address(RVA = "0x18E8940", Offset = "0x18E7740", VA = "0x1818E8940")]
|
|
internal static ISet GetNonCriticalExtensionOids(X509Extensions extensions)
|
|
{
|
|
if (extensions != 0)
|
|
{
|
|
HashSet hashSet = new HashSet(extensions.GetNonCriticalExtensionOids());
|
|
UnmodifiableSetProxy unmodifiableSetProxy;
|
|
unmodifiableSetProxy.s = hashSet;
|
|
}
|
|
return TspUtil.EmptySet;
|
|
}
|
|
|
|
// Token: 0x06009A91 RID: 39569 RVA: 0x002001D0 File Offset: 0x001FE3D0
|
|
[Token(Token = "0x6009A91")]
|
|
[Address(RVA = "0x18E8820", Offset = "0x18E7620", VA = "0x1818E8820")]
|
|
internal static IList GetExtensionOids(X509Extensions extensions)
|
|
{
|
|
if (extensions != 0)
|
|
{
|
|
ArrayList arrayList = new ArrayList(extensions.GetExtensionOids());
|
|
UnmodifiableListProxy unmodifiableListProxy;
|
|
unmodifiableListProxy.l = arrayList;
|
|
}
|
|
return TspUtil.EmptyList;
|
|
}
|
|
|
|
// Token: 0x06009A92 RID: 39570 RVA: 0x002001FC File Offset: 0x001FE3FC
|
|
[Token(Token = "0x6009A92")]
|
|
[Address(RVA = "0x3F5100", Offset = "0x3F3F00", VA = "0x1803F5100")]
|
|
public TspUtil()
|
|
{
|
|
}
|
|
|
|
// Token: 0x040068AA RID: 26794
|
|
[Token(Token = "0x40068AA")]
|
|
private static ISet EmptySet;
|
|
|
|
// Token: 0x040068AB RID: 26795
|
|
[Token(Token = "0x40068AB")]
|
|
private static IList EmptyList;
|
|
|
|
// Token: 0x040068AC RID: 26796
|
|
[Token(Token = "0x40068AC")]
|
|
private static readonly IDictionary digestLengths;
|
|
|
|
// Token: 0x040068AD RID: 26797
|
|
[Token(Token = "0x40068AD")]
|
|
private static readonly IDictionary digestNames;
|
|
}
|
|
}
|