This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
@@ -0,0 +1,95 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000064 RID: 100
public class AuthorityKeyIdentifierExtension : X509Extension
{
// Token: 0x060003C4 RID: 964 RVA: 0x00018D04 File Offset: 0x00016F04
public AuthorityKeyIdentifierExtension()
{
this.extnOid = "2.5.29.35";
}
// Token: 0x060003C5 RID: 965 RVA: 0x00018D18 File Offset: 0x00016F18
public AuthorityKeyIdentifierExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003C6 RID: 966 RVA: 0x00018D24 File Offset: 0x00016F24
public AuthorityKeyIdentifierExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003C7 RID: 967 RVA: 0x00018D30 File Offset: 0x00016F30
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid AuthorityKeyIdentifier extension");
}
for (int i = 0; i < asn.Count; i++)
{
ASN1 asn2 = asn[i];
byte tag = asn2.Tag;
if (tag == 128)
{
this.aki = asn2.Value;
}
}
}
// Token: 0x170000D7 RID: 215
// (get) Token: 0x060003C8 RID: 968 RVA: 0x00018DB4 File Offset: 0x00016FB4
public override string Name
{
get
{
return "Authority Key Identifier";
}
}
// Token: 0x170000D8 RID: 216
// (get) Token: 0x060003C9 RID: 969 RVA: 0x00018DBC File Offset: 0x00016FBC
public byte[] Identifier
{
get
{
if (this.aki == null)
{
return null;
}
return (byte[])this.aki.Clone();
}
}
// Token: 0x060003CA RID: 970 RVA: 0x00018DDC File Offset: 0x00016FDC
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.aki != null)
{
int i = 0;
stringBuilder.Append("KeyID=");
while (i < this.aki.Length)
{
stringBuilder.Append(this.aki[i].ToString("X2", CultureInfo.InvariantCulture));
if (i % 2 == 1)
{
stringBuilder.Append(" ");
}
i++;
}
}
return stringBuilder.ToString();
}
// Token: 0x040001B9 RID: 441
private byte[] aki;
}
}
@@ -0,0 +1,142 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000065 RID: 101
public class BasicConstraintsExtension : X509Extension
{
// Token: 0x060003CB RID: 971 RVA: 0x00018E5C File Offset: 0x0001705C
public BasicConstraintsExtension()
{
this.extnOid = "2.5.29.19";
this.pathLenConstraint = -1;
}
// Token: 0x060003CC RID: 972 RVA: 0x00018E78 File Offset: 0x00017078
public BasicConstraintsExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003CD RID: 973 RVA: 0x00018E84 File Offset: 0x00017084
public BasicConstraintsExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003CE RID: 974 RVA: 0x00018E90 File Offset: 0x00017090
protected override void Decode()
{
this.cA = false;
this.pathLenConstraint = -1;
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid BasicConstraints extension");
}
int num = 0;
ASN1 asn2 = asn[num++];
if (asn2 != null && asn2.Tag == 1)
{
this.cA = asn2.Value[0] == byte.MaxValue;
asn2 = asn[num++];
}
if (asn2 != null && asn2.Tag == 2)
{
this.pathLenConstraint = ASN1Convert.ToInt32(asn2);
}
}
// Token: 0x060003CF RID: 975 RVA: 0x00018F34 File Offset: 0x00017134
protected override void Encode()
{
ASN1 asn = new ASN1(48);
if (this.cA)
{
asn.Add(new ASN1(1, new byte[] { byte.MaxValue }));
}
if (this.cA && this.pathLenConstraint >= 0)
{
asn.Add(ASN1Convert.FromInt32(this.pathLenConstraint));
}
this.extnValue = new ASN1(4);
this.extnValue.Add(asn);
}
// Token: 0x170000D9 RID: 217
// (get) Token: 0x060003D0 RID: 976 RVA: 0x00018FB4 File Offset: 0x000171B4
// (set) Token: 0x060003D1 RID: 977 RVA: 0x00018FBC File Offset: 0x000171BC
public bool CertificateAuthority
{
get
{
return this.cA;
}
set
{
this.cA = value;
}
}
// Token: 0x170000DA RID: 218
// (get) Token: 0x060003D2 RID: 978 RVA: 0x00018FC8 File Offset: 0x000171C8
public override string Name
{
get
{
return "Basic Constraints";
}
}
// Token: 0x170000DB RID: 219
// (get) Token: 0x060003D3 RID: 979 RVA: 0x00018FD0 File Offset: 0x000171D0
// (set) Token: 0x060003D4 RID: 980 RVA: 0x00018FD8 File Offset: 0x000171D8
public int PathLenConstraint
{
get
{
return this.pathLenConstraint;
}
set
{
if (value < -1)
{
string text = Locale.GetText("PathLenConstraint must be positive or -1 for none ({0}).", new object[] { value });
throw new ArgumentOutOfRangeException(text);
}
this.pathLenConstraint = value;
}
}
// Token: 0x060003D5 RID: 981 RVA: 0x00019014 File Offset: 0x00017214
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("Subject Type=");
stringBuilder.Append((!this.cA) ? "End Entity" : "CA");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("Path Length Constraint=");
if (this.pathLenConstraint == -1)
{
stringBuilder.Append("None");
}
else
{
stringBuilder.Append(this.pathLenConstraint.ToString(CultureInfo.InvariantCulture));
}
stringBuilder.Append(Environment.NewLine);
return stringBuilder.ToString();
}
// Token: 0x040001BA RID: 442
public const int NoPathLengthConstraint = -1;
// Token: 0x040001BB RID: 443
private bool cA;
// Token: 0x040001BC RID: 444
private int pathLenConstraint;
}
}
@@ -0,0 +1,148 @@
using System;
using System.Collections;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000066 RID: 102
public class CRLDistributionPointsExtension : X509Extension
{
// Token: 0x060003D6 RID: 982 RVA: 0x000190B4 File Offset: 0x000172B4
public CRLDistributionPointsExtension()
{
this.extnOid = "2.5.29.31";
this.dps = new ArrayList();
}
// Token: 0x060003D7 RID: 983 RVA: 0x000190D4 File Offset: 0x000172D4
public CRLDistributionPointsExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003D8 RID: 984 RVA: 0x000190E0 File Offset: 0x000172E0
public CRLDistributionPointsExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003D9 RID: 985 RVA: 0x000190EC File Offset: 0x000172EC
protected override void Decode()
{
this.dps = new ArrayList();
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid CRLDistributionPoints extension");
}
for (int i = 0; i < asn.Count; i++)
{
this.dps.Add(new CRLDistributionPointsExtension.DP(asn[i]));
}
}
// Token: 0x170000DC RID: 220
// (get) Token: 0x060003DA RID: 986 RVA: 0x0001915C File Offset: 0x0001735C
public override string Name
{
get
{
return "CRL Distribution Points";
}
}
// Token: 0x060003DB RID: 987 RVA: 0x00019164 File Offset: 0x00017364
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
int num = 1;
foreach (object obj in this.dps)
{
CRLDistributionPointsExtension.DP dp = (CRLDistributionPointsExtension.DP)obj;
stringBuilder.Append("[");
stringBuilder.Append(num++);
stringBuilder.Append("]CRL Distribution Point");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("\tDistribution Point Name:");
stringBuilder.Append("\t\tFull Name:");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("\t\t\t");
stringBuilder.Append(dp.DistributionPoint);
stringBuilder.Append(Environment.NewLine);
}
return stringBuilder.ToString();
}
// Token: 0x040001BD RID: 445
private ArrayList dps;
// Token: 0x02000067 RID: 103
internal class DP
{
// Token: 0x060003DC RID: 988 RVA: 0x00019258 File Offset: 0x00017458
public DP(string dp, CRLDistributionPointsExtension.ReasonFlags reasons, string issuer)
{
this.DistributionPoint = dp;
this.Reasons = reasons;
this.CRLIssuer = issuer;
}
// Token: 0x060003DD RID: 989 RVA: 0x00019278 File Offset: 0x00017478
public DP(ASN1 dp)
{
for (int i = 0; i < dp.Count; i++)
{
ASN1 asn = dp[i];
switch (asn.Tag)
{
case 160:
{
for (int j = 0; j < asn.Count; j++)
{
ASN1 asn2 = asn[j];
if (asn2.Tag == 160)
{
this.DistributionPoint = new GeneralNames(asn2).ToString();
}
}
break;
}
}
}
}
// Token: 0x040001BE RID: 446
public string DistributionPoint;
// Token: 0x040001BF RID: 447
public CRLDistributionPointsExtension.ReasonFlags Reasons;
// Token: 0x040001C0 RID: 448
public string CRLIssuer;
}
// Token: 0x02000068 RID: 104
[Flags]
public enum ReasonFlags
{
// Token: 0x040001C2 RID: 450
Unused = 0,
// Token: 0x040001C3 RID: 451
KeyCompromise = 1,
// Token: 0x040001C4 RID: 452
CACompromise = 2,
// Token: 0x040001C5 RID: 453
AffiliationChanged = 3,
// Token: 0x040001C6 RID: 454
Superseded = 4,
// Token: 0x040001C7 RID: 455
CessationOfOperation = 5,
// Token: 0x040001C8 RID: 456
CertificateHold = 6,
// Token: 0x040001C9 RID: 457
PrivilegeWithdrawn = 7,
// Token: 0x040001CA RID: 458
AACompromise = 8
}
}
}
@@ -0,0 +1,76 @@
using System;
using System.Collections;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000069 RID: 105
public class CertificatePoliciesExtension : X509Extension
{
// Token: 0x060003DE RID: 990 RVA: 0x00019320 File Offset: 0x00017520
public CertificatePoliciesExtension()
{
this.extnOid = "2.5.29.32";
this.policies = new Hashtable();
}
// Token: 0x060003DF RID: 991 RVA: 0x00019340 File Offset: 0x00017540
public CertificatePoliciesExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003E0 RID: 992 RVA: 0x0001934C File Offset: 0x0001754C
public CertificatePoliciesExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003E1 RID: 993 RVA: 0x00019358 File Offset: 0x00017558
protected override void Decode()
{
this.policies = new Hashtable();
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid CertificatePolicies extension");
}
for (int i = 0; i < asn.Count; i++)
{
this.policies.Add(ASN1Convert.ToOid(asn[i][0]), null);
}
}
// Token: 0x170000DD RID: 221
// (get) Token: 0x060003E2 RID: 994 RVA: 0x000193D0 File Offset: 0x000175D0
public override string Name
{
get
{
return "Certificate Policies";
}
}
// Token: 0x060003E3 RID: 995 RVA: 0x000193D8 File Offset: 0x000175D8
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
int num = 1;
foreach (object obj in this.policies)
{
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
stringBuilder.Append("[");
stringBuilder.Append(num++);
stringBuilder.Append("]Certificate Policy:");
stringBuilder.Append(Environment.NewLine);
stringBuilder.Append("\tPolicyIdentifier=");
stringBuilder.Append((string)dictionaryEntry.Key);
stringBuilder.Append(Environment.NewLine);
}
return stringBuilder.ToString();
}
// Token: 0x040001CB RID: 459
private Hashtable policies;
}
}
@@ -0,0 +1,143 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006A RID: 106
public class ExtendedKeyUsageExtension : X509Extension
{
// Token: 0x060003E4 RID: 996 RVA: 0x000194AC File Offset: 0x000176AC
public ExtendedKeyUsageExtension()
{
this.extnOid = "2.5.29.37";
this.keyPurpose = new ArrayList();
}
// Token: 0x060003E5 RID: 997 RVA: 0x000194CC File Offset: 0x000176CC
public ExtendedKeyUsageExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003E6 RID: 998 RVA: 0x000194D8 File Offset: 0x000176D8
public ExtendedKeyUsageExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003E7 RID: 999 RVA: 0x000194E4 File Offset: 0x000176E4
protected override void Decode()
{
this.keyPurpose = new ArrayList();
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid ExtendedKeyUsage extension");
}
for (int i = 0; i < asn.Count; i++)
{
this.keyPurpose.Add(ASN1Convert.ToOid(asn[i]));
}
}
// Token: 0x060003E8 RID: 1000 RVA: 0x00019554 File Offset: 0x00017754
protected override void Encode()
{
ASN1 asn = new ASN1(48);
foreach (object obj in this.keyPurpose)
{
string text = (string)obj;
asn.Add(ASN1Convert.FromOid(text));
}
this.extnValue = new ASN1(4);
this.extnValue.Add(asn);
}
// Token: 0x170000DE RID: 222
// (get) Token: 0x060003E9 RID: 1001 RVA: 0x000195EC File Offset: 0x000177EC
public ArrayList KeyPurpose
{
get
{
return this.keyPurpose;
}
}
// Token: 0x170000DF RID: 223
// (get) Token: 0x060003EA RID: 1002 RVA: 0x000195F4 File Offset: 0x000177F4
public override string Name
{
get
{
return "Extended Key Usage";
}
}
// Token: 0x060003EB RID: 1003 RVA: 0x000195FC File Offset: 0x000177FC
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
foreach (object obj in this.keyPurpose)
{
string text = (string)obj;
string text2 = text;
if (text2 == null)
{
goto IL_12E;
}
if (ExtendedKeyUsageExtension.<>f__switch$map14 == null)
{
ExtendedKeyUsageExtension.<>f__switch$map14 = new Dictionary<string, int>(6)
{
{ "1.3.6.1.5.5.7.3.1", 0 },
{ "1.3.6.1.5.5.7.3.2", 1 },
{ "1.3.6.1.5.5.7.3.3", 2 },
{ "1.3.6.1.5.5.7.3.4", 3 },
{ "1.3.6.1.5.5.7.3.8", 4 },
{ "1.3.6.1.5.5.7.3.9", 5 }
};
}
int num;
if (!ExtendedKeyUsageExtension.<>f__switch$map14.TryGetValue(text2, out num))
{
goto IL_12E;
}
switch (num)
{
case 0:
stringBuilder.Append("Server Authentication");
break;
case 1:
stringBuilder.Append("Client Authentication");
break;
case 2:
stringBuilder.Append("Code Signing");
break;
case 3:
stringBuilder.Append("Email Protection");
break;
case 4:
stringBuilder.Append("Time Stamping");
break;
case 5:
stringBuilder.Append("OCSP Signing");
break;
default:
goto IL_12E;
}
IL_13F:
stringBuilder.AppendFormat(" ({0}){1}", text, Environment.NewLine);
continue;
IL_12E:
stringBuilder.Append("unknown");
goto IL_13F;
}
return stringBuilder.ToString();
}
// Token: 0x040001CC RID: 460
private ArrayList keyPurpose;
}
}
@@ -0,0 +1,290 @@
using System;
using System.Collections;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006B RID: 107
internal class GeneralNames
{
// Token: 0x060003EC RID: 1004 RVA: 0x000197A4 File Offset: 0x000179A4
public GeneralNames()
{
}
// Token: 0x060003ED RID: 1005 RVA: 0x000197AC File Offset: 0x000179AC
public GeneralNames(string[] rfc822s, string[] dnsNames, string[] ipAddresses, string[] uris)
{
this.asn = new ASN1(48);
if (rfc822s != null)
{
this.rfc822Name = new ArrayList();
foreach (string text in rfc822s)
{
this.asn.Add(new ASN1(129, Encoding.ASCII.GetBytes(text)));
this.rfc822Name.Add(rfc822s);
}
}
if (dnsNames != null)
{
this.dnsName = new ArrayList();
foreach (string text2 in dnsNames)
{
this.asn.Add(new ASN1(130, Encoding.ASCII.GetBytes(text2)));
this.dnsName.Add(text2);
}
}
if (ipAddresses != null)
{
this.ipAddr = new ArrayList();
foreach (string text3 in ipAddresses)
{
string[] array = text3.Split(new char[] { '.', ':' });
byte[] array2 = new byte[array.Length];
for (int l = 0; l < array.Length; l++)
{
array2[l] = byte.Parse(array[l]);
}
this.asn.Add(new ASN1(135, array2));
this.ipAddr.Add(text3);
}
}
if (uris != null)
{
this.uris = new ArrayList();
foreach (string text4 in uris)
{
this.asn.Add(new ASN1(134, Encoding.ASCII.GetBytes(text4)));
this.uris.Add(text4);
}
}
}
// Token: 0x060003EE RID: 1006 RVA: 0x00019994 File Offset: 0x00017B94
public GeneralNames(ASN1 sequence)
{
int i = 0;
while (i < sequence.Count)
{
byte tag = sequence[i].Tag;
switch (tag)
{
case 129:
if (this.rfc822Name == null)
{
this.rfc822Name = new ArrayList();
}
this.rfc822Name.Add(Encoding.ASCII.GetString(sequence[i].Value));
break;
case 130:
if (this.dnsName == null)
{
this.dnsName = new ArrayList();
}
this.dnsName.Add(Encoding.ASCII.GetString(sequence[i].Value));
break;
default:
if (tag == 164)
{
goto IL_CF;
}
break;
case 132:
goto IL_CF;
case 134:
if (this.uris == null)
{
this.uris = new ArrayList();
}
this.uris.Add(Encoding.ASCII.GetString(sequence[i].Value));
break;
case 135:
{
if (this.ipAddr == null)
{
this.ipAddr = new ArrayList();
}
byte[] value = sequence[i].Value;
string text = ((value.Length != 4) ? ":" : ".");
StringBuilder stringBuilder = new StringBuilder();
for (int j = 0; j < value.Length; j++)
{
stringBuilder.Append(value[j].ToString());
if (j < value.Length - 1)
{
stringBuilder.Append(text);
}
}
this.ipAddr.Add(stringBuilder.ToString());
if (this.ipAddr == null)
{
this.ipAddr = new ArrayList();
}
break;
}
}
IL_1F9:
i++;
continue;
IL_CF:
if (this.directoryNames == null)
{
this.directoryNames = new ArrayList();
}
this.directoryNames.Add(X501.ToString(sequence[i][0]));
goto IL_1F9;
}
}
// Token: 0x170000E0 RID: 224
// (get) Token: 0x060003EF RID: 1007 RVA: 0x00019BAC File Offset: 0x00017DAC
public string[] RFC822
{
get
{
if (this.rfc822Name == null)
{
return new string[0];
}
return (string[])this.rfc822Name.ToArray(typeof(string));
}
}
// Token: 0x170000E1 RID: 225
// (get) Token: 0x060003F0 RID: 1008 RVA: 0x00019BE8 File Offset: 0x00017DE8
public string[] DirectoryNames
{
get
{
if (this.directoryNames == null)
{
return new string[0];
}
return (string[])this.directoryNames.ToArray(typeof(string));
}
}
// Token: 0x170000E2 RID: 226
// (get) Token: 0x060003F1 RID: 1009 RVA: 0x00019C24 File Offset: 0x00017E24
public string[] DNSNames
{
get
{
if (this.dnsName == null)
{
return new string[0];
}
return (string[])this.dnsName.ToArray(typeof(string));
}
}
// Token: 0x170000E3 RID: 227
// (get) Token: 0x060003F2 RID: 1010 RVA: 0x00019C60 File Offset: 0x00017E60
public string[] UniformResourceIdentifiers
{
get
{
if (this.uris == null)
{
return new string[0];
}
return (string[])this.uris.ToArray(typeof(string));
}
}
// Token: 0x170000E4 RID: 228
// (get) Token: 0x060003F3 RID: 1011 RVA: 0x00019C9C File Offset: 0x00017E9C
public string[] IPAddresses
{
get
{
if (this.ipAddr == null)
{
return new string[0];
}
return (string[])this.ipAddr.ToArray(typeof(string));
}
}
// Token: 0x060003F4 RID: 1012 RVA: 0x00019CD8 File Offset: 0x00017ED8
public byte[] GetBytes()
{
return this.asn.GetBytes();
}
// Token: 0x060003F5 RID: 1013 RVA: 0x00019CE8 File Offset: 0x00017EE8
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.rfc822Name != null)
{
foreach (object obj in this.rfc822Name)
{
string text = (string)obj;
stringBuilder.Append("RFC822 Name=");
stringBuilder.Append(text);
stringBuilder.Append(Environment.NewLine);
}
}
if (this.dnsName != null)
{
foreach (object obj2 in this.dnsName)
{
string text2 = (string)obj2;
stringBuilder.Append("DNS Name=");
stringBuilder.Append(text2);
stringBuilder.Append(Environment.NewLine);
}
}
if (this.directoryNames != null)
{
foreach (object obj3 in this.directoryNames)
{
string text3 = (string)obj3;
stringBuilder.Append("Directory Address: ");
stringBuilder.Append(text3);
stringBuilder.Append(Environment.NewLine);
}
}
if (this.uris != null)
{
foreach (object obj4 in this.uris)
{
string text4 = (string)obj4;
stringBuilder.Append("URL=");
stringBuilder.Append(text4);
stringBuilder.Append(Environment.NewLine);
}
}
if (this.ipAddr != null)
{
foreach (object obj5 in this.ipAddr)
{
string text5 = (string)obj5;
stringBuilder.Append("IP Address=");
stringBuilder.Append(text5);
stringBuilder.Append(Environment.NewLine);
}
}
return stringBuilder.ToString();
}
// Token: 0x040001CE RID: 462
private ArrayList rfc822Name;
// Token: 0x040001CF RID: 463
private ArrayList dnsName;
// Token: 0x040001D0 RID: 464
private ArrayList directoryNames;
// Token: 0x040001D1 RID: 465
private ArrayList uris;
// Token: 0x040001D2 RID: 466
private ArrayList ipAddr;
// Token: 0x040001D3 RID: 467
private ASN1 asn;
}
}
@@ -0,0 +1,257 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006C RID: 108
public class KeyAttributesExtension : X509Extension
{
// Token: 0x060003F6 RID: 1014 RVA: 0x00019FB4 File Offset: 0x000181B4
public KeyAttributesExtension()
{
this.extnOid = "2.5.29.2";
}
// Token: 0x060003F7 RID: 1015 RVA: 0x00019FC8 File Offset: 0x000181C8
public KeyAttributesExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x060003F8 RID: 1016 RVA: 0x00019FD4 File Offset: 0x000181D4
public KeyAttributesExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x060003F9 RID: 1017 RVA: 0x00019FE0 File Offset: 0x000181E0
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid KeyAttributesExtension extension");
}
int num = 0;
if (num < asn.Count)
{
ASN1 asn2 = asn[num];
if (asn2.Tag == 4)
{
num++;
this.keyId = asn2.Value;
}
}
if (num < asn.Count)
{
ASN1 asn3 = asn[num];
if (asn3.Tag == 3)
{
num++;
int i = 1;
while (i < asn3.Value.Length)
{
this.kubits = (this.kubits << 8) + (int)asn3.Value[i++];
}
}
}
if (num < asn.Count)
{
ASN1 asn4 = asn[num];
if (asn4.Tag == 48)
{
int num2 = 0;
if (num2 < asn4.Count)
{
ASN1 asn5 = asn4[num2];
if (asn5.Tag == 129)
{
num2++;
this.notBefore = ASN1Convert.ToDateTime(asn5);
}
}
if (num2 < asn4.Count)
{
ASN1 asn6 = asn4[num2];
if (asn6.Tag == 130)
{
this.notAfter = ASN1Convert.ToDateTime(asn6);
}
}
}
}
}
// Token: 0x170000E5 RID: 229
// (get) Token: 0x060003FA RID: 1018 RVA: 0x0001A13C File Offset: 0x0001833C
public byte[] KeyIdentifier
{
get
{
if (this.keyId == null)
{
return null;
}
return (byte[])this.keyId.Clone();
}
}
// Token: 0x170000E6 RID: 230
// (get) Token: 0x060003FB RID: 1019 RVA: 0x0001A15C File Offset: 0x0001835C
public override string Name
{
get
{
return "Key Attributes";
}
}
// Token: 0x170000E7 RID: 231
// (get) Token: 0x060003FC RID: 1020 RVA: 0x0001A164 File Offset: 0x00018364
public DateTime NotAfter
{
get
{
return this.notAfter;
}
}
// Token: 0x170000E8 RID: 232
// (get) Token: 0x060003FD RID: 1021 RVA: 0x0001A16C File Offset: 0x0001836C
public DateTime NotBefore
{
get
{
return this.notBefore;
}
}
// Token: 0x060003FE RID: 1022 RVA: 0x0001A174 File Offset: 0x00018374
public bool Support(KeyUsages usage)
{
int num = Convert.ToInt32(usage, CultureInfo.InvariantCulture);
return (num & this.kubits) == num;
}
// Token: 0x060003FF RID: 1023 RVA: 0x0001A1A0 File Offset: 0x000183A0
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.keyId != null)
{
stringBuilder.Append("KeyID=");
for (int i = 0; i < this.keyId.Length; i++)
{
stringBuilder.Append(this.keyId[i].ToString("X2", CultureInfo.InvariantCulture));
if (i % 2 == 1)
{
stringBuilder.Append(" ");
}
}
stringBuilder.Append(Environment.NewLine);
}
if (this.kubits != 0)
{
stringBuilder.Append("Key Usage=");
if (this.Support(KeyUsages.digitalSignature))
{
stringBuilder.Append("Digital Signature");
}
if (this.Support(KeyUsages.nonRepudiation))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Non-Repudiation");
}
if (this.Support(KeyUsages.keyEncipherment))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Key Encipherment");
}
if (this.Support(KeyUsages.dataEncipherment))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Data Encipherment");
}
if (this.Support(KeyUsages.keyAgreement))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Key Agreement");
}
if (this.Support(KeyUsages.keyCertSign))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Certificate Signing");
}
if (this.Support(KeyUsages.cRLSign))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("CRL Signing");
}
if (this.Support(KeyUsages.encipherOnly))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Encipher Only ");
}
if (this.Support(KeyUsages.decipherOnly))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Decipher Only");
}
stringBuilder.Append("(");
stringBuilder.Append(this.kubits.ToString("X2", CultureInfo.InvariantCulture));
stringBuilder.Append(")");
stringBuilder.Append(Environment.NewLine);
}
if (this.notBefore != DateTime.MinValue)
{
stringBuilder.Append("Not Before=");
stringBuilder.Append(this.notBefore.ToString(CultureInfo.CurrentUICulture));
stringBuilder.Append(Environment.NewLine);
}
if (this.notAfter != DateTime.MinValue)
{
stringBuilder.Append("Not After=");
stringBuilder.Append(this.notAfter.ToString(CultureInfo.CurrentUICulture));
stringBuilder.Append(Environment.NewLine);
}
return stringBuilder.ToString();
}
// Token: 0x040001D4 RID: 468
private byte[] keyId;
// Token: 0x040001D5 RID: 469
private int kubits;
// Token: 0x040001D6 RID: 470
private DateTime notBefore;
// Token: 0x040001D7 RID: 471
private DateTime notAfter;
}
}
@@ -0,0 +1,202 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006E RID: 110
public class KeyUsageExtension : X509Extension
{
// Token: 0x06000400 RID: 1024 RVA: 0x0001A4B0 File Offset: 0x000186B0
public KeyUsageExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x06000401 RID: 1025 RVA: 0x0001A4BC File Offset: 0x000186BC
public KeyUsageExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x06000402 RID: 1026 RVA: 0x0001A4C8 File Offset: 0x000186C8
public KeyUsageExtension()
{
this.extnOid = "2.5.29.15";
}
// Token: 0x06000403 RID: 1027 RVA: 0x0001A4DC File Offset: 0x000186DC
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 3)
{
throw new ArgumentException("Invalid KeyUsage extension");
}
int i = 1;
while (i < asn.Value.Length)
{
this.kubits = (this.kubits << 8) + (int)asn.Value[i++];
}
}
// Token: 0x06000404 RID: 1028 RVA: 0x0001A544 File Offset: 0x00018744
protected override void Encode()
{
this.extnValue = new ASN1(4);
ushort num = (ushort)this.kubits;
if (num > 0)
{
byte b;
for (b = 15; b > 0; b -= 1)
{
if ((num & 32768) == 32768)
{
break;
}
num = (ushort)(num << 1);
}
if (this.kubits > 255)
{
b -= 8;
this.extnValue.Add(new ASN1(3, new byte[]
{
b,
(byte)this.kubits,
(byte)(this.kubits >> 8)
}));
}
else
{
this.extnValue.Add(new ASN1(3, new byte[]
{
b,
(byte)this.kubits
}));
}
}
else
{
ASN1 extnValue = this.extnValue;
byte b2 = 3;
byte[] array = new byte[2];
array[0] = 7;
extnValue.Add(new ASN1(b2, array));
}
}
// Token: 0x170000E9 RID: 233
// (get) Token: 0x06000405 RID: 1029 RVA: 0x0001A634 File Offset: 0x00018834
// (set) Token: 0x06000406 RID: 1030 RVA: 0x0001A63C File Offset: 0x0001883C
public KeyUsages KeyUsage
{
get
{
return (KeyUsages)this.kubits;
}
set
{
this.kubits = Convert.ToInt32(value, CultureInfo.InvariantCulture);
}
}
// Token: 0x170000EA RID: 234
// (get) Token: 0x06000407 RID: 1031 RVA: 0x0001A654 File Offset: 0x00018854
public override string Name
{
get
{
return "Key Usage";
}
}
// Token: 0x06000408 RID: 1032 RVA: 0x0001A65C File Offset: 0x0001885C
public bool Support(KeyUsages usage)
{
int num = Convert.ToInt32(usage, CultureInfo.InvariantCulture);
return (num & this.kubits) == num;
}
// Token: 0x06000409 RID: 1033 RVA: 0x0001A688 File Offset: 0x00018888
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.Support(KeyUsages.digitalSignature))
{
stringBuilder.Append("Digital Signature");
}
if (this.Support(KeyUsages.nonRepudiation))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Non-Repudiation");
}
if (this.Support(KeyUsages.keyEncipherment))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Key Encipherment");
}
if (this.Support(KeyUsages.dataEncipherment))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Data Encipherment");
}
if (this.Support(KeyUsages.keyAgreement))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Key Agreement");
}
if (this.Support(KeyUsages.keyCertSign))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Certificate Signing");
}
if (this.Support(KeyUsages.cRLSign))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("CRL Signing");
}
if (this.Support(KeyUsages.encipherOnly))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Encipher Only ");
}
if (this.Support(KeyUsages.decipherOnly))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Decipher Only");
}
stringBuilder.Append("(");
stringBuilder.Append(this.kubits.ToString("X2", CultureInfo.InvariantCulture));
stringBuilder.Append(")");
stringBuilder.Append(Environment.NewLine);
return stringBuilder.ToString();
}
// Token: 0x040001E3 RID: 483
private int kubits;
}
}
@@ -0,0 +1,30 @@
using System;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006D RID: 109
[Flags]
public enum KeyUsages
{
// Token: 0x040001D9 RID: 473
digitalSignature = 128,
// Token: 0x040001DA RID: 474
nonRepudiation = 64,
// Token: 0x040001DB RID: 475
keyEncipherment = 32,
// Token: 0x040001DC RID: 476
dataEncipherment = 16,
// Token: 0x040001DD RID: 477
keyAgreement = 8,
// Token: 0x040001DE RID: 478
keyCertSign = 4,
// Token: 0x040001DF RID: 479
cRLSign = 2,
// Token: 0x040001E0 RID: 480
encipherOnly = 1,
// Token: 0x040001E1 RID: 481
decipherOnly = 2048,
// Token: 0x040001E2 RID: 482
none = 0
}
}
@@ -0,0 +1,146 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x0200006F RID: 111
public class NetscapeCertTypeExtension : X509Extension
{
// Token: 0x0600040A RID: 1034 RVA: 0x0001A884 File Offset: 0x00018A84
public NetscapeCertTypeExtension()
{
this.extnOid = "2.16.840.1.113730.1.1";
}
// Token: 0x0600040B RID: 1035 RVA: 0x0001A898 File Offset: 0x00018A98
public NetscapeCertTypeExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x0600040C RID: 1036 RVA: 0x0001A8A4 File Offset: 0x00018AA4
public NetscapeCertTypeExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x0600040D RID: 1037 RVA: 0x0001A8B0 File Offset: 0x00018AB0
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 3)
{
throw new ArgumentException("Invalid NetscapeCertType extension");
}
int i = 1;
while (i < asn.Value.Length)
{
this.ctbits = (this.ctbits << 8) + (int)asn.Value[i++];
}
}
// Token: 0x170000EB RID: 235
// (get) Token: 0x0600040E RID: 1038 RVA: 0x0001A918 File Offset: 0x00018B18
public override string Name
{
get
{
return "NetscapeCertType";
}
}
// Token: 0x0600040F RID: 1039 RVA: 0x0001A920 File Offset: 0x00018B20
public bool Support(NetscapeCertTypeExtension.CertTypes usage)
{
int num = Convert.ToInt32(usage, CultureInfo.InvariantCulture);
return (num & this.ctbits) == num;
}
// Token: 0x06000410 RID: 1040 RVA: 0x0001A94C File Offset: 0x00018B4C
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.Support(NetscapeCertTypeExtension.CertTypes.SslClient))
{
stringBuilder.Append("SSL Client Authentication");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.SslServer))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("SSL Server Authentication");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.Smime))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("SMIME");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.ObjectSigning))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Object Signing");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.SslCA))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("SSL CA");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.SmimeCA))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("SMIME CA");
}
if (this.Support(NetscapeCertTypeExtension.CertTypes.ObjectSigningCA))
{
if (stringBuilder.Length > 0)
{
stringBuilder.Append(" , ");
}
stringBuilder.Append("Object Signing CA");
}
stringBuilder.Append("(");
stringBuilder.Append(this.ctbits.ToString("X2", CultureInfo.InvariantCulture));
stringBuilder.Append(")");
stringBuilder.Append(Environment.NewLine);
return stringBuilder.ToString();
}
// Token: 0x040001E4 RID: 484
private int ctbits;
// Token: 0x02000070 RID: 112
[Flags]
public enum CertTypes
{
// Token: 0x040001E6 RID: 486
SslClient = 128,
// Token: 0x040001E7 RID: 487
SslServer = 64,
// Token: 0x040001E8 RID: 488
Smime = 32,
// Token: 0x040001E9 RID: 489
ObjectSigning = 16,
// Token: 0x040001EA RID: 490
SslCA = 4,
// Token: 0x040001EB RID: 491
SmimeCA = 2,
// Token: 0x040001EC RID: 492
ObjectSigningCA = 1
}
}
}
@@ -0,0 +1,89 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000071 RID: 113
public class PrivateKeyUsagePeriodExtension : X509Extension
{
// Token: 0x06000411 RID: 1041 RVA: 0x0001AAE4 File Offset: 0x00018CE4
public PrivateKeyUsagePeriodExtension()
{
this.extnOid = "2.5.29.16";
}
// Token: 0x06000412 RID: 1042 RVA: 0x0001AAF8 File Offset: 0x00018CF8
public PrivateKeyUsagePeriodExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x06000413 RID: 1043 RVA: 0x0001AB04 File Offset: 0x00018D04
public PrivateKeyUsagePeriodExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x06000414 RID: 1044 RVA: 0x0001AB10 File Offset: 0x00018D10
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid PrivateKeyUsagePeriod extension");
}
for (int i = 0; i < asn.Count; i++)
{
byte tag = asn[i].Tag;
if (tag != 128)
{
if (tag != 129)
{
throw new ArgumentException("Invalid PrivateKeyUsagePeriod extension");
}
this.notAfter = ASN1Convert.ToDateTime(asn[i]);
}
else
{
this.notBefore = ASN1Convert.ToDateTime(asn[i]);
}
}
}
// Token: 0x170000EC RID: 236
// (get) Token: 0x06000415 RID: 1045 RVA: 0x0001ABC0 File Offset: 0x00018DC0
public override string Name
{
get
{
return "Private Key Usage Period";
}
}
// Token: 0x06000416 RID: 1046 RVA: 0x0001ABC8 File Offset: 0x00018DC8
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
if (this.notBefore != DateTime.MinValue)
{
stringBuilder.Append("Not Before: ");
stringBuilder.Append(this.notBefore.ToString(CultureInfo.CurrentUICulture));
stringBuilder.Append(Environment.NewLine);
}
if (this.notAfter != DateTime.MinValue)
{
stringBuilder.Append("Not After: ");
stringBuilder.Append(this.notAfter.ToString(CultureInfo.CurrentUICulture));
stringBuilder.Append(Environment.NewLine);
}
return stringBuilder.ToString();
}
// Token: 0x040001ED RID: 493
private DateTime notBefore;
// Token: 0x040001EE RID: 494
private DateTime notAfter;
}
}
@@ -0,0 +1,105 @@
using System;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000072 RID: 114
public class SubjectAltNameExtension : X509Extension
{
// Token: 0x06000417 RID: 1047 RVA: 0x0001AC6C File Offset: 0x00018E6C
public SubjectAltNameExtension()
{
this.extnOid = "2.5.29.17";
this._names = new GeneralNames();
}
// Token: 0x06000418 RID: 1048 RVA: 0x0001AC8C File Offset: 0x00018E8C
public SubjectAltNameExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x06000419 RID: 1049 RVA: 0x0001AC98 File Offset: 0x00018E98
public SubjectAltNameExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x0600041A RID: 1050 RVA: 0x0001ACA4 File Offset: 0x00018EA4
public SubjectAltNameExtension(string[] rfc822, string[] dnsNames, string[] ipAddresses, string[] uris)
{
this._names = new GeneralNames(rfc822, dnsNames, ipAddresses, uris);
this.extnValue = new ASN1(4, this._names.GetBytes());
this.extnOid = "2.5.29.17";
}
// Token: 0x0600041B RID: 1051 RVA: 0x0001ACEC File Offset: 0x00018EEC
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 48)
{
throw new ArgumentException("Invalid SubjectAltName extension");
}
this._names = new GeneralNames(asn);
}
// Token: 0x170000ED RID: 237
// (get) Token: 0x0600041C RID: 1052 RVA: 0x0001AD30 File Offset: 0x00018F30
public override string Name
{
get
{
return "Subject Alternative Name";
}
}
// Token: 0x170000EE RID: 238
// (get) Token: 0x0600041D RID: 1053 RVA: 0x0001AD38 File Offset: 0x00018F38
public string[] RFC822
{
get
{
return this._names.RFC822;
}
}
// Token: 0x170000EF RID: 239
// (get) Token: 0x0600041E RID: 1054 RVA: 0x0001AD48 File Offset: 0x00018F48
public string[] DNSNames
{
get
{
return this._names.DNSNames;
}
}
// Token: 0x170000F0 RID: 240
// (get) Token: 0x0600041F RID: 1055 RVA: 0x0001AD58 File Offset: 0x00018F58
public string[] IPAddresses
{
get
{
return this._names.IPAddresses;
}
}
// Token: 0x170000F1 RID: 241
// (get) Token: 0x06000420 RID: 1056 RVA: 0x0001AD68 File Offset: 0x00018F68
public string[] UniformResourceIdentifiers
{
get
{
return this._names.UniformResourceIdentifiers;
}
}
// Token: 0x06000421 RID: 1057 RVA: 0x0001AD78 File Offset: 0x00018F78
public override string ToString()
{
return this._names.ToString();
}
// Token: 0x040001EF RID: 495
private GeneralNames _names;
}
}
@@ -0,0 +1,85 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509.Extensions
{
// Token: 0x02000073 RID: 115
public class SubjectKeyIdentifierExtension : X509Extension
{
// Token: 0x06000422 RID: 1058 RVA: 0x0001AD88 File Offset: 0x00018F88
public SubjectKeyIdentifierExtension()
{
this.extnOid = "2.5.29.14";
}
// Token: 0x06000423 RID: 1059 RVA: 0x0001AD9C File Offset: 0x00018F9C
public SubjectKeyIdentifierExtension(ASN1 asn1)
: base(asn1)
{
}
// Token: 0x06000424 RID: 1060 RVA: 0x0001ADA8 File Offset: 0x00018FA8
public SubjectKeyIdentifierExtension(X509Extension extension)
: base(extension)
{
}
// Token: 0x06000425 RID: 1061 RVA: 0x0001ADB4 File Offset: 0x00018FB4
protected override void Decode()
{
ASN1 asn = new ASN1(this.extnValue.Value);
if (asn.Tag != 4)
{
throw new ArgumentException("Invalid SubjectKeyIdentifier extension");
}
this.ski = asn.Value;
}
// Token: 0x170000F2 RID: 242
// (get) Token: 0x06000426 RID: 1062 RVA: 0x0001ADF8 File Offset: 0x00018FF8
public override string Name
{
get
{
return "Subject Key Identifier";
}
}
// Token: 0x170000F3 RID: 243
// (get) Token: 0x06000427 RID: 1063 RVA: 0x0001AE00 File Offset: 0x00019000
public byte[] Identifier
{
get
{
if (this.ski == null)
{
return null;
}
return (byte[])this.ski.Clone();
}
}
// Token: 0x06000428 RID: 1064 RVA: 0x0001AE20 File Offset: 0x00019020
public override string ToString()
{
if (this.ski == null)
{
return null;
}
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < this.ski.Length; i++)
{
stringBuilder.Append(this.ski[i].ToString("X2", CultureInfo.InvariantCulture));
if (i % 2 == 1)
{
stringBuilder.Append(" ");
}
}
return stringBuilder.ToString();
}
// Token: 0x040001F0 RID: 496
private byte[] ski;
}
}
+2347
View File
@@ -0,0 +1,2347 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using Mono.Security.Cryptography;
namespace Mono.Security.X509
{
// Token: 0x0200003E RID: 62
public class PKCS12 : ICloneable
{
// Token: 0x0600027F RID: 639 RVA: 0x00010560 File Offset: 0x0000E760
public PKCS12()
{
this._iterations = PKCS12.recommendedIterationCount;
this._keyBags = new ArrayList();
this._secretBags = new ArrayList();
this._certs = new X509CertificateCollection();
this._keyBagsChanged = false;
this._secretBagsChanged = false;
this._certsChanged = false;
this._safeBags = new ArrayList();
}
// Token: 0x06000280 RID: 640 RVA: 0x000105C0 File Offset: 0x0000E7C0
public PKCS12(byte[] data)
: this()
{
this.Password = null;
this.Decode(data);
}
// Token: 0x06000281 RID: 641 RVA: 0x000105D8 File Offset: 0x0000E7D8
public PKCS12(byte[] data, string password)
: this()
{
this.Password = password;
this.Decode(data);
}
// Token: 0x06000282 RID: 642 RVA: 0x000105F0 File Offset: 0x0000E7F0
public PKCS12(byte[] data, byte[] password)
: this()
{
this._password = password;
this.Decode(data);
}
// Token: 0x06000284 RID: 644 RVA: 0x00010620 File Offset: 0x0000E820
private void Decode(byte[] data)
{
ASN1 asn = new ASN1(data);
if (asn.Tag != 48)
{
throw new ArgumentException("invalid data");
}
ASN1 asn2 = asn[0];
if (asn2.Tag != 2)
{
throw new ArgumentException("invalid PFX version");
}
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn[1]);
if (contentInfo.ContentType != "1.2.840.113549.1.7.1")
{
throw new ArgumentException("invalid authenticated safe");
}
if (asn.Count > 2)
{
ASN1 asn3 = asn[2];
if (asn3.Tag != 48)
{
throw new ArgumentException("invalid MAC");
}
ASN1 asn4 = asn3[0];
if (asn4.Tag != 48)
{
throw new ArgumentException("invalid MAC");
}
ASN1 asn5 = asn4[0];
string text = ASN1Convert.ToOid(asn5[0]);
if (text != "1.3.14.3.2.26")
{
throw new ArgumentException("unsupported HMAC");
}
byte[] value = asn4[1].Value;
ASN1 asn6 = asn3[1];
if (asn6.Tag != 4)
{
throw new ArgumentException("missing MAC salt");
}
this._iterations = 1;
if (asn3.Count > 2)
{
ASN1 asn7 = asn3[2];
if (asn7.Tag != 2)
{
throw new ArgumentException("invalid MAC iteration");
}
this._iterations = ASN1Convert.ToInt32(asn7);
}
byte[] value2 = contentInfo.Content[0].Value;
byte[] array = this.MAC(this._password, asn6.Value, this._iterations, value2);
if (!this.Compare(value, array))
{
throw new CryptographicException("Invalid MAC - file may have been tampered!");
}
}
ASN1 asn8 = new ASN1(contentInfo.Content[0].Value);
int i = 0;
while (i < asn8.Count)
{
PKCS7.ContentInfo contentInfo2 = new PKCS7.ContentInfo(asn8[i]);
string contentType = contentInfo2.ContentType;
if (contentType != null)
{
if (PKCS12.<>f__switch$map5 == null)
{
PKCS12.<>f__switch$map5 = new Dictionary<string, int>(3)
{
{ "1.2.840.113549.1.7.1", 0 },
{ "1.2.840.113549.1.7.6", 1 },
{ "1.2.840.113549.1.7.3", 2 }
};
}
int num;
if (PKCS12.<>f__switch$map5.TryGetValue(contentType, out num))
{
switch (num)
{
case 0:
{
ASN1 asn9 = new ASN1(contentInfo2.Content[0].Value);
for (int j = 0; j < asn9.Count; j++)
{
ASN1 asn10 = asn9[j];
this.ReadSafeBag(asn10);
}
break;
}
case 1:
{
PKCS7.EncryptedData encryptedData = new PKCS7.EncryptedData(contentInfo2.Content[0]);
ASN1 asn11 = new ASN1(this.Decrypt(encryptedData));
for (int k = 0; k < asn11.Count; k++)
{
ASN1 asn12 = asn11[k];
this.ReadSafeBag(asn12);
}
break;
}
case 2:
throw new NotImplementedException("public key encrypted");
default:
goto IL_303;
}
i++;
continue;
}
}
IL_303:
throw new ArgumentException("unknown authenticatedSafe");
}
}
// Token: 0x06000285 RID: 645 RVA: 0x00010950 File Offset: 0x0000EB50
~PKCS12()
{
if (this._password != null)
{
Array.Clear(this._password, 0, this._password.Length);
}
this._password = null;
}
// Token: 0x1700007D RID: 125
// (set) Token: 0x06000286 RID: 646 RVA: 0x000109AC File Offset: 0x0000EBAC
public string Password
{
set
{
if (value != null)
{
if (value.Length > 0)
{
int num = value.Length;
int num2 = 0;
if (num < PKCS12.MaximumPasswordLength)
{
if (value[num - 1] != '\0')
{
num2 = 1;
}
}
else
{
num = PKCS12.MaximumPasswordLength;
}
this._password = new byte[num + num2 << 1];
Encoding.BigEndianUnicode.GetBytes(value, 0, num, this._password, 0);
}
else
{
this._password = new byte[2];
}
}
else
{
this._password = null;
}
}
}
// Token: 0x1700007E RID: 126
// (get) Token: 0x06000287 RID: 647 RVA: 0x00010A3C File Offset: 0x0000EC3C
// (set) Token: 0x06000288 RID: 648 RVA: 0x00010A44 File Offset: 0x0000EC44
public int IterationCount
{
get
{
return this._iterations;
}
set
{
this._iterations = value;
}
}
// Token: 0x1700007F RID: 127
// (get) Token: 0x06000289 RID: 649 RVA: 0x00010A50 File Offset: 0x0000EC50
public ArrayList Keys
{
get
{
if (this._keyBagsChanged)
{
this._keyBags.Clear();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn2.Value);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
if (b != 2)
{
if (b == 48)
{
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey));
}
}
else
{
DSAParameters dsaparameters = default(DSAParameters);
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, dsaparameters));
}
Array.Clear(privateKey, 0, privateKey.Length);
}
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
ASN1 asn3 = safeBag.ASN1;
ASN1 asn4 = asn3[1];
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn4.Value);
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array);
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
byte b = privateKey2[0];
if (b != 2)
{
if (b == 48)
{
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2));
}
}
else
{
DSAParameters dsaparameters2 = default(DSAParameters);
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, dsaparameters2));
}
Array.Clear(privateKey2, 0, privateKey2.Length);
Array.Clear(array, 0, array.Length);
}
}
this._keyBagsChanged = false;
}
return ArrayList.ReadOnly(this._keyBags);
}
}
// Token: 0x17000080 RID: 128
// (get) Token: 0x0600028A RID: 650 RVA: 0x00010C68 File Offset: 0x0000EE68
public ArrayList Secrets
{
get
{
if (this._secretBagsChanged)
{
this._secretBags.Clear();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
byte[] value = asn2.Value;
this._secretBags.Add(value);
}
}
this._secretBagsChanged = false;
}
return ArrayList.ReadOnly(this._secretBags);
}
}
// Token: 0x17000081 RID: 129
// (get) Token: 0x0600028B RID: 651 RVA: 0x00010D38 File Offset: 0x0000EF38
public X509CertificateCollection Certificates
{
get
{
if (this._certsChanged)
{
this._certs.Clear();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
this._certs.Add(new X509Certificate(contentInfo.Content[0].Value));
}
}
this._certsChanged = false;
}
return this._certs;
}
}
// Token: 0x17000082 RID: 130
// (get) Token: 0x0600028C RID: 652 RVA: 0x00010E1C File Offset: 0x0000F01C
internal RandomNumberGenerator RNG
{
get
{
if (this._rng == null)
{
this._rng = RandomNumberGenerator.Create();
}
return this._rng;
}
}
// Token: 0x0600028D RID: 653 RVA: 0x00010E3C File Offset: 0x0000F03C
private bool Compare(byte[] expected, byte[] actual)
{
bool flag = false;
if (expected.Length == actual.Length)
{
for (int i = 0; i < expected.Length; i++)
{
if (expected[i] != actual[i])
{
return false;
}
}
flag = true;
}
return flag;
}
// Token: 0x0600028E RID: 654 RVA: 0x00010E7C File Offset: 0x0000F07C
private SymmetricAlgorithm GetSymmetricAlgorithm(string algorithmOid, byte[] salt, int iterationCount)
{
string text = null;
int num = 8;
int num2 = 8;
PKCS12.DeriveBytes deriveBytes = new PKCS12.DeriveBytes();
deriveBytes.Password = this._password;
deriveBytes.Salt = salt;
deriveBytes.IterationCount = iterationCount;
if (algorithmOid != null)
{
if (PKCS12.<>f__switch$map6 == null)
{
PKCS12.<>f__switch$map6 = new Dictionary<string, int>(12)
{
{ "1.2.840.113549.1.5.1", 0 },
{ "1.2.840.113549.1.5.3", 1 },
{ "1.2.840.113549.1.5.4", 2 },
{ "1.2.840.113549.1.5.6", 3 },
{ "1.2.840.113549.1.5.10", 4 },
{ "1.2.840.113549.1.5.11", 5 },
{ "1.2.840.113549.1.12.1.1", 6 },
{ "1.2.840.113549.1.12.1.2", 7 },
{ "1.2.840.113549.1.12.1.3", 8 },
{ "1.2.840.113549.1.12.1.4", 9 },
{ "1.2.840.113549.1.12.1.5", 10 },
{ "1.2.840.113549.1.12.1.6", 11 }
};
}
int num3;
if (PKCS12.<>f__switch$map6.TryGetValue(algorithmOid, out num3))
{
switch (num3)
{
case 0:
deriveBytes.HashName = "MD2";
text = "DES";
break;
case 1:
deriveBytes.HashName = "MD5";
text = "DES";
break;
case 2:
deriveBytes.HashName = "MD2";
text = "RC2";
num = 4;
break;
case 3:
deriveBytes.HashName = "MD5";
text = "RC2";
num = 4;
break;
case 4:
deriveBytes.HashName = "SHA1";
text = "DES";
break;
case 5:
deriveBytes.HashName = "SHA1";
text = "RC2";
num = 4;
break;
case 6:
deriveBytes.HashName = "SHA1";
text = "RC4";
num = 16;
num2 = 0;
break;
case 7:
deriveBytes.HashName = "SHA1";
text = "RC4";
num = 5;
num2 = 0;
break;
case 8:
deriveBytes.HashName = "SHA1";
text = "TripleDES";
num = 24;
break;
case 9:
deriveBytes.HashName = "SHA1";
text = "TripleDES";
num = 16;
break;
case 10:
deriveBytes.HashName = "SHA1";
text = "RC2";
num = 16;
break;
case 11:
deriveBytes.HashName = "SHA1";
text = "RC2";
num = 5;
break;
default:
goto IL_25A;
}
SymmetricAlgorithm symmetricAlgorithm = SymmetricAlgorithm.Create(text);
symmetricAlgorithm.Key = deriveBytes.DeriveKey(num);
if (num2 > 0)
{
symmetricAlgorithm.IV = deriveBytes.DeriveIV(num2);
symmetricAlgorithm.Mode = CipherMode.CBC;
}
return symmetricAlgorithm;
}
}
IL_25A:
throw new NotSupportedException("unknown oid " + text);
}
// Token: 0x0600028F RID: 655 RVA: 0x0001112C File Offset: 0x0000F32C
public byte[] Decrypt(string algorithmOid, byte[] salt, int iterationCount, byte[] encryptedData)
{
SymmetricAlgorithm symmetricAlgorithm = null;
byte[] array = null;
try
{
symmetricAlgorithm = this.GetSymmetricAlgorithm(algorithmOid, salt, iterationCount);
ICryptoTransform cryptoTransform = symmetricAlgorithm.CreateDecryptor();
array = cryptoTransform.TransformFinalBlock(encryptedData, 0, encryptedData.Length);
}
finally
{
if (symmetricAlgorithm != null)
{
symmetricAlgorithm.Clear();
}
}
return array;
}
// Token: 0x06000290 RID: 656 RVA: 0x0001118C File Offset: 0x0000F38C
public byte[] Decrypt(PKCS7.EncryptedData ed)
{
return this.Decrypt(ed.EncryptionAlgorithm.ContentType, ed.EncryptionAlgorithm.Content[0].Value, ASN1Convert.ToInt32(ed.EncryptionAlgorithm.Content[1]), ed.EncryptedContent);
}
// Token: 0x06000291 RID: 657 RVA: 0x000111DC File Offset: 0x0000F3DC
public byte[] Encrypt(string algorithmOid, byte[] salt, int iterationCount, byte[] data)
{
byte[] array = null;
using (SymmetricAlgorithm symmetricAlgorithm = this.GetSymmetricAlgorithm(algorithmOid, salt, iterationCount))
{
ICryptoTransform cryptoTransform = symmetricAlgorithm.CreateEncryptor();
array = cryptoTransform.TransformFinalBlock(data, 0, data.Length);
}
return array;
}
// Token: 0x06000292 RID: 658 RVA: 0x0001123C File Offset: 0x0000F43C
private DSAParameters GetExistingParameters(out bool found)
{
foreach (X509Certificate x509Certificate in this.Certificates)
{
if (x509Certificate.KeyAlgorithmParameters != null)
{
DSA dsa = x509Certificate.DSA;
if (dsa != null)
{
found = true;
return dsa.ExportParameters(false);
}
}
}
found = false;
return default(DSAParameters);
}
// Token: 0x06000293 RID: 659 RVA: 0x000112DC File Offset: 0x0000F4DC
private void AddPrivateKey(PKCS8.PrivateKeyInfo pki)
{
byte[] privateKey = pki.PrivateKey;
byte b = privateKey[0];
if (b != 2)
{
if (b != 48)
{
Array.Clear(privateKey, 0, privateKey.Length);
throw new CryptographicException("Unknown private key format");
}
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeRSA(privateKey));
}
else
{
bool flag;
DSAParameters existingParameters = this.GetExistingParameters(out flag);
if (flag)
{
this._keyBags.Add(PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, existingParameters));
}
}
Array.Clear(privateKey, 0, privateKey.Length);
}
// Token: 0x06000294 RID: 660 RVA: 0x00011368 File Offset: 0x0000F568
private void ReadSafeBag(ASN1 safeBag)
{
if (safeBag.Tag != 48)
{
throw new ArgumentException("invalid safeBag");
}
ASN1 asn = safeBag[0];
if (asn.Tag != 6)
{
throw new ArgumentException("invalid safeBag id");
}
ASN1 asn2 = safeBag[1];
string text = ASN1Convert.ToOid(asn);
string text2 = text;
if (text2 != null)
{
if (PKCS12.<>f__switch$map7 == null)
{
PKCS12.<>f__switch$map7 = new Dictionary<string, int>(6)
{
{ "1.2.840.113549.1.12.10.1.1", 0 },
{ "1.2.840.113549.1.12.10.1.2", 1 },
{ "1.2.840.113549.1.12.10.1.3", 2 },
{ "1.2.840.113549.1.12.10.1.4", 3 },
{ "1.2.840.113549.1.12.10.1.5", 4 },
{ "1.2.840.113549.1.12.10.1.6", 5 }
};
}
int num;
if (PKCS12.<>f__switch$map7.TryGetValue(text2, out num))
{
switch (num)
{
case 0:
this.AddPrivateKey(new PKCS8.PrivateKeyInfo(asn2.Value));
break;
case 1:
{
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn2.Value);
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
this.AddPrivateKey(new PKCS8.PrivateKeyInfo(array));
Array.Clear(array, 0, array.Length);
break;
}
case 2:
{
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
if (contentInfo.ContentType != "1.2.840.113549.1.9.22.1")
{
throw new NotSupportedException("unsupport certificate type");
}
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
this._certs.Add(x509Certificate);
break;
}
case 3:
break;
case 4:
{
byte[] value = asn2.Value;
this._secretBags.Add(value);
break;
}
case 5:
break;
default:
goto IL_1CD;
}
if (safeBag.Count > 2)
{
ASN1 asn3 = safeBag[2];
if (asn3.Tag != 49)
{
throw new ArgumentException("invalid safeBag attributes id");
}
for (int i = 0; i < asn3.Count; i++)
{
ASN1 asn4 = asn3[i];
if (asn4.Tag != 48)
{
throw new ArgumentException("invalid PKCS12 attributes id");
}
ASN1 asn5 = asn4[0];
if (asn5.Tag != 6)
{
throw new ArgumentException("invalid attribute id");
}
string text3 = ASN1Convert.ToOid(asn5);
ASN1 asn6 = asn4[1];
int j = 0;
while (j < asn6.Count)
{
ASN1 asn7 = asn6[j];
text2 = text3;
if (text2 != null)
{
if (PKCS12.<>f__switch$map8 == null)
{
PKCS12.<>f__switch$map8 = new Dictionary<string, int>(2)
{
{ "1.2.840.113549.1.9.20", 0 },
{ "1.2.840.113549.1.9.21", 1 }
};
}
if (PKCS12.<>f__switch$map8.TryGetValue(text2, out num))
{
if (num != 0)
{
if (num == 1)
{
if (asn7.Tag != 4)
{
throw new ArgumentException("invalid attribute value id");
}
}
}
else if (asn7.Tag != 30)
{
throw new ArgumentException("invalid attribute value id");
}
}
}
IL_31F:
j++;
continue;
goto IL_31F;
}
}
}
this._safeBags.Add(new SafeBag(text, safeBag));
return;
}
}
IL_1CD:
throw new ArgumentException("unknown safeBag oid");
}
// Token: 0x06000295 RID: 661 RVA: 0x000116D0 File Offset: 0x0000F8D0
private ASN1 Pkcs8ShroudedKeyBagSafeBag(AsymmetricAlgorithm aa, IDictionary attributes)
{
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo();
if (aa is RSA)
{
privateKeyInfo.Algorithm = "1.2.840.113549.1.1.1";
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((RSA)aa);
}
else
{
if (!(aa is DSA))
{
throw new CryptographicException("Unknown asymmetric algorithm {0}", aa.ToString());
}
privateKeyInfo.Algorithm = null;
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((DSA)aa);
}
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo();
encryptedPrivateKeyInfo.Algorithm = "1.2.840.113549.1.12.1.3";
encryptedPrivateKeyInfo.IterationCount = this._iterations;
encryptedPrivateKeyInfo.EncryptedData = this.Encrypt("1.2.840.113549.1.12.1.3", encryptedPrivateKeyInfo.Salt, this._iterations, privateKeyInfo.GetBytes());
ASN1 asn = new ASN1(48);
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.2"));
ASN1 asn2 = new ASN1(160);
asn2.Add(new ASN1(encryptedPrivateKeyInfo.GetBytes()));
asn.Add(asn2);
if (attributes != null)
{
ASN1 asn3 = new ASN1(49);
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
while (enumerator.MoveNext())
{
string text = (string)enumerator.Key;
string text2 = text;
if (text2 != null)
{
if (PKCS12.<>f__switch$map9 == null)
{
PKCS12.<>f__switch$map9 = new Dictionary<string, int>(2)
{
{ "1.2.840.113549.1.9.20", 0 },
{ "1.2.840.113549.1.9.21", 1 }
};
}
int num;
if (PKCS12.<>f__switch$map9.TryGetValue(text2, out num))
{
if (num != 0)
{
if (num == 1)
{
ArrayList arrayList = (ArrayList)enumerator.Value;
if (arrayList.Count > 0)
{
ASN1 asn4 = new ASN1(48);
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
ASN1 asn5 = new ASN1(49);
foreach (object obj in arrayList)
{
byte[] array = (byte[])obj;
asn5.Add(new ASN1(4)
{
Value = array
});
}
asn4.Add(asn5);
asn3.Add(asn4);
}
}
}
else
{
ArrayList arrayList2 = (ArrayList)enumerator.Value;
if (arrayList2.Count > 0)
{
ASN1 asn6 = new ASN1(48);
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
ASN1 asn7 = new ASN1(49);
foreach (object obj2 in arrayList2)
{
byte[] array2 = (byte[])obj2;
asn7.Add(new ASN1(30)
{
Value = array2
});
}
asn6.Add(asn7);
asn3.Add(asn6);
}
}
}
}
}
if (asn3.Count > 0)
{
asn.Add(asn3);
}
}
return asn;
}
// Token: 0x06000296 RID: 662 RVA: 0x00011A20 File Offset: 0x0000FC20
private ASN1 KeyBagSafeBag(AsymmetricAlgorithm aa, IDictionary attributes)
{
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo();
if (aa is RSA)
{
privateKeyInfo.Algorithm = "1.2.840.113549.1.1.1";
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((RSA)aa);
}
else
{
if (!(aa is DSA))
{
throw new CryptographicException("Unknown asymmetric algorithm {0}", aa.ToString());
}
privateKeyInfo.Algorithm = null;
privateKeyInfo.PrivateKey = PKCS8.PrivateKeyInfo.Encode((DSA)aa);
}
ASN1 asn = new ASN1(48);
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.1"));
ASN1 asn2 = new ASN1(160);
asn2.Add(new ASN1(privateKeyInfo.GetBytes()));
asn.Add(asn2);
if (attributes != null)
{
ASN1 asn3 = new ASN1(49);
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
while (enumerator.MoveNext())
{
string text = (string)enumerator.Key;
string text2 = text;
if (text2 != null)
{
if (PKCS12.<>f__switch$mapA == null)
{
PKCS12.<>f__switch$mapA = new Dictionary<string, int>(2)
{
{ "1.2.840.113549.1.9.20", 0 },
{ "1.2.840.113549.1.9.21", 1 }
};
}
int num;
if (PKCS12.<>f__switch$mapA.TryGetValue(text2, out num))
{
if (num != 0)
{
if (num == 1)
{
ArrayList arrayList = (ArrayList)enumerator.Value;
if (arrayList.Count > 0)
{
ASN1 asn4 = new ASN1(48);
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
ASN1 asn5 = new ASN1(49);
foreach (object obj in arrayList)
{
byte[] array = (byte[])obj;
asn5.Add(new ASN1(4)
{
Value = array
});
}
asn4.Add(asn5);
asn3.Add(asn4);
}
}
}
else
{
ArrayList arrayList2 = (ArrayList)enumerator.Value;
if (arrayList2.Count > 0)
{
ASN1 asn6 = new ASN1(48);
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
ASN1 asn7 = new ASN1(49);
foreach (object obj2 in arrayList2)
{
byte[] array2 = (byte[])obj2;
asn7.Add(new ASN1(30)
{
Value = array2
});
}
asn6.Add(asn7);
asn3.Add(asn6);
}
}
}
}
}
if (asn3.Count > 0)
{
asn.Add(asn3);
}
}
return asn;
}
// Token: 0x06000297 RID: 663 RVA: 0x00011D2C File Offset: 0x0000FF2C
private ASN1 SecretBagSafeBag(byte[] secret, IDictionary attributes)
{
ASN1 asn = new ASN1(48);
asn.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.5"));
ASN1 asn2 = new ASN1(128, secret);
asn.Add(asn2);
if (attributes != null)
{
ASN1 asn3 = new ASN1(49);
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
while (enumerator.MoveNext())
{
string text = (string)enumerator.Key;
string text2 = text;
if (text2 != null)
{
if (PKCS12.<>f__switch$mapB == null)
{
PKCS12.<>f__switch$mapB = new Dictionary<string, int>(2)
{
{ "1.2.840.113549.1.9.20", 0 },
{ "1.2.840.113549.1.9.21", 1 }
};
}
int num;
if (PKCS12.<>f__switch$mapB.TryGetValue(text2, out num))
{
if (num != 0)
{
if (num == 1)
{
ArrayList arrayList = (ArrayList)enumerator.Value;
if (arrayList.Count > 0)
{
ASN1 asn4 = new ASN1(48);
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
ASN1 asn5 = new ASN1(49);
foreach (object obj in arrayList)
{
byte[] array = (byte[])obj;
asn5.Add(new ASN1(4)
{
Value = array
});
}
asn4.Add(asn5);
asn3.Add(asn4);
}
}
}
else
{
ArrayList arrayList2 = (ArrayList)enumerator.Value;
if (arrayList2.Count > 0)
{
ASN1 asn6 = new ASN1(48);
asn6.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
ASN1 asn7 = new ASN1(49);
foreach (object obj2 in arrayList2)
{
byte[] array2 = (byte[])obj2;
asn7.Add(new ASN1(30)
{
Value = array2
});
}
asn6.Add(asn7);
asn3.Add(asn6);
}
}
}
}
}
if (asn3.Count > 0)
{
asn.Add(asn3);
}
}
return asn;
}
// Token: 0x06000298 RID: 664 RVA: 0x00011FB4 File Offset: 0x000101B4
private ASN1 CertificateSafeBag(X509Certificate x509, IDictionary attributes)
{
ASN1 asn = new ASN1(4, x509.RawData);
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo();
contentInfo.ContentType = "1.2.840.113549.1.9.22.1";
contentInfo.Content.Add(asn);
ASN1 asn2 = new ASN1(160);
asn2.Add(contentInfo.ASN1);
ASN1 asn3 = new ASN1(48);
asn3.Add(ASN1Convert.FromOid("1.2.840.113549.1.12.10.1.3"));
asn3.Add(asn2);
if (attributes != null)
{
ASN1 asn4 = new ASN1(49);
IDictionaryEnumerator enumerator = attributes.GetEnumerator();
while (enumerator.MoveNext())
{
string text = (string)enumerator.Key;
string text2 = text;
if (text2 != null)
{
if (PKCS12.<>f__switch$mapC == null)
{
PKCS12.<>f__switch$mapC = new Dictionary<string, int>(2)
{
{ "1.2.840.113549.1.9.20", 0 },
{ "1.2.840.113549.1.9.21", 1 }
};
}
int num;
if (PKCS12.<>f__switch$mapC.TryGetValue(text2, out num))
{
if (num != 0)
{
if (num == 1)
{
ArrayList arrayList = (ArrayList)enumerator.Value;
if (arrayList.Count > 0)
{
ASN1 asn5 = new ASN1(48);
asn5.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.21"));
ASN1 asn6 = new ASN1(49);
foreach (object obj in arrayList)
{
byte[] array = (byte[])obj;
asn6.Add(new ASN1(4)
{
Value = array
});
}
asn5.Add(asn6);
asn4.Add(asn5);
}
}
}
else
{
ArrayList arrayList2 = (ArrayList)enumerator.Value;
if (arrayList2.Count > 0)
{
ASN1 asn7 = new ASN1(48);
asn7.Add(ASN1Convert.FromOid("1.2.840.113549.1.9.20"));
ASN1 asn8 = new ASN1(49);
foreach (object obj2 in arrayList2)
{
byte[] array2 = (byte[])obj2;
asn8.Add(new ASN1(30)
{
Value = array2
});
}
asn7.Add(asn8);
asn4.Add(asn7);
}
}
}
}
}
if (asn4.Count > 0)
{
asn3.Add(asn4);
}
}
return asn3;
}
// Token: 0x06000299 RID: 665 RVA: 0x00012280 File Offset: 0x00010480
private byte[] MAC(byte[] password, byte[] salt, int iterations, byte[] data)
{
PKCS12.DeriveBytes deriveBytes = new PKCS12.DeriveBytes();
deriveBytes.HashName = "SHA1";
deriveBytes.Password = password;
deriveBytes.Salt = salt;
deriveBytes.IterationCount = iterations;
HMACSHA1 hmacsha = (HMACSHA1)global::System.Security.Cryptography.HMAC.Create();
hmacsha.Key = deriveBytes.DeriveMAC(20);
return hmacsha.ComputeHash(data, 0, data.Length);
}
// Token: 0x0600029A RID: 666 RVA: 0x000122DC File Offset: 0x000104DC
public byte[] GetBytes()
{
ASN1 asn = new ASN1(48);
ArrayList arrayList = new ArrayList();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn2 = safeBag.ASN1;
ASN1 asn3 = asn2[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn3.Value);
arrayList.Add(new X509Certificate(contentInfo.Content[0].Value));
}
}
ArrayList arrayList2 = new ArrayList();
ArrayList arrayList3 = new ArrayList();
foreach (X509Certificate x509Certificate in this.Certificates)
{
bool flag = false;
foreach (object obj2 in arrayList)
{
X509Certificate x509Certificate2 = (X509Certificate)obj2;
if (this.Compare(x509Certificate.RawData, x509Certificate2.RawData))
{
flag = true;
}
}
if (!flag)
{
arrayList2.Add(x509Certificate);
}
}
foreach (object obj3 in arrayList)
{
X509Certificate x509Certificate3 = (X509Certificate)obj3;
bool flag2 = false;
foreach (X509Certificate x509Certificate4 in this.Certificates)
{
if (this.Compare(x509Certificate3.RawData, x509Certificate4.RawData))
{
flag2 = true;
}
}
if (!flag2)
{
arrayList3.Add(x509Certificate3);
}
}
foreach (object obj4 in arrayList3)
{
X509Certificate x509Certificate5 = (X509Certificate)obj4;
this.RemoveCertificate(x509Certificate5);
}
foreach (object obj5 in arrayList2)
{
X509Certificate x509Certificate6 = (X509Certificate)obj5;
this.AddCertificate(x509Certificate6);
}
if (this._safeBags.Count > 0)
{
ASN1 asn4 = new ASN1(48);
foreach (object obj6 in this._safeBags)
{
SafeBag safeBag2 = (SafeBag)obj6;
if (safeBag2.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
asn4.Add(safeBag2.ASN1);
}
}
if (asn4.Count > 0)
{
PKCS7.ContentInfo contentInfo2 = this.EncryptedContentInfo(asn4, "1.2.840.113549.1.12.1.3");
asn.Add(contentInfo2.ASN1);
}
}
if (this._safeBags.Count > 0)
{
ASN1 asn5 = new ASN1(48);
foreach (object obj7 in this._safeBags)
{
SafeBag safeBag3 = (SafeBag)obj7;
if (safeBag3.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag3.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
asn5.Add(safeBag3.ASN1);
}
}
if (asn5.Count > 0)
{
ASN1 asn6 = new ASN1(160);
asn6.Add(new ASN1(4, asn5.GetBytes()));
asn.Add(new PKCS7.ContentInfo("1.2.840.113549.1.7.1")
{
Content = asn6
}.ASN1);
}
}
if (this._safeBags.Count > 0)
{
ASN1 asn7 = new ASN1(48);
foreach (object obj8 in this._safeBags)
{
SafeBag safeBag4 = (SafeBag)obj8;
if (safeBag4.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
{
asn7.Add(safeBag4.ASN1);
}
}
if (asn7.Count > 0)
{
PKCS7.ContentInfo contentInfo3 = this.EncryptedContentInfo(asn7, "1.2.840.113549.1.12.1.3");
asn.Add(contentInfo3.ASN1);
}
}
ASN1 asn8 = new ASN1(4, asn.GetBytes());
ASN1 asn9 = new ASN1(160);
asn9.Add(asn8);
PKCS7.ContentInfo contentInfo4 = new PKCS7.ContentInfo("1.2.840.113549.1.7.1");
contentInfo4.Content = asn9;
ASN1 asn10 = new ASN1(48);
if (this._password != null)
{
byte[] array = new byte[20];
this.RNG.GetBytes(array);
byte[] array2 = this.MAC(this._password, array, this._iterations, contentInfo4.Content[0].Value);
ASN1 asn11 = new ASN1(48);
asn11.Add(ASN1Convert.FromOid("1.3.14.3.2.26"));
asn11.Add(new ASN1(5));
ASN1 asn12 = new ASN1(48);
asn12.Add(asn11);
asn12.Add(new ASN1(4, array2));
asn10.Add(asn12);
asn10.Add(new ASN1(4, array));
asn10.Add(ASN1Convert.FromInt32(this._iterations));
}
ASN1 asn13 = new ASN1(2, new byte[] { 3 });
ASN1 asn14 = new ASN1(48);
asn14.Add(asn13);
asn14.Add(contentInfo4.ASN1);
if (asn10.Count > 0)
{
asn14.Add(asn10);
}
return asn14.GetBytes();
}
// Token: 0x0600029B RID: 667 RVA: 0x00012A30 File Offset: 0x00010C30
private PKCS7.ContentInfo EncryptedContentInfo(ASN1 safeBags, string algorithmOid)
{
byte[] array = new byte[8];
this.RNG.GetBytes(array);
ASN1 asn = new ASN1(48);
asn.Add(new ASN1(4, array));
asn.Add(ASN1Convert.FromInt32(this._iterations));
ASN1 asn2 = new ASN1(48);
asn2.Add(ASN1Convert.FromOid(algorithmOid));
asn2.Add(asn);
byte[] array2 = this.Encrypt(algorithmOid, array, this._iterations, safeBags.GetBytes());
ASN1 asn3 = new ASN1(128, array2);
ASN1 asn4 = new ASN1(48);
asn4.Add(ASN1Convert.FromOid("1.2.840.113549.1.7.1"));
asn4.Add(asn2);
asn4.Add(asn3);
ASN1 asn5 = new ASN1(2, new byte[1]);
ASN1 asn6 = new ASN1(48);
asn6.Add(asn5);
asn6.Add(asn4);
ASN1 asn7 = new ASN1(160);
asn7.Add(asn6);
return new PKCS7.ContentInfo("1.2.840.113549.1.7.6")
{
Content = asn7
};
}
// Token: 0x0600029C RID: 668 RVA: 0x00012B40 File Offset: 0x00010D40
public void AddCertificate(X509Certificate cert)
{
this.AddCertificate(cert, null);
}
// Token: 0x0600029D RID: 669 RVA: 0x00012B4C File Offset: 0x00010D4C
public void AddCertificate(X509Certificate cert, IDictionary attributes)
{
bool flag = false;
int num = 0;
while (!flag && num < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
if (this.Compare(cert.RawData, x509Certificate.RawData))
{
flag = true;
}
}
num++;
}
if (!flag)
{
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.3", this.CertificateSafeBag(cert, attributes)));
this._certsChanged = true;
}
}
// Token: 0x0600029E RID: 670 RVA: 0x00012C20 File Offset: 0x00010E20
public void RemoveCertificate(X509Certificate cert)
{
this.RemoveCertificate(cert, null);
}
// Token: 0x0600029F RID: 671 RVA: 0x00012C2C File Offset: 0x00010E2C
public void RemoveCertificate(X509Certificate cert, IDictionary attrs)
{
int num = -1;
int num2 = 0;
while (num == -1 && num2 < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num2];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
if (this.Compare(cert.RawData, x509Certificate.RawData))
{
if (attrs != null)
{
if (asn.Count == 3)
{
ASN1 asn3 = asn[2];
int num3 = 0;
for (int i = 0; i < asn3.Count; i++)
{
ASN1 asn4 = asn3[i];
ASN1 asn5 = asn4[0];
string text = ASN1Convert.ToOid(asn5);
ArrayList arrayList = (ArrayList)attrs[text];
if (arrayList != null)
{
ASN1 asn6 = asn4[1];
if (arrayList.Count == asn6.Count)
{
int num4 = 0;
for (int j = 0; j < asn6.Count; j++)
{
ASN1 asn7 = asn6[j];
byte[] array = (byte[])arrayList[j];
if (this.Compare(array, asn7.Value))
{
num4++;
}
}
if (num4 == asn6.Count)
{
num3++;
}
}
}
}
if (num3 == asn3.Count)
{
num = num2;
}
}
}
else
{
num = num2;
}
}
}
num2++;
}
if (num != -1)
{
this._safeBags.RemoveAt(num);
this._certsChanged = true;
}
}
// Token: 0x060002A0 RID: 672 RVA: 0x00012DF8 File Offset: 0x00010FF8
private bool CompareAsymmetricAlgorithm(AsymmetricAlgorithm a1, AsymmetricAlgorithm a2)
{
return a1.KeySize == a2.KeySize && a1.ToXmlString(false) == a2.ToXmlString(false);
}
// Token: 0x060002A1 RID: 673 RVA: 0x00012E2C File Offset: 0x0001102C
public void AddPkcs8ShroudedKeyBag(AsymmetricAlgorithm aa)
{
this.AddPkcs8ShroudedKeyBag(aa, null);
}
// Token: 0x060002A2 RID: 674 RVA: 0x00012E38 File Offset: 0x00011038
public void AddPkcs8ShroudedKeyBag(AsymmetricAlgorithm aa, IDictionary attributes)
{
bool flag = false;
int num = 0;
while (!flag && num < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
ASN1 asn = safeBag.ASN1[1];
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn.Value);
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(array);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
AsymmetricAlgorithm asymmetricAlgorithm;
if (b != 2)
{
if (b != 48)
{
Array.Clear(array, 0, array.Length);
Array.Clear(privateKey, 0, privateKey.Length);
throw new CryptographicException("Unknown private key format");
}
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(array, 0, array.Length);
Array.Clear(privateKey, 0, privateKey.Length);
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
{
flag = true;
}
}
num++;
}
if (!flag)
{
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.2", this.Pkcs8ShroudedKeyBagSafeBag(aa, attributes)));
this._keyBagsChanged = true;
}
}
// Token: 0x060002A3 RID: 675 RVA: 0x00012F9C File Offset: 0x0001119C
public void RemovePkcs8ShroudedKeyBag(AsymmetricAlgorithm aa)
{
int num = -1;
int num2 = 0;
while (num == -1 && num2 < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num2];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
ASN1 asn = safeBag.ASN1[1];
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn.Value);
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(array);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
AsymmetricAlgorithm asymmetricAlgorithm;
if (b != 2)
{
if (b != 48)
{
Array.Clear(array, 0, array.Length);
Array.Clear(privateKey, 0, privateKey.Length);
throw new CryptographicException("Unknown private key format");
}
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(array, 0, array.Length);
Array.Clear(privateKey, 0, privateKey.Length);
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
{
num = num2;
}
}
num2++;
}
if (num != -1)
{
this._safeBags.RemoveAt(num);
this._keyBagsChanged = true;
}
}
// Token: 0x060002A4 RID: 676 RVA: 0x000130F0 File Offset: 0x000112F0
public void AddKeyBag(AsymmetricAlgorithm aa)
{
this.AddKeyBag(aa, null);
}
// Token: 0x060002A5 RID: 677 RVA: 0x000130FC File Offset: 0x000112FC
public void AddKeyBag(AsymmetricAlgorithm aa, IDictionary attributes)
{
bool flag = false;
int num = 0;
while (!flag && num < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
{
ASN1 asn = safeBag.ASN1[1];
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn.Value);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
AsymmetricAlgorithm asymmetricAlgorithm;
if (b != 2)
{
if (b != 48)
{
Array.Clear(privateKey, 0, privateKey.Length);
throw new CryptographicException("Unknown private key format");
}
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(privateKey, 0, privateKey.Length);
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
{
flag = true;
}
}
num++;
}
if (!flag)
{
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.1", this.KeyBagSafeBag(aa, attributes)));
this._keyBagsChanged = true;
}
}
// Token: 0x060002A6 RID: 678 RVA: 0x0001321C File Offset: 0x0001141C
public void RemoveKeyBag(AsymmetricAlgorithm aa)
{
int num = -1;
int num2 = 0;
while (num == -1 && num2 < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num2];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
{
ASN1 asn = safeBag.ASN1[1];
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn.Value);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
AsymmetricAlgorithm asymmetricAlgorithm;
if (b != 2)
{
if (b != 48)
{
Array.Clear(privateKey, 0, privateKey.Length);
throw new CryptographicException("Unknown private key format");
}
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(privateKey, 0, privateKey.Length);
if (this.CompareAsymmetricAlgorithm(aa, asymmetricAlgorithm))
{
num = num2;
}
}
num2++;
}
if (num != -1)
{
this._safeBags.RemoveAt(num);
this._keyBagsChanged = true;
}
}
// Token: 0x060002A7 RID: 679 RVA: 0x0001332C File Offset: 0x0001152C
public void AddSecretBag(byte[] secret)
{
this.AddSecretBag(secret, null);
}
// Token: 0x060002A8 RID: 680 RVA: 0x00013338 File Offset: 0x00011538
public void AddSecretBag(byte[] secret, IDictionary attributes)
{
bool flag = false;
int num = 0;
while (!flag && num < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
{
ASN1 asn = safeBag.ASN1[1];
byte[] value = asn.Value;
if (this.Compare(secret, value))
{
flag = true;
}
}
num++;
}
if (!flag)
{
this._safeBags.Add(new SafeBag("1.2.840.113549.1.12.10.1.5", this.SecretBagSafeBag(secret, attributes)));
this._secretBagsChanged = true;
}
}
// Token: 0x060002A9 RID: 681 RVA: 0x000133E0 File Offset: 0x000115E0
public void RemoveSecretBag(byte[] secret)
{
int num = -1;
int num2 = 0;
while (num == -1 && num2 < this._safeBags.Count)
{
SafeBag safeBag = (SafeBag)this._safeBags[num2];
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
{
ASN1 asn = safeBag.ASN1[1];
byte[] value = asn.Value;
if (this.Compare(secret, value))
{
num = num2;
}
}
num2++;
}
if (num != -1)
{
this._safeBags.RemoveAt(num);
this._secretBagsChanged = true;
}
}
// Token: 0x060002AA RID: 682 RVA: 0x00013478 File Offset: 0x00011678
public AsymmetricAlgorithm GetAsymmetricAlgorithm(IDictionary attrs)
{
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
ASN1 asn = safeBag.ASN1;
if (asn.Count == 3)
{
ASN1 asn2 = asn[2];
int num = 0;
for (int i = 0; i < asn2.Count; i++)
{
ASN1 asn3 = asn2[i];
ASN1 asn4 = asn3[0];
string text = ASN1Convert.ToOid(asn4);
ArrayList arrayList = (ArrayList)attrs[text];
if (arrayList != null)
{
ASN1 asn5 = asn3[1];
if (arrayList.Count == asn5.Count)
{
int num2 = 0;
for (int j = 0; j < asn5.Count; j++)
{
ASN1 asn6 = asn5[j];
byte[] array = (byte[])arrayList[j];
if (this.Compare(array, asn6.Value))
{
num2++;
}
}
if (num2 == asn5.Count)
{
num++;
}
}
}
}
if (num == asn2.Count)
{
ASN1 asn7 = asn[1];
AsymmetricAlgorithm asymmetricAlgorithm = null;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
{
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn7.Value);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
if (b != 2)
{
if (b == 48)
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(privateKey, 0, privateKey.Length);
}
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn7.Value);
byte[] array2 = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array2);
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
byte b = privateKey2[0];
if (b != 2)
{
if (b == 48)
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2);
}
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, default(DSAParameters));
}
Array.Clear(privateKey2, 0, privateKey2.Length);
Array.Clear(array2, 0, array2.Length);
}
return asymmetricAlgorithm;
}
}
}
}
return null;
}
// Token: 0x060002AB RID: 683 RVA: 0x00013760 File Offset: 0x00011960
public byte[] GetSecret(IDictionary attrs)
{
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.5"))
{
ASN1 asn = safeBag.ASN1;
if (asn.Count == 3)
{
ASN1 asn2 = asn[2];
int num = 0;
for (int i = 0; i < asn2.Count; i++)
{
ASN1 asn3 = asn2[i];
ASN1 asn4 = asn3[0];
string text = ASN1Convert.ToOid(asn4);
ArrayList arrayList = (ArrayList)attrs[text];
if (arrayList != null)
{
ASN1 asn5 = asn3[1];
if (arrayList.Count == asn5.Count)
{
int num2 = 0;
for (int j = 0; j < asn5.Count; j++)
{
ASN1 asn6 = asn5[j];
byte[] array = (byte[])arrayList[j];
if (this.Compare(array, asn6.Value))
{
num2++;
}
}
if (num2 == asn5.Count)
{
num++;
}
}
}
}
if (num == asn2.Count)
{
ASN1 asn7 = asn[1];
return asn7.Value;
}
}
}
}
return null;
}
// Token: 0x060002AC RID: 684 RVA: 0x000138FC File Offset: 0x00011AFC
public X509Certificate GetCertificate(IDictionary attrs)
{
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn = safeBag.ASN1;
if (asn.Count == 3)
{
ASN1 asn2 = asn[2];
int num = 0;
for (int i = 0; i < asn2.Count; i++)
{
ASN1 asn3 = asn2[i];
ASN1 asn4 = asn3[0];
string text = ASN1Convert.ToOid(asn4);
ArrayList arrayList = (ArrayList)attrs[text];
if (arrayList != null)
{
ASN1 asn5 = asn3[1];
if (arrayList.Count == asn5.Count)
{
int num2 = 0;
for (int j = 0; j < asn5.Count; j++)
{
ASN1 asn6 = asn5[j];
byte[] array = (byte[])arrayList[j];
if (this.Compare(array, asn6.Value))
{
num2++;
}
}
if (num2 == asn5.Count)
{
num++;
}
}
}
}
if (num == asn2.Count)
{
ASN1 asn7 = asn[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn7.Value);
return new X509Certificate(contentInfo.Content[0].Value);
}
}
}
}
return null;
}
// Token: 0x060002AD RID: 685 RVA: 0x00013AB4 File Offset: 0x00011CB4
public IDictionary GetAttributes(AsymmetricAlgorithm aa)
{
IDictionary dictionary = new Hashtable();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1") || safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
AsymmetricAlgorithm asymmetricAlgorithm = null;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.1"))
{
PKCS8.PrivateKeyInfo privateKeyInfo = new PKCS8.PrivateKeyInfo(asn2.Value);
byte[] privateKey = privateKeyInfo.PrivateKey;
byte b = privateKey[0];
if (b != 2)
{
if (b == 48)
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey);
}
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey, default(DSAParameters));
}
Array.Clear(privateKey, 0, privateKey.Length);
}
else if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.2"))
{
PKCS8.EncryptedPrivateKeyInfo encryptedPrivateKeyInfo = new PKCS8.EncryptedPrivateKeyInfo(asn2.Value);
byte[] array = this.Decrypt(encryptedPrivateKeyInfo.Algorithm, encryptedPrivateKeyInfo.Salt, encryptedPrivateKeyInfo.IterationCount, encryptedPrivateKeyInfo.EncryptedData);
PKCS8.PrivateKeyInfo privateKeyInfo2 = new PKCS8.PrivateKeyInfo(array);
byte[] privateKey2 = privateKeyInfo2.PrivateKey;
byte b = privateKey2[0];
if (b != 2)
{
if (b == 48)
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeRSA(privateKey2);
}
}
else
{
asymmetricAlgorithm = PKCS8.PrivateKeyInfo.DecodeDSA(privateKey2, default(DSAParameters));
}
Array.Clear(privateKey2, 0, privateKey2.Length);
Array.Clear(array, 0, array.Length);
}
if (asymmetricAlgorithm != null && this.CompareAsymmetricAlgorithm(asymmetricAlgorithm, aa) && asn.Count == 3)
{
ASN1 asn3 = asn[2];
for (int i = 0; i < asn3.Count; i++)
{
ASN1 asn4 = asn3[i];
ASN1 asn5 = asn4[0];
string text = ASN1Convert.ToOid(asn5);
ArrayList arrayList = new ArrayList();
ASN1 asn6 = asn4[1];
for (int j = 0; j < asn6.Count; j++)
{
ASN1 asn7 = asn6[j];
arrayList.Add(asn7.Value);
}
dictionary.Add(text, arrayList);
}
}
}
}
return dictionary;
}
// Token: 0x060002AE RID: 686 RVA: 0x00013D54 File Offset: 0x00011F54
public IDictionary GetAttributes(X509Certificate cert)
{
IDictionary dictionary = new Hashtable();
foreach (object obj in this._safeBags)
{
SafeBag safeBag = (SafeBag)obj;
if (safeBag.BagOID.Equals("1.2.840.113549.1.12.10.1.3"))
{
ASN1 asn = safeBag.ASN1;
ASN1 asn2 = asn[1];
PKCS7.ContentInfo contentInfo = new PKCS7.ContentInfo(asn2.Value);
X509Certificate x509Certificate = new X509Certificate(contentInfo.Content[0].Value);
if (this.Compare(cert.RawData, x509Certificate.RawData) && asn.Count == 3)
{
ASN1 asn3 = asn[2];
for (int i = 0; i < asn3.Count; i++)
{
ASN1 asn4 = asn3[i];
ASN1 asn5 = asn4[0];
string text = ASN1Convert.ToOid(asn5);
ArrayList arrayList = new ArrayList();
ASN1 asn6 = asn4[1];
for (int j = 0; j < asn6.Count; j++)
{
ASN1 asn7 = asn6[j];
arrayList.Add(asn7.Value);
}
dictionary.Add(text, arrayList);
}
}
}
}
return dictionary;
}
// Token: 0x060002AF RID: 687 RVA: 0x00013ECC File Offset: 0x000120CC
public void SaveToFile(string filename)
{
if (filename == null)
{
throw new ArgumentNullException("filename");
}
using (FileStream fileStream = File.Create(filename))
{
byte[] bytes = this.GetBytes();
fileStream.Write(bytes, 0, bytes.Length);
}
}
// Token: 0x060002B0 RID: 688 RVA: 0x00013F34 File Offset: 0x00012134
public object Clone()
{
PKCS12 pkcs;
if (this._password != null)
{
pkcs = new PKCS12(this.GetBytes(), Encoding.BigEndianUnicode.GetString(this._password));
}
else
{
pkcs = new PKCS12(this.GetBytes());
}
pkcs.IterationCount = this.IterationCount;
return pkcs;
}
// Token: 0x17000083 RID: 131
// (get) Token: 0x060002B1 RID: 689 RVA: 0x00013F88 File Offset: 0x00012188
// (set) Token: 0x060002B2 RID: 690 RVA: 0x00013F90 File Offset: 0x00012190
public static int MaximumPasswordLength
{
get
{
return PKCS12.password_max_length;
}
set
{
if (value < 32)
{
string text = Locale.GetText("Maximum password length cannot be less than {0}.", new object[] { 32 });
throw new ArgumentOutOfRangeException(text);
}
PKCS12.password_max_length = value;
}
}
// Token: 0x060002B3 RID: 691 RVA: 0x00013FD0 File Offset: 0x000121D0
private static byte[] LoadFile(string filename)
{
byte[] array = null;
using (FileStream fileStream = File.OpenRead(filename))
{
array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
fileStream.Close();
}
return array;
}
// Token: 0x060002B4 RID: 692 RVA: 0x00014034 File Offset: 0x00012234
public static PKCS12 LoadFromFile(string filename)
{
if (filename == null)
{
throw new ArgumentNullException("filename");
}
return new PKCS12(PKCS12.LoadFile(filename));
}
// Token: 0x060002B5 RID: 693 RVA: 0x00014054 File Offset: 0x00012254
public static PKCS12 LoadFromFile(string filename, string password)
{
if (filename == null)
{
throw new ArgumentNullException("filename");
}
return new PKCS12(PKCS12.LoadFile(filename), password);
}
// Token: 0x0400011C RID: 284
public const string pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1";
// Token: 0x0400011D RID: 285
public const string pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2";
// Token: 0x0400011E RID: 286
public const string pbeWithSHAAnd3KeyTripleDESCBC = "1.2.840.113549.1.12.1.3";
// Token: 0x0400011F RID: 287
public const string pbeWithSHAAnd2KeyTripleDESCBC = "1.2.840.113549.1.12.1.4";
// Token: 0x04000120 RID: 288
public const string pbeWithSHAAnd128BitRC2CBC = "1.2.840.113549.1.12.1.5";
// Token: 0x04000121 RID: 289
public const string pbeWithSHAAnd40BitRC2CBC = "1.2.840.113549.1.12.1.6";
// Token: 0x04000122 RID: 290
public const string keyBag = "1.2.840.113549.1.12.10.1.1";
// Token: 0x04000123 RID: 291
public const string pkcs8ShroudedKeyBag = "1.2.840.113549.1.12.10.1.2";
// Token: 0x04000124 RID: 292
public const string certBag = "1.2.840.113549.1.12.10.1.3";
// Token: 0x04000125 RID: 293
public const string crlBag = "1.2.840.113549.1.12.10.1.4";
// Token: 0x04000126 RID: 294
public const string secretBag = "1.2.840.113549.1.12.10.1.5";
// Token: 0x04000127 RID: 295
public const string safeContentsBag = "1.2.840.113549.1.12.10.1.6";
// Token: 0x04000128 RID: 296
public const string x509Certificate = "1.2.840.113549.1.9.22.1";
// Token: 0x04000129 RID: 297
public const string sdsiCertificate = "1.2.840.113549.1.9.22.2";
// Token: 0x0400012A RID: 298
public const string x509Crl = "1.2.840.113549.1.9.23.1";
// Token: 0x0400012B RID: 299
public const int CryptoApiPasswordLimit = 32;
// Token: 0x0400012C RID: 300
private static int recommendedIterationCount = 2000;
// Token: 0x0400012D RID: 301
private byte[] _password;
// Token: 0x0400012E RID: 302
private ArrayList _keyBags;
// Token: 0x0400012F RID: 303
private ArrayList _secretBags;
// Token: 0x04000130 RID: 304
private X509CertificateCollection _certs;
// Token: 0x04000131 RID: 305
private bool _keyBagsChanged;
// Token: 0x04000132 RID: 306
private bool _secretBagsChanged;
// Token: 0x04000133 RID: 307
private bool _certsChanged;
// Token: 0x04000134 RID: 308
private int _iterations;
// Token: 0x04000135 RID: 309
private ArrayList _safeBags;
// Token: 0x04000136 RID: 310
private RandomNumberGenerator _rng;
// Token: 0x04000137 RID: 311
private static int password_max_length = int.MaxValue;
// Token: 0x0200003F RID: 63
public class DeriveBytes
{
// Token: 0x17000084 RID: 132
// (get) Token: 0x060002B8 RID: 696 RVA: 0x000140D0 File Offset: 0x000122D0
// (set) Token: 0x060002B9 RID: 697 RVA: 0x000140D8 File Offset: 0x000122D8
public string HashName
{
get
{
return this._hashName;
}
set
{
this._hashName = value;
}
}
// Token: 0x17000085 RID: 133
// (get) Token: 0x060002BA RID: 698 RVA: 0x000140E4 File Offset: 0x000122E4
// (set) Token: 0x060002BB RID: 699 RVA: 0x000140EC File Offset: 0x000122EC
public int IterationCount
{
get
{
return this._iterations;
}
set
{
this._iterations = value;
}
}
// Token: 0x17000086 RID: 134
// (get) Token: 0x060002BC RID: 700 RVA: 0x000140F8 File Offset: 0x000122F8
// (set) Token: 0x060002BD RID: 701 RVA: 0x0001410C File Offset: 0x0001230C
public byte[] Password
{
get
{
return (byte[])this._password.Clone();
}
set
{
if (value == null)
{
this._password = new byte[0];
}
else
{
this._password = (byte[])value.Clone();
}
}
}
// Token: 0x17000087 RID: 135
// (get) Token: 0x060002BE RID: 702 RVA: 0x00014144 File Offset: 0x00012344
// (set) Token: 0x060002BF RID: 703 RVA: 0x00014158 File Offset: 0x00012358
public byte[] Salt
{
get
{
return (byte[])this._salt.Clone();
}
set
{
if (value != null)
{
this._salt = (byte[])value.Clone();
}
else
{
this._salt = null;
}
}
}
// Token: 0x060002C0 RID: 704 RVA: 0x00014180 File Offset: 0x00012380
private void Adjust(byte[] a, int aOff, byte[] b)
{
int num = (int)((b[b.Length - 1] & byte.MaxValue) + (a[aOff + b.Length - 1] & byte.MaxValue) + 1);
a[aOff + b.Length - 1] = (byte)num;
num >>= 8;
for (int i = b.Length - 2; i >= 0; i--)
{
num += (int)((b[i] & byte.MaxValue) + (a[aOff + i] & byte.MaxValue));
a[aOff + i] = (byte)num;
num >>= 8;
}
}
// Token: 0x060002C1 RID: 705 RVA: 0x000141F8 File Offset: 0x000123F8
private byte[] Derive(byte[] diversifier, int n)
{
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this._hashName);
int num = hashAlgorithm.HashSize >> 3;
int num2 = 64;
byte[] array = new byte[n];
byte[] array2;
if (this._salt != null && this._salt.Length != 0)
{
array2 = new byte[num2 * ((this._salt.Length + num2 - 1) / num2)];
for (int num3 = 0; num3 != array2.Length; num3++)
{
array2[num3] = this._salt[num3 % this._salt.Length];
}
}
else
{
array2 = new byte[0];
}
byte[] array3;
if (this._password != null && this._password.Length != 0)
{
array3 = new byte[num2 * ((this._password.Length + num2 - 1) / num2)];
for (int num4 = 0; num4 != array3.Length; num4++)
{
array3[num4] = this._password[num4 % this._password.Length];
}
}
else
{
array3 = new byte[0];
}
byte[] array4 = new byte[array2.Length + array3.Length];
Buffer.BlockCopy(array2, 0, array4, 0, array2.Length);
Buffer.BlockCopy(array3, 0, array4, array2.Length, array3.Length);
byte[] array5 = new byte[num2];
int num5 = (n + num - 1) / num;
for (int i = 1; i <= num5; i++)
{
hashAlgorithm.TransformBlock(diversifier, 0, diversifier.Length, diversifier, 0);
hashAlgorithm.TransformFinalBlock(array4, 0, array4.Length);
byte[] array6 = hashAlgorithm.Hash;
hashAlgorithm.Initialize();
for (int num6 = 1; num6 != this._iterations; num6++)
{
array6 = hashAlgorithm.ComputeHash(array6, 0, array6.Length);
}
for (int num7 = 0; num7 != array5.Length; num7++)
{
array5[num7] = array6[num7 % array6.Length];
}
for (int num8 = 0; num8 != array4.Length / num2; num8++)
{
this.Adjust(array4, num8 * num2, array5);
}
if (i == num5)
{
Buffer.BlockCopy(array6, 0, array, (i - 1) * num, array.Length - (i - 1) * num);
}
else
{
Buffer.BlockCopy(array6, 0, array, (i - 1) * num, array6.Length);
}
}
return array;
}
// Token: 0x060002C2 RID: 706 RVA: 0x00014438 File Offset: 0x00012638
public byte[] DeriveKey(int size)
{
return this.Derive(PKCS12.DeriveBytes.keyDiversifier, size);
}
// Token: 0x060002C3 RID: 707 RVA: 0x00014448 File Offset: 0x00012648
public byte[] DeriveIV(int size)
{
return this.Derive(PKCS12.DeriveBytes.ivDiversifier, size);
}
// Token: 0x060002C4 RID: 708 RVA: 0x00014458 File Offset: 0x00012658
public byte[] DeriveMAC(int size)
{
return this.Derive(PKCS12.DeriveBytes.macDiversifier, size);
}
// Token: 0x04000140 RID: 320
private static byte[] keyDiversifier = new byte[]
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1
};
// Token: 0x04000141 RID: 321
private static byte[] ivDiversifier = new byte[]
{
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2
};
// Token: 0x04000142 RID: 322
private static byte[] macDiversifier = new byte[]
{
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3
};
// Token: 0x04000143 RID: 323
private string _hashName;
// Token: 0x04000144 RID: 324
private int _iterations;
// Token: 0x04000145 RID: 325
private byte[] _password;
// Token: 0x04000146 RID: 326
private byte[] _salt;
// Token: 0x02000040 RID: 64
public enum Purpose
{
// Token: 0x04000148 RID: 328
Key,
// Token: 0x04000149 RID: 329
IV,
// Token: 0x0400014A RID: 330
MAC
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
namespace Mono.Security.X509
{
// Token: 0x0200003B RID: 59
public class PKCS5
{
// Token: 0x04000112 RID: 274
public const string pbeWithMD2AndDESCBC = "1.2.840.113549.1.5.1";
// Token: 0x04000113 RID: 275
public const string pbeWithMD5AndDESCBC = "1.2.840.113549.1.5.3";
// Token: 0x04000114 RID: 276
public const string pbeWithMD2AndRC2CBC = "1.2.840.113549.1.5.4";
// Token: 0x04000115 RID: 277
public const string pbeWithMD5AndRC2CBC = "1.2.840.113549.1.5.6";
// Token: 0x04000116 RID: 278
public const string pbeWithSHA1AndDESCBC = "1.2.840.113549.1.5.10";
// Token: 0x04000117 RID: 279
public const string pbeWithSHA1AndRC2CBC = "1.2.840.113549.1.5.11";
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
namespace Mono.Security.X509
{
// Token: 0x0200003C RID: 60
public class PKCS9
{
// Token: 0x04000118 RID: 280
public const string friendlyName = "1.2.840.113549.1.9.20";
// Token: 0x04000119 RID: 281
public const string localKeyId = "1.2.840.113549.1.9.21";
}
}
+41
View File
@@ -0,0 +1,41 @@
using System;
namespace Mono.Security.X509
{
// Token: 0x0200003D RID: 61
internal class SafeBag
{
// Token: 0x0600027C RID: 636 RVA: 0x00010538 File Offset: 0x0000E738
public SafeBag(string bagOID, ASN1 asn1)
{
this._bagOID = bagOID;
this._asn1 = asn1;
}
// Token: 0x1700007B RID: 123
// (get) Token: 0x0600027D RID: 637 RVA: 0x00010550 File Offset: 0x0000E750
public string BagOID
{
get
{
return this._bagOID;
}
}
// Token: 0x1700007C RID: 124
// (get) Token: 0x0600027E RID: 638 RVA: 0x00010558 File Offset: 0x0000E758
public ASN1 ASN1
{
get
{
return this._asn1;
}
}
// Token: 0x0400011A RID: 282
private string _bagOID;
// Token: 0x0400011B RID: 283
private ASN1 _asn1;
}
}
+457
View File
@@ -0,0 +1,457 @@
using System;
using System.Globalization;
using System.Text;
using Mono.Security.Cryptography;
namespace Mono.Security.X509
{
// Token: 0x02000041 RID: 65
public sealed class X501
{
// Token: 0x060002C5 RID: 709 RVA: 0x00014468 File Offset: 0x00012668
private X501()
{
}
// Token: 0x060002C7 RID: 711 RVA: 0x000145EC File Offset: 0x000127EC
public static string ToString(ASN1 seq)
{
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < seq.Count; i++)
{
ASN1 asn = seq[i];
X501.AppendEntry(stringBuilder, asn, true);
if (i < seq.Count - 1)
{
stringBuilder.Append(", ");
}
}
return stringBuilder.ToString();
}
// Token: 0x060002C8 RID: 712 RVA: 0x00014648 File Offset: 0x00012848
public static string ToString(ASN1 seq, bool reversed, string separator, bool quotes)
{
StringBuilder stringBuilder = new StringBuilder();
if (reversed)
{
for (int i = seq.Count - 1; i >= 0; i--)
{
ASN1 asn = seq[i];
X501.AppendEntry(stringBuilder, asn, quotes);
if (i > 0)
{
stringBuilder.Append(separator);
}
}
}
else
{
for (int j = 0; j < seq.Count; j++)
{
ASN1 asn2 = seq[j];
X501.AppendEntry(stringBuilder, asn2, quotes);
if (j < seq.Count - 1)
{
stringBuilder.Append(separator);
}
}
}
return stringBuilder.ToString();
}
// Token: 0x060002C9 RID: 713 RVA: 0x000146E4 File Offset: 0x000128E4
private static void AppendEntry(StringBuilder sb, ASN1 entry, bool quotes)
{
for (int i = 0; i < entry.Count; i++)
{
ASN1 asn = entry[i];
ASN1 asn2 = asn[1];
if (asn2 != null)
{
ASN1 asn3 = asn[0];
if (asn3 != null)
{
if (asn3.CompareValue(X501.countryName))
{
sb.Append("C=");
}
else if (asn3.CompareValue(X501.organizationName))
{
sb.Append("O=");
}
else if (asn3.CompareValue(X501.organizationalUnitName))
{
sb.Append("OU=");
}
else if (asn3.CompareValue(X501.commonName))
{
sb.Append("CN=");
}
else if (asn3.CompareValue(X501.localityName))
{
sb.Append("L=");
}
else if (asn3.CompareValue(X501.stateOrProvinceName))
{
sb.Append("S=");
}
else if (asn3.CompareValue(X501.streetAddress))
{
sb.Append("STREET=");
}
else if (asn3.CompareValue(X501.domainComponent))
{
sb.Append("DC=");
}
else if (asn3.CompareValue(X501.userid))
{
sb.Append("UID=");
}
else if (asn3.CompareValue(X501.email))
{
sb.Append("E=");
}
else if (asn3.CompareValue(X501.dnQualifier))
{
sb.Append("dnQualifier=");
}
else if (asn3.CompareValue(X501.title))
{
sb.Append("T=");
}
else if (asn3.CompareValue(X501.surname))
{
sb.Append("SN=");
}
else if (asn3.CompareValue(X501.givenName))
{
sb.Append("G=");
}
else if (asn3.CompareValue(X501.initial))
{
sb.Append("I=");
}
else
{
sb.Append("OID.");
sb.Append(ASN1Convert.ToOid(asn3));
sb.Append("=");
}
string text;
if (asn2.Tag == 30)
{
StringBuilder stringBuilder = new StringBuilder();
for (int j = 1; j < asn2.Value.Length; j += 2)
{
stringBuilder.Append((char)asn2.Value[j]);
}
text = stringBuilder.ToString();
}
else
{
if (asn2.Tag == 20)
{
text = Encoding.UTF7.GetString(asn2.Value);
}
else
{
text = Encoding.UTF8.GetString(asn2.Value);
}
char[] array = new char[] { ',', '+', '"', '\\', '<', '>', ';' };
if (quotes && (text.IndexOfAny(array, 0, text.Length) > 0 || text.StartsWith(" ") || text.EndsWith(" ")))
{
text = "\"" + text + "\"";
}
}
sb.Append(text);
if (i < entry.Count - 1)
{
sb.Append(", ");
}
}
}
}
}
// Token: 0x060002CA RID: 714 RVA: 0x00014A5C File Offset: 0x00012C5C
private static X520.AttributeTypeAndValue GetAttributeFromOid(string attributeType)
{
string text = attributeType.ToUpper(CultureInfo.InvariantCulture).Trim();
string text2 = text;
switch (text2)
{
case "C":
return new X520.CountryName();
case "O":
return new X520.OrganizationName();
case "OU":
return new X520.OrganizationalUnitName();
case "CN":
return new X520.CommonName();
case "L":
return new X520.LocalityName();
case "S":
case "ST":
return new X520.StateOrProvinceName();
case "E":
return new X520.EmailAddress();
case "DC":
return new X520.DomainComponent();
case "UID":
return new X520.UserId();
case "DNQUALIFIER":
return new X520.DnQualifier();
case "T":
return new X520.Title();
case "SN":
return new X520.Surname();
case "G":
return new X520.GivenName();
case "I":
return new X520.Initial();
}
if (text.StartsWith("OID."))
{
return new X520.Oid(text.Substring(4));
}
if (X501.IsOid(text))
{
return new X520.Oid(text);
}
return null;
}
// Token: 0x060002CB RID: 715 RVA: 0x00014C2C File Offset: 0x00012E2C
private static bool IsOid(string oid)
{
bool flag;
try
{
ASN1 asn = ASN1Convert.FromOid(oid);
flag = asn.Tag == 6;
}
catch
{
flag = false;
}
return flag;
}
// Token: 0x060002CC RID: 716 RVA: 0x00014C80 File Offset: 0x00012E80
private static X520.AttributeTypeAndValue ReadAttribute(string value, ref int pos)
{
while (value[pos] == ' ' && pos < value.Length)
{
pos++;
}
int num = value.IndexOf('=', pos);
if (num == -1)
{
string text = Locale.GetText("No attribute found.");
throw new FormatException(text);
}
string text2 = value.Substring(pos, num - pos);
X520.AttributeTypeAndValue attributeFromOid = X501.GetAttributeFromOid(text2);
if (attributeFromOid == null)
{
string text3 = Locale.GetText("Unknown attribute '{0}'.");
throw new FormatException(string.Format(text3, text2));
}
pos = num + 1;
return attributeFromOid;
}
// Token: 0x060002CD RID: 717 RVA: 0x00014D14 File Offset: 0x00012F14
private static bool IsHex(char c)
{
if (char.IsDigit(c))
{
return true;
}
char c2 = char.ToUpper(c, CultureInfo.InvariantCulture);
return c2 >= 'A' && c2 <= 'F';
}
// Token: 0x060002CE RID: 718 RVA: 0x00014D50 File Offset: 0x00012F50
private static string ReadHex(string value, ref int pos)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append(value[pos++]);
stringBuilder.Append(value[pos]);
if (pos < value.Length - 4 && value[pos + 1] == '\\' && X501.IsHex(value[pos + 2]))
{
pos += 2;
stringBuilder.Append(value[pos++]);
stringBuilder.Append(value[pos]);
}
byte[] array = CryptoConvert.FromHex(stringBuilder.ToString());
return Encoding.UTF8.GetString(array);
}
// Token: 0x060002CF RID: 719 RVA: 0x00014E00 File Offset: 0x00013000
private static int ReadEscaped(StringBuilder sb, string value, int pos)
{
char c = value[pos];
switch (c)
{
case ';':
case '<':
case '=':
case '>':
break;
default:
if (c != '"' && c != '#' && c != '+' && c != ',' && c != '\\')
{
if (pos >= value.Length - 2)
{
string text = Locale.GetText("Malformed escaped value '{0}'.");
throw new FormatException(string.Format(text, value.Substring(pos)));
}
sb.Append(X501.ReadHex(value, ref pos));
return pos;
}
break;
}
sb.Append(value[pos]);
return pos;
}
// Token: 0x060002D0 RID: 720 RVA: 0x00014EA8 File Offset: 0x000130A8
private static int ReadQuoted(StringBuilder sb, string value, int pos)
{
int num = pos;
while (pos <= value.Length)
{
char c = value[pos];
if (c == '"')
{
return pos;
}
if (c == '\\')
{
return X501.ReadEscaped(sb, value, pos);
}
sb.Append(value[pos]);
pos++;
}
string text = Locale.GetText("Malformed quoted value '{0}'.");
throw new FormatException(string.Format(text, value.Substring(num)));
}
// Token: 0x060002D1 RID: 721 RVA: 0x00014F28 File Offset: 0x00013128
private static string ReadValue(string value, ref int pos)
{
int num = pos;
StringBuilder stringBuilder = new StringBuilder();
while (pos < value.Length)
{
char c = value[pos];
switch (c)
{
case ';':
case '<':
case '=':
case '>':
{
string text = Locale.GetText("Malformed value '{0}' contains '{1}' outside quotes.");
throw new FormatException(string.Format(text, value.Substring(num), value[pos]));
}
default:
if (c != '"')
{
if (c == '#' || c == '+')
{
throw new NotImplementedException();
}
if (c == ',')
{
pos++;
return stringBuilder.ToString();
}
if (c != '\\')
{
stringBuilder.Append(value[pos]);
}
else
{
pos = X501.ReadEscaped(stringBuilder, value, ++pos);
}
}
else
{
pos = X501.ReadQuoted(stringBuilder, value, ++pos);
}
pos++;
break;
}
}
return stringBuilder.ToString();
}
// Token: 0x060002D2 RID: 722 RVA: 0x00015030 File Offset: 0x00013230
public static ASN1 FromString(string rdn)
{
if (rdn == null)
{
throw new ArgumentNullException("rdn");
}
int i = 0;
ASN1 asn = new ASN1(48);
while (i < rdn.Length)
{
X520.AttributeTypeAndValue attributeTypeAndValue = X501.ReadAttribute(rdn, ref i);
attributeTypeAndValue.Value = X501.ReadValue(rdn, ref i);
ASN1 asn2 = new ASN1(49);
asn2.Add(attributeTypeAndValue.GetASN1());
asn.Add(asn2);
}
return asn;
}
// Token: 0x0400014B RID: 331
private static byte[] countryName = new byte[] { 85, 4, 6 };
// Token: 0x0400014C RID: 332
private static byte[] organizationName = new byte[] { 85, 4, 10 };
// Token: 0x0400014D RID: 333
private static byte[] organizationalUnitName = new byte[] { 85, 4, 11 };
// Token: 0x0400014E RID: 334
private static byte[] commonName = new byte[] { 85, 4, 3 };
// Token: 0x0400014F RID: 335
private static byte[] localityName = new byte[] { 85, 4, 7 };
// Token: 0x04000150 RID: 336
private static byte[] stateOrProvinceName = new byte[] { 85, 4, 8 };
// Token: 0x04000151 RID: 337
private static byte[] streetAddress = new byte[] { 85, 4, 9 };
// Token: 0x04000152 RID: 338
private static byte[] domainComponent = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 25 };
// Token: 0x04000153 RID: 339
private static byte[] userid = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 1 };
// Token: 0x04000154 RID: 340
private static byte[] email = new byte[] { 42, 134, 72, 134, 247, 13, 1, 9, 1 };
// Token: 0x04000155 RID: 341
private static byte[] dnQualifier = new byte[] { 85, 4, 46 };
// Token: 0x04000156 RID: 342
private static byte[] title = new byte[] { 85, 4, 12 };
// Token: 0x04000157 RID: 343
private static byte[] surname = new byte[] { 85, 4, 4 };
// Token: 0x04000158 RID: 344
private static byte[] givenName = new byte[] { 85, 4, 42 };
// Token: 0x04000159 RID: 345
private static byte[] initial = new byte[] { 85, 4, 43 };
}
}
+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Globalization;
using System.Security.Cryptography;
namespace Mono.Security.X509
{
// Token: 0x02000042 RID: 66
public abstract class X509Builder
{
// Token: 0x060002D3 RID: 723 RVA: 0x000150A0 File Offset: 0x000132A0
protected X509Builder()
{
this.hashName = "SHA1";
}
// Token: 0x060002D4 RID: 724
protected abstract ASN1 ToBeSigned(string hashName);
// Token: 0x060002D5 RID: 725 RVA: 0x000150B4 File Offset: 0x000132B4
protected string GetOid(string hashName)
{
string text = hashName.ToLower(CultureInfo.InvariantCulture);
switch (text)
{
case "md2":
return "1.2.840.113549.1.1.2";
case "md4":
return "1.2.840.113549.1.1.3";
case "md5":
return "1.2.840.113549.1.1.4";
case "sha1":
return "1.2.840.113549.1.1.5";
case "sha256":
return "1.2.840.113549.1.1.11";
case "sha384":
return "1.2.840.113549.1.1.12";
case "sha512":
return "1.2.840.113549.1.1.13";
}
throw new NotSupportedException("Unknown hash algorithm " + hashName);
}
// Token: 0x17000088 RID: 136
// (get) Token: 0x060002D6 RID: 726 RVA: 0x000151B4 File Offset: 0x000133B4
// (set) Token: 0x060002D7 RID: 727 RVA: 0x000151BC File Offset: 0x000133BC
public string Hash
{
get
{
return this.hashName;
}
set
{
if (this.hashName == null)
{
this.hashName = "SHA1";
}
else
{
this.hashName = value;
}
}
}
// Token: 0x060002D8 RID: 728 RVA: 0x000151EC File Offset: 0x000133EC
public virtual byte[] Sign(AsymmetricAlgorithm aa)
{
if (aa is RSA)
{
return this.Sign(aa as RSA);
}
if (aa is DSA)
{
return this.Sign(aa as DSA);
}
throw new NotSupportedException("Unknown Asymmetric Algorithm " + aa.ToString());
}
// Token: 0x060002D9 RID: 729 RVA: 0x00015240 File Offset: 0x00013440
private byte[] Build(ASN1 tbs, string hashoid, byte[] signature)
{
ASN1 asn = new ASN1(48);
asn.Add(tbs);
asn.Add(PKCS7.AlgorithmIdentifier(hashoid));
byte[] array = new byte[signature.Length + 1];
Buffer.BlockCopy(signature, 0, array, 1, signature.Length);
asn.Add(new ASN1(3, array));
return asn.GetBytes();
}
// Token: 0x060002DA RID: 730 RVA: 0x00015298 File Offset: 0x00013498
public virtual byte[] Sign(RSA key)
{
string oid = this.GetOid(this.hashName);
ASN1 asn = this.ToBeSigned(oid);
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.hashName);
byte[] array = hashAlgorithm.ComputeHash(asn.GetBytes());
RSAPKCS1SignatureFormatter rsapkcs1SignatureFormatter = new RSAPKCS1SignatureFormatter(key);
rsapkcs1SignatureFormatter.SetHashAlgorithm(this.hashName);
byte[] array2 = rsapkcs1SignatureFormatter.CreateSignature(array);
return this.Build(asn, oid, array2);
}
// Token: 0x060002DB RID: 731 RVA: 0x000152FC File Offset: 0x000134FC
public virtual byte[] Sign(DSA key)
{
string text = "1.2.840.10040.4.3";
ASN1 asn = this.ToBeSigned(text);
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.hashName);
if (!(hashAlgorithm is SHA1))
{
throw new NotSupportedException("Only SHA-1 is supported for DSA");
}
byte[] array = hashAlgorithm.ComputeHash(asn.GetBytes());
DSASignatureFormatter dsasignatureFormatter = new DSASignatureFormatter(key);
dsasignatureFormatter.SetHashAlgorithm(this.hashName);
byte[] array2 = dsasignatureFormatter.CreateSignature(array);
byte[] array3 = new byte[20];
Buffer.BlockCopy(array2, 0, array3, 0, 20);
byte[] array4 = new byte[20];
Buffer.BlockCopy(array2, 20, array4, 0, 20);
ASN1 asn2 = new ASN1(48);
asn2.Add(new ASN1(2, array3));
asn2.Add(new ASN1(2, array4));
return this.Build(asn, text, asn2.GetBytes());
}
// Token: 0x0400015B RID: 347
private const string defaultHash = "SHA1";
// Token: 0x0400015C RID: 348
private string hashName;
}
}
@@ -0,0 +1,765 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Security.Cryptography;
using System.Text;
using Mono.Security.Cryptography;
namespace Mono.Security.X509
{
// Token: 0x02000043 RID: 67
public class X509Certificate : ISerializable
{
// Token: 0x060002DC RID: 732 RVA: 0x000153CC File Offset: 0x000135CC
public X509Certificate(byte[] data)
{
if (data != null)
{
if (data.Length > 0 && data[0] != 48)
{
try
{
data = X509Certificate.PEM("CERTIFICATE", data);
}
catch (Exception ex)
{
throw new CryptographicException(X509Certificate.encoding_error, ex);
}
}
this.Parse(data);
}
}
// Token: 0x060002DD RID: 733 RVA: 0x00015440 File Offset: 0x00013640
protected X509Certificate(SerializationInfo info, StreamingContext context)
{
this.Parse((byte[])info.GetValue("raw", typeof(byte[])));
}
// Token: 0x060002DF RID: 735 RVA: 0x00015488 File Offset: 0x00013688
private void Parse(byte[] data)
{
try
{
this.decoder = new ASN1(data);
if (this.decoder.Tag != 48)
{
throw new CryptographicException(X509Certificate.encoding_error);
}
if (this.decoder[0].Tag != 48)
{
throw new CryptographicException(X509Certificate.encoding_error);
}
ASN1 asn = this.decoder[0];
int num = 0;
ASN1 asn2 = this.decoder[0][num];
this.version = 1;
if (asn2.Tag == 160 && asn2.Count > 0)
{
this.version += (int)asn2[0].Value[0];
num++;
}
ASN1 asn3 = this.decoder[0][num++];
if (asn3.Tag != 2)
{
throw new CryptographicException(X509Certificate.encoding_error);
}
this.serialnumber = asn3.Value;
Array.Reverse(this.serialnumber, 0, this.serialnumber.Length);
num++;
this.issuer = asn.Element(num++, 48);
this.m_issuername = X501.ToString(this.issuer);
ASN1 asn4 = asn.Element(num++, 48);
ASN1 asn5 = asn4[0];
this.m_from = ASN1Convert.ToDateTime(asn5);
ASN1 asn6 = asn4[1];
this.m_until = ASN1Convert.ToDateTime(asn6);
this.subject = asn.Element(num++, 48);
this.m_subject = X501.ToString(this.subject);
ASN1 asn7 = asn.Element(num++, 48);
ASN1 asn8 = asn7.Element(0, 48);
ASN1 asn9 = asn8.Element(0, 6);
this.m_keyalgo = ASN1Convert.ToOid(asn9);
ASN1 asn10 = asn8[1];
this.m_keyalgoparams = ((asn8.Count <= 1) ? null : asn10.GetBytes());
ASN1 asn11 = asn7.Element(1, 3);
int num2 = asn11.Length - 1;
this.m_publickey = new byte[num2];
Buffer.BlockCopy(asn11.Value, 1, this.m_publickey, 0, num2);
byte[] value = this.decoder[2].Value;
this.signature = new byte[value.Length - 1];
Buffer.BlockCopy(value, 1, this.signature, 0, this.signature.Length);
asn8 = this.decoder[1];
asn9 = asn8.Element(0, 6);
this.m_signaturealgo = ASN1Convert.ToOid(asn9);
asn10 = asn8[1];
if (asn10 != null)
{
this.m_signaturealgoparams = asn10.GetBytes();
}
else
{
this.m_signaturealgoparams = null;
}
ASN1 asn12 = asn.Element(num, 129);
if (asn12 != null)
{
num++;
this.issuerUniqueID = asn12.Value;
}
ASN1 asn13 = asn.Element(num, 130);
if (asn13 != null)
{
num++;
this.subjectUniqueID = asn13.Value;
}
ASN1 asn14 = asn.Element(num, 163);
if (asn14 != null && asn14.Count == 1)
{
this.extensions = new X509ExtensionCollection(asn14[0]);
}
else
{
this.extensions = new X509ExtensionCollection(null);
}
this.m_encodedcert = (byte[])data.Clone();
}
catch (Exception ex)
{
throw new CryptographicException(X509Certificate.encoding_error, ex);
}
}
// Token: 0x060002E0 RID: 736 RVA: 0x00015818 File Offset: 0x00013A18
private byte[] GetUnsignedBigInteger(byte[] integer)
{
if (integer[0] == 0)
{
int num = integer.Length - 1;
byte[] array = new byte[num];
Buffer.BlockCopy(integer, 1, array, 0, num);
return array;
}
return integer;
}
// Token: 0x17000089 RID: 137
// (get) Token: 0x060002E1 RID: 737 RVA: 0x00015848 File Offset: 0x00013A48
// (set) Token: 0x060002E2 RID: 738 RVA: 0x0001598C File Offset: 0x00013B8C
public DSA DSA
{
get
{
if (this.m_keyalgoparams == null)
{
throw new CryptographicException("Missing key algorithm parameters.");
}
if (this._dsa == null)
{
DSAParameters dsaparameters = default(DSAParameters);
ASN1 asn = new ASN1(this.m_publickey);
if (asn == null || asn.Tag != 2)
{
return null;
}
dsaparameters.Y = this.GetUnsignedBigInteger(asn.Value);
ASN1 asn2 = new ASN1(this.m_keyalgoparams);
if (asn2 == null || asn2.Tag != 48 || asn2.Count < 3)
{
return null;
}
if (asn2[0].Tag != 2 || asn2[1].Tag != 2 || asn2[2].Tag != 2)
{
return null;
}
dsaparameters.P = this.GetUnsignedBigInteger(asn2[0].Value);
dsaparameters.Q = this.GetUnsignedBigInteger(asn2[1].Value);
dsaparameters.G = this.GetUnsignedBigInteger(asn2[2].Value);
this._dsa = new DSACryptoServiceProvider(dsaparameters.Y.Length << 3);
this._dsa.ImportParameters(dsaparameters);
}
return this._dsa;
}
set
{
this._dsa = value;
if (value != null)
{
this._rsa = null;
}
}
}
// Token: 0x1700008A RID: 138
// (get) Token: 0x060002E3 RID: 739 RVA: 0x000159A4 File Offset: 0x00013BA4
public X509ExtensionCollection Extensions
{
get
{
return this.extensions;
}
}
// Token: 0x1700008B RID: 139
// (get) Token: 0x060002E4 RID: 740 RVA: 0x000159AC File Offset: 0x00013BAC
public byte[] Hash
{
get
{
if (this.certhash == null)
{
string signaturealgo = this.m_signaturealgo;
if (signaturealgo != null)
{
if (X509Certificate.<>f__switch$mapF == null)
{
X509Certificate.<>f__switch$mapF = new Dictionary<string, int>(9)
{
{ "1.2.840.113549.1.1.2", 0 },
{ "1.2.840.113549.1.1.3", 1 },
{ "1.2.840.113549.1.1.4", 2 },
{ "1.2.840.113549.1.1.5", 3 },
{ "1.3.14.3.2.29", 3 },
{ "1.2.840.10040.4.3", 3 },
{ "1.2.840.113549.1.1.11", 4 },
{ "1.2.840.113549.1.1.12", 5 },
{ "1.2.840.113549.1.1.13", 6 }
};
}
int num;
if (X509Certificate.<>f__switch$mapF.TryGetValue(signaturealgo, out num))
{
HashAlgorithm hashAlgorithm;
switch (num)
{
case 0:
hashAlgorithm = MD2.Create();
break;
case 1:
hashAlgorithm = MD4.Create();
break;
case 2:
hashAlgorithm = MD5.Create();
break;
case 3:
hashAlgorithm = SHA1.Create();
break;
case 4:
hashAlgorithm = SHA256.Create();
break;
case 5:
hashAlgorithm = SHA384.Create();
break;
case 6:
hashAlgorithm = SHA512.Create();
break;
default:
goto IL_125;
}
if (this.decoder == null || this.decoder.Count < 1)
{
return null;
}
byte[] bytes = this.decoder[0].GetBytes();
this.certhash = hashAlgorithm.ComputeHash(bytes, 0, bytes.Length);
goto IL_168;
}
}
IL_125:
return null;
}
IL_168:
return (byte[])this.certhash.Clone();
}
}
// Token: 0x1700008C RID: 140
// (get) Token: 0x060002E5 RID: 741 RVA: 0x00015B34 File Offset: 0x00013D34
public virtual string IssuerName
{
get
{
return this.m_issuername;
}
}
// Token: 0x1700008D RID: 141
// (get) Token: 0x060002E6 RID: 742 RVA: 0x00015B3C File Offset: 0x00013D3C
public virtual string KeyAlgorithm
{
get
{
return this.m_keyalgo;
}
}
// Token: 0x1700008E RID: 142
// (get) Token: 0x060002E7 RID: 743 RVA: 0x00015B44 File Offset: 0x00013D44
// (set) Token: 0x060002E8 RID: 744 RVA: 0x00015B64 File Offset: 0x00013D64
public virtual byte[] KeyAlgorithmParameters
{
get
{
if (this.m_keyalgoparams == null)
{
return null;
}
return (byte[])this.m_keyalgoparams.Clone();
}
set
{
this.m_keyalgoparams = value;
}
}
// Token: 0x1700008F RID: 143
// (get) Token: 0x060002E9 RID: 745 RVA: 0x00015B70 File Offset: 0x00013D70
public virtual byte[] PublicKey
{
get
{
if (this.m_publickey == null)
{
return null;
}
return (byte[])this.m_publickey.Clone();
}
}
// Token: 0x17000090 RID: 144
// (get) Token: 0x060002EA RID: 746 RVA: 0x00015B90 File Offset: 0x00013D90
// (set) Token: 0x060002EB RID: 747 RVA: 0x00015C3C File Offset: 0x00013E3C
public virtual RSA RSA
{
get
{
if (this._rsa == null)
{
RSAParameters rsaparameters = default(RSAParameters);
ASN1 asn = new ASN1(this.m_publickey);
ASN1 asn2 = asn[0];
if (asn2 == null || asn2.Tag != 2)
{
return null;
}
ASN1 asn3 = asn[1];
if (asn3.Tag != 2)
{
return null;
}
rsaparameters.Modulus = this.GetUnsignedBigInteger(asn2.Value);
rsaparameters.Exponent = asn3.Value;
int num = rsaparameters.Modulus.Length << 3;
this._rsa = new RSACryptoServiceProvider(num);
this._rsa.ImportParameters(rsaparameters);
}
return this._rsa;
}
set
{
if (value != null)
{
this._dsa = null;
}
this._rsa = value;
}
}
// Token: 0x17000091 RID: 145
// (get) Token: 0x060002EC RID: 748 RVA: 0x00015C54 File Offset: 0x00013E54
public virtual byte[] RawData
{
get
{
if (this.m_encodedcert == null)
{
return null;
}
return (byte[])this.m_encodedcert.Clone();
}
}
// Token: 0x17000092 RID: 146
// (get) Token: 0x060002ED RID: 749 RVA: 0x00015C74 File Offset: 0x00013E74
public virtual byte[] SerialNumber
{
get
{
if (this.serialnumber == null)
{
return null;
}
return (byte[])this.serialnumber.Clone();
}
}
// Token: 0x17000093 RID: 147
// (get) Token: 0x060002EE RID: 750 RVA: 0x00015C94 File Offset: 0x00013E94
public virtual byte[] Signature
{
get
{
if (this.signature == null)
{
return null;
}
string signaturealgo = this.m_signaturealgo;
if (signaturealgo != null)
{
if (X509Certificate.<>f__switch$map10 == null)
{
X509Certificate.<>f__switch$map10 = new Dictionary<string, int>(9)
{
{ "1.2.840.113549.1.1.2", 0 },
{ "1.2.840.113549.1.1.3", 0 },
{ "1.2.840.113549.1.1.4", 0 },
{ "1.2.840.113549.1.1.5", 0 },
{ "1.3.14.3.2.29", 0 },
{ "1.2.840.113549.1.1.11", 0 },
{ "1.2.840.113549.1.1.12", 0 },
{ "1.2.840.113549.1.1.13", 0 },
{ "1.2.840.10040.4.3", 1 }
};
}
int num;
if (X509Certificate.<>f__switch$map10.TryGetValue(signaturealgo, out num))
{
if (num == 0)
{
return (byte[])this.signature.Clone();
}
if (num == 1)
{
ASN1 asn = new ASN1(this.signature);
if (asn == null || asn.Count != 2)
{
return null;
}
byte[] value = asn[0].Value;
byte[] value2 = asn[1].Value;
byte[] array = new byte[40];
int num2 = Math.Max(0, value.Length - 20);
int num3 = Math.Max(0, 20 - value.Length);
Buffer.BlockCopy(value, num2, array, num3, value.Length - num2);
int num4 = Math.Max(0, value2.Length - 20);
int num5 = Math.Max(20, 40 - value2.Length);
Buffer.BlockCopy(value2, num4, array, num5, value2.Length - num4);
return array;
}
}
}
throw new CryptographicException("Unsupported hash algorithm: " + this.m_signaturealgo);
}
}
// Token: 0x17000094 RID: 148
// (get) Token: 0x060002EF RID: 751 RVA: 0x00015E38 File Offset: 0x00014038
public virtual string SignatureAlgorithm
{
get
{
return this.m_signaturealgo;
}
}
// Token: 0x17000095 RID: 149
// (get) Token: 0x060002F0 RID: 752 RVA: 0x00015E40 File Offset: 0x00014040
public virtual byte[] SignatureAlgorithmParameters
{
get
{
if (this.m_signaturealgoparams == null)
{
return this.m_signaturealgoparams;
}
return (byte[])this.m_signaturealgoparams.Clone();
}
}
// Token: 0x17000096 RID: 150
// (get) Token: 0x060002F1 RID: 753 RVA: 0x00015E70 File Offset: 0x00014070
public virtual string SubjectName
{
get
{
return this.m_subject;
}
}
// Token: 0x17000097 RID: 151
// (get) Token: 0x060002F2 RID: 754 RVA: 0x00015E78 File Offset: 0x00014078
public virtual DateTime ValidFrom
{
get
{
return this.m_from;
}
}
// Token: 0x17000098 RID: 152
// (get) Token: 0x060002F3 RID: 755 RVA: 0x00015E80 File Offset: 0x00014080
public virtual DateTime ValidUntil
{
get
{
return this.m_until;
}
}
// Token: 0x17000099 RID: 153
// (get) Token: 0x060002F4 RID: 756 RVA: 0x00015E88 File Offset: 0x00014088
public int Version
{
get
{
return this.version;
}
}
// Token: 0x1700009A RID: 154
// (get) Token: 0x060002F5 RID: 757 RVA: 0x00015E90 File Offset: 0x00014090
public bool IsCurrent
{
get
{
return this.WasCurrent(DateTime.UtcNow);
}
}
// Token: 0x060002F6 RID: 758 RVA: 0x00015EA0 File Offset: 0x000140A0
public bool WasCurrent(DateTime instant)
{
return instant > this.ValidFrom && instant <= this.ValidUntil;
}
// Token: 0x1700009B RID: 155
// (get) Token: 0x060002F7 RID: 759 RVA: 0x00015ED0 File Offset: 0x000140D0
public byte[] IssuerUniqueIdentifier
{
get
{
if (this.issuerUniqueID == null)
{
return null;
}
return (byte[])this.issuerUniqueID.Clone();
}
}
// Token: 0x1700009C RID: 156
// (get) Token: 0x060002F8 RID: 760 RVA: 0x00015EF0 File Offset: 0x000140F0
public byte[] SubjectUniqueIdentifier
{
get
{
if (this.subjectUniqueID == null)
{
return null;
}
return (byte[])this.subjectUniqueID.Clone();
}
}
// Token: 0x060002F9 RID: 761 RVA: 0x00015F10 File Offset: 0x00014110
internal bool VerifySignature(DSA dsa)
{
DSASignatureDeformatter dsasignatureDeformatter = new DSASignatureDeformatter(dsa);
dsasignatureDeformatter.SetHashAlgorithm("SHA1");
return dsasignatureDeformatter.VerifySignature(this.Hash, this.Signature);
}
// Token: 0x060002FA RID: 762 RVA: 0x00015F44 File Offset: 0x00014144
internal bool VerifySignature(RSA rsa)
{
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
string signaturealgo = this.m_signaturealgo;
if (signaturealgo != null)
{
if (X509Certificate.<>f__switch$map11 == null)
{
X509Certificate.<>f__switch$map11 = new Dictionary<string, int>(9)
{
{ "1.2.840.113549.1.1.2", 0 },
{ "1.2.840.113549.1.1.3", 1 },
{ "1.2.840.113549.1.1.4", 2 },
{ "1.2.840.113549.1.1.5", 3 },
{ "1.3.14.3.2.29", 3 },
{ "1.2.840.113549.1.1.11", 4 },
{ "1.2.840.113549.1.1.12", 5 },
{ "1.2.840.113549.1.1.13", 6 },
{ "1.2.840.10040.4.3", 7 }
};
}
int num;
if (X509Certificate.<>f__switch$map11.TryGetValue(signaturealgo, out num))
{
switch (num)
{
case 0:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("MD2");
break;
case 1:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("MD4");
break;
case 2:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("MD5");
break;
case 3:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("SHA1");
break;
case 4:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("SHA256");
break;
case 5:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("SHA384");
break;
case 6:
rsapkcs1SignatureDeformatter.SetHashAlgorithm("SHA512");
break;
case 7:
return false;
default:
goto IL_147;
}
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.Signature);
}
}
IL_147:
throw new CryptographicException("Unsupported hash algorithm: " + this.m_signaturealgo);
}
// Token: 0x060002FB RID: 763 RVA: 0x000160C0 File Offset: 0x000142C0
public bool VerifySignature(AsymmetricAlgorithm aa)
{
if (aa == null)
{
throw new ArgumentNullException("aa");
}
if (aa is RSA)
{
return this.VerifySignature(aa as RSA);
}
if (aa is DSA)
{
return this.VerifySignature(aa as DSA);
}
throw new NotSupportedException("Unknown Asymmetric Algorithm " + aa.ToString());
}
// Token: 0x060002FC RID: 764 RVA: 0x00016124 File Offset: 0x00014324
public bool CheckSignature(byte[] hash, string hashAlgorithm, byte[] signature)
{
RSACryptoServiceProvider rsacryptoServiceProvider = (RSACryptoServiceProvider)this.RSA;
return rsacryptoServiceProvider.VerifyHash(hash, hashAlgorithm, signature);
}
// Token: 0x1700009D RID: 157
// (get) Token: 0x060002FD RID: 765 RVA: 0x00016148 File Offset: 0x00014348
public bool IsSelfSigned
{
get
{
return this.m_issuername == this.m_subject && this.VerifySignature(this.RSA);
}
}
// Token: 0x060002FE RID: 766 RVA: 0x0001617C File Offset: 0x0001437C
public ASN1 GetIssuerName()
{
return this.issuer;
}
// Token: 0x060002FF RID: 767 RVA: 0x00016184 File Offset: 0x00014384
public ASN1 GetSubjectName()
{
return this.subject;
}
// Token: 0x06000300 RID: 768 RVA: 0x0001618C File Offset: 0x0001438C
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("raw", this.m_encodedcert);
}
// Token: 0x06000301 RID: 769 RVA: 0x000161A0 File Offset: 0x000143A0
private static byte[] PEM(string type, byte[] data)
{
string @string = Encoding.ASCII.GetString(data);
string text = string.Format("-----BEGIN {0}-----", type);
string text2 = string.Format("-----END {0}-----", type);
int num = @string.IndexOf(text) + text.Length;
int num2 = @string.IndexOf(text2, num);
string text3 = @string.Substring(num, num2 - num);
return Convert.FromBase64String(text3);
}
// Token: 0x0400015E RID: 350
private ASN1 decoder;
// Token: 0x0400015F RID: 351
private byte[] m_encodedcert;
// Token: 0x04000160 RID: 352
private DateTime m_from;
// Token: 0x04000161 RID: 353
private DateTime m_until;
// Token: 0x04000162 RID: 354
private ASN1 issuer;
// Token: 0x04000163 RID: 355
private string m_issuername;
// Token: 0x04000164 RID: 356
private string m_keyalgo;
// Token: 0x04000165 RID: 357
private byte[] m_keyalgoparams;
// Token: 0x04000166 RID: 358
private ASN1 subject;
// Token: 0x04000167 RID: 359
private string m_subject;
// Token: 0x04000168 RID: 360
private byte[] m_publickey;
// Token: 0x04000169 RID: 361
private byte[] signature;
// Token: 0x0400016A RID: 362
private string m_signaturealgo;
// Token: 0x0400016B RID: 363
private byte[] m_signaturealgoparams;
// Token: 0x0400016C RID: 364
private byte[] certhash;
// Token: 0x0400016D RID: 365
private RSA _rsa;
// Token: 0x0400016E RID: 366
private DSA _dsa;
// Token: 0x0400016F RID: 367
private int version;
// Token: 0x04000170 RID: 368
private byte[] serialnumber;
// Token: 0x04000171 RID: 369
private byte[] issuerUniqueID;
// Token: 0x04000172 RID: 370
private byte[] subjectUniqueID;
// Token: 0x04000173 RID: 371
private X509ExtensionCollection extensions;
// Token: 0x04000174 RID: 372
private static string encoding_error = Locale.GetText("Input data cannot be coded as a valid certificate.");
}
}
@@ -0,0 +1,278 @@
using System;
using System.Security.Cryptography;
namespace Mono.Security.X509
{
// Token: 0x02000046 RID: 70
public class X509CertificateBuilder : X509Builder
{
// Token: 0x0600031A RID: 794 RVA: 0x000164A0 File Offset: 0x000146A0
public X509CertificateBuilder()
: this(3)
{
}
// Token: 0x0600031B RID: 795 RVA: 0x000164AC File Offset: 0x000146AC
public X509CertificateBuilder(byte version)
{
if (version > 3)
{
throw new ArgumentException("Invalid certificate version");
}
this.version = version;
this.extensions = new X509ExtensionCollection();
}
// Token: 0x170000A1 RID: 161
// (get) Token: 0x0600031C RID: 796 RVA: 0x000164E4 File Offset: 0x000146E4
// (set) Token: 0x0600031D RID: 797 RVA: 0x000164EC File Offset: 0x000146EC
public byte Version
{
get
{
return this.version;
}
set
{
this.version = value;
}
}
// Token: 0x170000A2 RID: 162
// (get) Token: 0x0600031E RID: 798 RVA: 0x000164F8 File Offset: 0x000146F8
// (set) Token: 0x0600031F RID: 799 RVA: 0x00016500 File Offset: 0x00014700
public byte[] SerialNumber
{
get
{
return this.sn;
}
set
{
this.sn = value;
}
}
// Token: 0x170000A3 RID: 163
// (get) Token: 0x06000320 RID: 800 RVA: 0x0001650C File Offset: 0x0001470C
// (set) Token: 0x06000321 RID: 801 RVA: 0x00016514 File Offset: 0x00014714
public string IssuerName
{
get
{
return this.issuer;
}
set
{
this.issuer = value;
}
}
// Token: 0x170000A4 RID: 164
// (get) Token: 0x06000322 RID: 802 RVA: 0x00016520 File Offset: 0x00014720
// (set) Token: 0x06000323 RID: 803 RVA: 0x00016528 File Offset: 0x00014728
public DateTime NotBefore
{
get
{
return this.notBefore;
}
set
{
this.notBefore = value;
}
}
// Token: 0x170000A5 RID: 165
// (get) Token: 0x06000324 RID: 804 RVA: 0x00016534 File Offset: 0x00014734
// (set) Token: 0x06000325 RID: 805 RVA: 0x0001653C File Offset: 0x0001473C
public DateTime NotAfter
{
get
{
return this.notAfter;
}
set
{
this.notAfter = value;
}
}
// Token: 0x170000A6 RID: 166
// (get) Token: 0x06000326 RID: 806 RVA: 0x00016548 File Offset: 0x00014748
// (set) Token: 0x06000327 RID: 807 RVA: 0x00016550 File Offset: 0x00014750
public string SubjectName
{
get
{
return this.subject;
}
set
{
this.subject = value;
}
}
// Token: 0x170000A7 RID: 167
// (get) Token: 0x06000328 RID: 808 RVA: 0x0001655C File Offset: 0x0001475C
// (set) Token: 0x06000329 RID: 809 RVA: 0x00016564 File Offset: 0x00014764
public AsymmetricAlgorithm SubjectPublicKey
{
get
{
return this.aa;
}
set
{
this.aa = value;
}
}
// Token: 0x170000A8 RID: 168
// (get) Token: 0x0600032A RID: 810 RVA: 0x00016570 File Offset: 0x00014770
// (set) Token: 0x0600032B RID: 811 RVA: 0x00016578 File Offset: 0x00014778
public byte[] IssuerUniqueId
{
get
{
return this.issuerUniqueID;
}
set
{
this.issuerUniqueID = value;
}
}
// Token: 0x170000A9 RID: 169
// (get) Token: 0x0600032C RID: 812 RVA: 0x00016584 File Offset: 0x00014784
// (set) Token: 0x0600032D RID: 813 RVA: 0x0001658C File Offset: 0x0001478C
public byte[] SubjectUniqueId
{
get
{
return this.subjectUniqueID;
}
set
{
this.subjectUniqueID = value;
}
}
// Token: 0x170000AA RID: 170
// (get) Token: 0x0600032E RID: 814 RVA: 0x00016598 File Offset: 0x00014798
public X509ExtensionCollection Extensions
{
get
{
return this.extensions;
}
}
// Token: 0x0600032F RID: 815 RVA: 0x000165A0 File Offset: 0x000147A0
private ASN1 SubjectPublicKeyInfo()
{
ASN1 asn = new ASN1(48);
if (this.aa is RSA)
{
asn.Add(PKCS7.AlgorithmIdentifier("1.2.840.113549.1.1.1"));
RSAParameters rsaparameters = (this.aa as RSA).ExportParameters(false);
ASN1 asn2 = new ASN1(48);
asn2.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.Modulus));
asn2.Add(ASN1Convert.FromUnsignedBigInteger(rsaparameters.Exponent));
asn.Add(new ASN1(this.UniqueIdentifier(asn2.GetBytes())));
}
else
{
if (!(this.aa is DSA))
{
throw new NotSupportedException("Unknown Asymmetric Algorithm " + this.aa.ToString());
}
DSAParameters dsaparameters = (this.aa as DSA).ExportParameters(false);
ASN1 asn3 = new ASN1(48);
asn3.Add(ASN1Convert.FromUnsignedBigInteger(dsaparameters.P));
asn3.Add(ASN1Convert.FromUnsignedBigInteger(dsaparameters.Q));
asn3.Add(ASN1Convert.FromUnsignedBigInteger(dsaparameters.G));
asn.Add(PKCS7.AlgorithmIdentifier("1.2.840.10040.4.1", asn3));
ASN1 asn4 = asn.Add(new ASN1(3));
asn4.Add(ASN1Convert.FromUnsignedBigInteger(dsaparameters.Y));
}
return asn;
}
// Token: 0x06000330 RID: 816 RVA: 0x000166F0 File Offset: 0x000148F0
private byte[] UniqueIdentifier(byte[] id)
{
ASN1 asn = new ASN1(3);
byte[] array = new byte[id.Length + 1];
Buffer.BlockCopy(id, 0, array, 1, id.Length);
asn.Value = array;
return asn.GetBytes();
}
// Token: 0x06000331 RID: 817 RVA: 0x00016728 File Offset: 0x00014928
protected override ASN1 ToBeSigned(string oid)
{
ASN1 asn = new ASN1(48);
if (this.version > 1)
{
byte[] array = new byte[] { this.version - 1 };
ASN1 asn2 = asn.Add(new ASN1(160));
asn2.Add(new ASN1(2, array));
}
asn.Add(new ASN1(2, this.sn));
asn.Add(PKCS7.AlgorithmIdentifier(oid));
asn.Add(X501.FromString(this.issuer));
ASN1 asn3 = asn.Add(new ASN1(48));
asn3.Add(ASN1Convert.FromDateTime(this.notBefore));
asn3.Add(ASN1Convert.FromDateTime(this.notAfter));
asn.Add(X501.FromString(this.subject));
asn.Add(this.SubjectPublicKeyInfo());
if (this.version > 1)
{
if (this.issuerUniqueID != null)
{
asn.Add(new ASN1(161, this.UniqueIdentifier(this.issuerUniqueID)));
}
if (this.subjectUniqueID != null)
{
asn.Add(new ASN1(161, this.UniqueIdentifier(this.subjectUniqueID)));
}
if (this.version > 2 && this.extensions.Count > 0)
{
asn.Add(new ASN1(163, this.extensions.GetBytes()));
}
}
return asn;
}
// Token: 0x04000179 RID: 377
private byte version;
// Token: 0x0400017A RID: 378
private byte[] sn;
// Token: 0x0400017B RID: 379
private string issuer;
// Token: 0x0400017C RID: 380
private DateTime notBefore;
// Token: 0x0400017D RID: 381
private DateTime notAfter;
// Token: 0x0400017E RID: 382
private string subject;
// Token: 0x0400017F RID: 383
private AsymmetricAlgorithm aa;
// Token: 0x04000180 RID: 384
private byte[] issuerUniqueID;
// Token: 0x04000181 RID: 385
private byte[] subjectUniqueID;
// Token: 0x04000182 RID: 386
private X509ExtensionCollection extensions;
}
}
@@ -0,0 +1,219 @@
using System;
using System.Collections;
namespace Mono.Security.X509
{
// Token: 0x02000044 RID: 68
[Serializable]
public class X509CertificateCollection : CollectionBase, IEnumerable
{
// Token: 0x06000302 RID: 770 RVA: 0x00016200 File Offset: 0x00014400
public X509CertificateCollection()
{
}
// Token: 0x06000303 RID: 771 RVA: 0x00016208 File Offset: 0x00014408
public X509CertificateCollection(X509Certificate[] value)
{
this.AddRange(value);
}
// Token: 0x06000304 RID: 772 RVA: 0x00016218 File Offset: 0x00014418
public X509CertificateCollection(X509CertificateCollection value)
{
this.AddRange(value);
}
// Token: 0x06000305 RID: 773 RVA: 0x00016228 File Offset: 0x00014428
IEnumerator IEnumerable.GetEnumerator()
{
return base.InnerList.GetEnumerator();
}
// Token: 0x1700009E RID: 158
public X509Certificate this[int index]
{
get
{
return (X509Certificate)base.InnerList[index];
}
set
{
base.InnerList[index] = value;
}
}
// Token: 0x06000308 RID: 776 RVA: 0x0001625C File Offset: 0x0001445C
public int Add(X509Certificate value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
return base.InnerList.Add(value);
}
// Token: 0x06000309 RID: 777 RVA: 0x0001627C File Offset: 0x0001447C
public void AddRange(X509Certificate[] value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
for (int i = 0; i < value.Length; i++)
{
base.InnerList.Add(value[i]);
}
}
// Token: 0x0600030A RID: 778 RVA: 0x000162C0 File Offset: 0x000144C0
public void AddRange(X509CertificateCollection value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
for (int i = 0; i < value.InnerList.Count; i++)
{
base.InnerList.Add(value[i]);
}
}
// Token: 0x0600030B RID: 779 RVA: 0x00016310 File Offset: 0x00014510
public bool Contains(X509Certificate value)
{
return this.IndexOf(value) != -1;
}
// Token: 0x0600030C RID: 780 RVA: 0x00016320 File Offset: 0x00014520
public void CopyTo(X509Certificate[] array, int index)
{
base.InnerList.CopyTo(array, index);
}
// Token: 0x0600030D RID: 781 RVA: 0x00016330 File Offset: 0x00014530
public new X509CertificateCollection.X509CertificateEnumerator GetEnumerator()
{
return new X509CertificateCollection.X509CertificateEnumerator(this);
}
// Token: 0x0600030E RID: 782 RVA: 0x00016338 File Offset: 0x00014538
public override int GetHashCode()
{
return base.InnerList.GetHashCode();
}
// Token: 0x0600030F RID: 783 RVA: 0x00016348 File Offset: 0x00014548
public int IndexOf(X509Certificate value)
{
if (value == null)
{
throw new ArgumentNullException("value");
}
byte[] hash = value.Hash;
for (int i = 0; i < base.InnerList.Count; i++)
{
X509Certificate x509Certificate = (X509Certificate)base.InnerList[i];
if (this.Compare(x509Certificate.Hash, hash))
{
return i;
}
}
return -1;
}
// Token: 0x06000310 RID: 784 RVA: 0x000163B0 File Offset: 0x000145B0
public void Insert(int index, X509Certificate value)
{
base.InnerList.Insert(index, value);
}
// Token: 0x06000311 RID: 785 RVA: 0x000163C0 File Offset: 0x000145C0
public void Remove(X509Certificate value)
{
base.InnerList.Remove(value);
}
// Token: 0x06000312 RID: 786 RVA: 0x000163D0 File Offset: 0x000145D0
private bool Compare(byte[] array1, byte[] array2)
{
if (array1 == null && array2 == null)
{
return true;
}
if (array1 == null || array2 == null)
{
return false;
}
if (array1.Length != array2.Length)
{
return false;
}
for (int i = 0; i < array1.Length; i++)
{
if (array1[i] != array2[i])
{
return false;
}
}
return true;
}
// Token: 0x02000045 RID: 69
public class X509CertificateEnumerator : IEnumerator
{
// Token: 0x06000313 RID: 787 RVA: 0x00016428 File Offset: 0x00014628
public X509CertificateEnumerator(X509CertificateCollection mappings)
{
this.enumerator = ((IEnumerable)mappings).GetEnumerator();
}
// Token: 0x1700009F RID: 159
// (get) Token: 0x06000314 RID: 788 RVA: 0x0001643C File Offset: 0x0001463C
object IEnumerator.Current
{
get
{
return this.enumerator.Current;
}
}
// Token: 0x06000315 RID: 789 RVA: 0x0001644C File Offset: 0x0001464C
bool IEnumerator.MoveNext()
{
return this.enumerator.MoveNext();
}
// Token: 0x06000316 RID: 790 RVA: 0x0001645C File Offset: 0x0001465C
void IEnumerator.Reset()
{
this.enumerator.Reset();
}
// Token: 0x170000A0 RID: 160
// (get) Token: 0x06000317 RID: 791 RVA: 0x0001646C File Offset: 0x0001466C
public X509Certificate Current
{
get
{
return (X509Certificate)this.enumerator.Current;
}
}
// Token: 0x06000318 RID: 792 RVA: 0x00016480 File Offset: 0x00014680
public bool MoveNext()
{
return this.enumerator.MoveNext();
}
// Token: 0x06000319 RID: 793 RVA: 0x00016490 File Offset: 0x00014690
public void Reset()
{
this.enumerator.Reset();
}
// Token: 0x04000178 RID: 376
private IEnumerator enumerator;
}
}
}
+288
View File
@@ -0,0 +1,288 @@
using System;
using System.Net;
using Mono.Security.X509.Extensions;
namespace Mono.Security.X509
{
// Token: 0x02000047 RID: 71
public class X509Chain
{
// Token: 0x06000332 RID: 818 RVA: 0x00016894 File Offset: 0x00014A94
public X509Chain()
{
this.certs = new X509CertificateCollection();
}
// Token: 0x06000333 RID: 819 RVA: 0x000168A8 File Offset: 0x00014AA8
public X509Chain(X509CertificateCollection chain)
: this()
{
this._chain = new X509CertificateCollection();
this._chain.AddRange(chain);
}
// Token: 0x170000AB RID: 171
// (get) Token: 0x06000334 RID: 820 RVA: 0x000168C8 File Offset: 0x00014AC8
public X509CertificateCollection Chain
{
get
{
return this._chain;
}
}
// Token: 0x170000AC RID: 172
// (get) Token: 0x06000335 RID: 821 RVA: 0x000168D0 File Offset: 0x00014AD0
public X509Certificate Root
{
get
{
return this._root;
}
}
// Token: 0x170000AD RID: 173
// (get) Token: 0x06000336 RID: 822 RVA: 0x000168D8 File Offset: 0x00014AD8
public X509ChainStatusFlags Status
{
get
{
return this._status;
}
}
// Token: 0x170000AE RID: 174
// (get) Token: 0x06000337 RID: 823 RVA: 0x000168E0 File Offset: 0x00014AE0
// (set) Token: 0x06000338 RID: 824 RVA: 0x00016918 File Offset: 0x00014B18
public X509CertificateCollection TrustAnchors
{
get
{
if (this.roots == null)
{
this.roots = new X509CertificateCollection();
this.roots.AddRange(X509StoreManager.TrustedRootCertificates);
return this.roots;
}
return this.roots;
}
set
{
this.roots = value;
}
}
// Token: 0x06000339 RID: 825 RVA: 0x00016924 File Offset: 0x00014B24
public void LoadCertificate(X509Certificate x509)
{
this.certs.Add(x509);
}
// Token: 0x0600033A RID: 826 RVA: 0x00016934 File Offset: 0x00014B34
public void LoadCertificates(X509CertificateCollection collection)
{
this.certs.AddRange(collection);
}
// Token: 0x0600033B RID: 827 RVA: 0x00016944 File Offset: 0x00014B44
public X509Certificate FindByIssuerName(string issuerName)
{
foreach (X509Certificate x509Certificate in this.certs)
{
if (x509Certificate.IssuerName == issuerName)
{
return x509Certificate;
}
}
return null;
}
// Token: 0x0600033C RID: 828 RVA: 0x000169C4 File Offset: 0x00014BC4
public bool Build(X509Certificate leaf)
{
this._status = X509ChainStatusFlags.NoError;
if (this._chain == null)
{
this._chain = new X509CertificateCollection();
X509Certificate x509Certificate = leaf;
X509Certificate x509Certificate2 = x509Certificate;
while (x509Certificate != null && !x509Certificate.IsSelfSigned)
{
x509Certificate2 = x509Certificate;
this._chain.Add(x509Certificate);
x509Certificate = this.FindCertificateParent(x509Certificate);
}
this._root = this.FindCertificateRoot(x509Certificate2);
}
else
{
int count = this._chain.Count;
if (count > 0)
{
if (this.IsParent(leaf, this._chain[0]))
{
int i;
for (i = 1; i < count; i++)
{
if (!this.IsParent(this._chain[i - 1], this._chain[i]))
{
break;
}
}
if (i == count)
{
this._root = this.FindCertificateRoot(this._chain[count - 1]);
}
}
}
else
{
this._root = this.FindCertificateRoot(leaf);
}
}
if (this._chain != null && this._status == X509ChainStatusFlags.NoError)
{
foreach (X509Certificate x509Certificate3 in this._chain)
{
if (!this.IsValid(x509Certificate3))
{
return false;
}
}
if (!this.IsValid(leaf))
{
if (this._status == X509ChainStatusFlags.NotTimeNested)
{
this._status = X509ChainStatusFlags.NotTimeValid;
}
return false;
}
if (this._root != null && !this.IsValid(this._root))
{
return false;
}
}
IL_1A6:
return this._status == X509ChainStatusFlags.NoError;
}
// Token: 0x0600033D RID: 829 RVA: 0x00016BA0 File Offset: 0x00014DA0
public void Reset()
{
this._status = X509ChainStatusFlags.NoError;
this.roots = null;
this.certs.Clear();
if (this._chain != null)
{
this._chain.Clear();
}
}
// Token: 0x0600033E RID: 830 RVA: 0x00016BD4 File Offset: 0x00014DD4
private bool IsValid(X509Certificate cert)
{
if (!cert.IsCurrent)
{
this._status = X509ChainStatusFlags.NotTimeNested;
return false;
}
if (ServicePointManager.CheckCertificateRevocationList)
{
}
return true;
}
// Token: 0x0600033F RID: 831 RVA: 0x00016BF8 File Offset: 0x00014DF8
private X509Certificate FindCertificateParent(X509Certificate child)
{
foreach (X509Certificate x509Certificate in this.certs)
{
if (this.IsParent(child, x509Certificate))
{
return x509Certificate;
}
}
return null;
}
// Token: 0x06000340 RID: 832 RVA: 0x00016C74 File Offset: 0x00014E74
private X509Certificate FindCertificateRoot(X509Certificate potentialRoot)
{
if (potentialRoot == null)
{
this._status = X509ChainStatusFlags.PartialChain;
return null;
}
if (this.IsTrusted(potentialRoot))
{
return potentialRoot;
}
foreach (X509Certificate x509Certificate in this.TrustAnchors)
{
if (this.IsParent(potentialRoot, x509Certificate))
{
return x509Certificate;
}
}
if (potentialRoot.IsSelfSigned)
{
this._status = X509ChainStatusFlags.UntrustedRoot;
return potentialRoot;
}
this._status = X509ChainStatusFlags.PartialChain;
return null;
}
// Token: 0x06000341 RID: 833 RVA: 0x00016D30 File Offset: 0x00014F30
private bool IsTrusted(X509Certificate potentialTrusted)
{
return this.TrustAnchors.Contains(potentialTrusted);
}
// Token: 0x06000342 RID: 834 RVA: 0x00016D40 File Offset: 0x00014F40
private bool IsParent(X509Certificate child, X509Certificate parent)
{
if (child.IssuerName != parent.SubjectName)
{
return false;
}
if (parent.Version > 2 && !this.IsTrusted(parent))
{
X509Extension x509Extension = parent.Extensions["2.5.29.19"];
if (x509Extension != null)
{
BasicConstraintsExtension basicConstraintsExtension = new BasicConstraintsExtension(x509Extension);
if (!basicConstraintsExtension.CertificateAuthority)
{
this._status = X509ChainStatusFlags.InvalidBasicConstraints;
}
}
else
{
this._status = X509ChainStatusFlags.InvalidBasicConstraints;
}
}
if (!child.VerifySignature(parent.RSA))
{
this._status = X509ChainStatusFlags.NotSignatureValid;
return false;
}
return true;
}
// Token: 0x04000183 RID: 387
private X509CertificateCollection roots;
// Token: 0x04000184 RID: 388
private X509CertificateCollection certs;
// Token: 0x04000185 RID: 389
private X509Certificate _root;
// Token: 0x04000186 RID: 390
private X509CertificateCollection _chain;
// Token: 0x04000187 RID: 391
private X509ChainStatusFlags _status;
}
}
@@ -0,0 +1,25 @@
using System;
namespace Mono.Security.X509
{
// Token: 0x02000048 RID: 72
[Flags]
[Serializable]
public enum X509ChainStatusFlags
{
// Token: 0x04000189 RID: 393
InvalidBasicConstraints = 1024,
// Token: 0x0400018A RID: 394
NoError = 0,
// Token: 0x0400018B RID: 395
NotSignatureValid = 8,
// Token: 0x0400018C RID: 396
NotTimeNested = 2,
// Token: 0x0400018D RID: 397
NotTimeValid = 1,
// Token: 0x0400018E RID: 398
PartialChain = 65536,
// Token: 0x0400018F RID: 399
UntrustedRoot = 32
}
}
+546
View File
@@ -0,0 +1,546 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using Mono.Security.X509.Extensions;
namespace Mono.Security.X509
{
// Token: 0x02000049 RID: 73
public class X509Crl
{
// Token: 0x06000343 RID: 835 RVA: 0x00016DDC File Offset: 0x00014FDC
public X509Crl(byte[] crl)
{
if (crl == null)
{
throw new ArgumentNullException("crl");
}
this.encoded = (byte[])crl.Clone();
this.Parse(this.encoded);
}
// Token: 0x06000344 RID: 836 RVA: 0x00016E20 File Offset: 0x00015020
private void Parse(byte[] crl)
{
string text = "Input data cannot be coded as a valid CRL.";
try
{
ASN1 asn = new ASN1(this.encoded);
if (asn.Tag != 48 || asn.Count != 3)
{
throw new CryptographicException(text);
}
ASN1 asn2 = asn[0];
if (asn2.Tag != 48 || asn2.Count < 3)
{
throw new CryptographicException(text);
}
int num = 0;
if (asn2[num].Tag == 2)
{
this.version = asn2[num++].Value[0] + 1;
}
else
{
this.version = 1;
}
this.signatureOID = ASN1Convert.ToOid(asn2[num++][0]);
this.issuer = X501.ToString(asn2[num++]);
this.thisUpdate = ASN1Convert.ToDateTime(asn2[num++]);
ASN1 asn3 = asn2[num++];
if (asn3.Tag == 23 || asn3.Tag == 24)
{
this.nextUpdate = ASN1Convert.ToDateTime(asn3);
asn3 = asn2[num++];
}
this.entries = new ArrayList();
if (asn3 != null && asn3.Tag == 48)
{
ASN1 asn4 = asn3;
for (int i = 0; i < asn4.Count; i++)
{
this.entries.Add(new X509Crl.X509CrlEntry(asn4[i]));
}
}
else
{
num--;
}
ASN1 asn5 = asn2[num];
if (asn5 != null && asn5.Tag == 160 && asn5.Count == 1)
{
this.extensions = new X509ExtensionCollection(asn5[0]);
}
else
{
this.extensions = new X509ExtensionCollection(null);
}
string text2 = ASN1Convert.ToOid(asn[1][0]);
if (this.signatureOID != text2)
{
throw new CryptographicException(text + " [Non-matching signature algorithms in CRL]");
}
byte[] value = asn[2].Value;
this.signature = new byte[value.Length - 1];
Buffer.BlockCopy(value, 1, this.signature, 0, this.signature.Length);
}
catch
{
throw new CryptographicException(text);
}
}
// Token: 0x170000AF RID: 175
// (get) Token: 0x06000345 RID: 837 RVA: 0x000170A0 File Offset: 0x000152A0
public ArrayList Entries
{
get
{
return ArrayList.ReadOnly(this.entries);
}
}
// Token: 0x170000B0 RID: 176
public X509Crl.X509CrlEntry this[int index]
{
get
{
return (X509Crl.X509CrlEntry)this.entries[index];
}
}
// Token: 0x170000B1 RID: 177
public X509Crl.X509CrlEntry this[byte[] serialNumber]
{
get
{
return this.GetCrlEntry(serialNumber);
}
}
// Token: 0x170000B2 RID: 178
// (get) Token: 0x06000348 RID: 840 RVA: 0x000170D0 File Offset: 0x000152D0
public X509ExtensionCollection Extensions
{
get
{
return this.extensions;
}
}
// Token: 0x170000B3 RID: 179
// (get) Token: 0x06000349 RID: 841 RVA: 0x000170D8 File Offset: 0x000152D8
public byte[] Hash
{
get
{
if (this.hash_value == null)
{
ASN1 asn = new ASN1(this.encoded);
byte[] bytes = asn[0].GetBytes();
HashAlgorithm hashAlgorithm = HashAlgorithm.Create(this.GetHashName());
this.hash_value = hashAlgorithm.ComputeHash(bytes);
}
return this.hash_value;
}
}
// Token: 0x170000B4 RID: 180
// (get) Token: 0x0600034A RID: 842 RVA: 0x00017128 File Offset: 0x00015328
public string IssuerName
{
get
{
return this.issuer;
}
}
// Token: 0x170000B5 RID: 181
// (get) Token: 0x0600034B RID: 843 RVA: 0x00017130 File Offset: 0x00015330
public DateTime NextUpdate
{
get
{
return this.nextUpdate;
}
}
// Token: 0x170000B6 RID: 182
// (get) Token: 0x0600034C RID: 844 RVA: 0x00017138 File Offset: 0x00015338
public DateTime ThisUpdate
{
get
{
return this.thisUpdate;
}
}
// Token: 0x170000B7 RID: 183
// (get) Token: 0x0600034D RID: 845 RVA: 0x00017140 File Offset: 0x00015340
public string SignatureAlgorithm
{
get
{
return this.signatureOID;
}
}
// Token: 0x170000B8 RID: 184
// (get) Token: 0x0600034E RID: 846 RVA: 0x00017148 File Offset: 0x00015348
public byte[] Signature
{
get
{
if (this.signature == null)
{
return null;
}
return (byte[])this.signature.Clone();
}
}
// Token: 0x170000B9 RID: 185
// (get) Token: 0x0600034F RID: 847 RVA: 0x00017168 File Offset: 0x00015368
public byte[] RawData
{
get
{
return (byte[])this.encoded.Clone();
}
}
// Token: 0x170000BA RID: 186
// (get) Token: 0x06000350 RID: 848 RVA: 0x0001717C File Offset: 0x0001537C
public byte Version
{
get
{
return this.version;
}
}
// Token: 0x170000BB RID: 187
// (get) Token: 0x06000351 RID: 849 RVA: 0x00017184 File Offset: 0x00015384
public bool IsCurrent
{
get
{
return this.WasCurrent(DateTime.Now);
}
}
// Token: 0x06000352 RID: 850 RVA: 0x00017194 File Offset: 0x00015394
public bool WasCurrent(DateTime instant)
{
if (this.nextUpdate == DateTime.MinValue)
{
return instant >= this.thisUpdate;
}
return instant >= this.thisUpdate && instant <= this.nextUpdate;
}
// Token: 0x06000353 RID: 851 RVA: 0x000171E4 File Offset: 0x000153E4
public byte[] GetBytes()
{
return (byte[])this.encoded.Clone();
}
// Token: 0x06000354 RID: 852 RVA: 0x000171F8 File Offset: 0x000153F8
private bool Compare(byte[] array1, byte[] array2)
{
if (array1 == null && array2 == null)
{
return true;
}
if (array1 == null || array2 == null)
{
return false;
}
if (array1.Length != array2.Length)
{
return false;
}
for (int i = 0; i < array1.Length; i++)
{
if (array1[i] != array2[i])
{
return false;
}
}
return true;
}
// Token: 0x06000355 RID: 853 RVA: 0x00017250 File Offset: 0x00015450
public X509Crl.X509CrlEntry GetCrlEntry(X509Certificate x509)
{
if (x509 == null)
{
throw new ArgumentNullException("x509");
}
return this.GetCrlEntry(x509.SerialNumber);
}
// Token: 0x06000356 RID: 854 RVA: 0x00017270 File Offset: 0x00015470
public X509Crl.X509CrlEntry GetCrlEntry(byte[] serialNumber)
{
if (serialNumber == null)
{
throw new ArgumentNullException("serialNumber");
}
for (int i = 0; i < this.entries.Count; i++)
{
X509Crl.X509CrlEntry x509CrlEntry = (X509Crl.X509CrlEntry)this.entries[i];
if (this.Compare(serialNumber, x509CrlEntry.SerialNumber))
{
return x509CrlEntry;
}
}
return null;
}
// Token: 0x06000357 RID: 855 RVA: 0x000172D4 File Offset: 0x000154D4
public bool VerifySignature(X509Certificate x509)
{
if (x509 == null)
{
throw new ArgumentNullException("x509");
}
if (x509.Version >= 3)
{
X509Extension x509Extension = x509.Extensions["2.5.29.15"];
if (x509Extension != null)
{
KeyUsageExtension keyUsageExtension = new KeyUsageExtension(x509Extension);
if (!keyUsageExtension.Support(KeyUsages.cRLSign))
{
return false;
}
}
x509Extension = x509.Extensions["2.5.29.19"];
if (x509Extension != null)
{
BasicConstraintsExtension basicConstraintsExtension = new BasicConstraintsExtension(x509Extension);
if (!basicConstraintsExtension.CertificateAuthority)
{
return false;
}
}
}
if (this.issuer != x509.SubjectName)
{
return false;
}
string text = this.signatureOID;
if (text != null)
{
if (X509Crl.<>f__switch$map12 == null)
{
X509Crl.<>f__switch$map12 = new Dictionary<string, int>(1) { { "1.2.840.10040.4.3", 0 } };
}
int num;
if (X509Crl.<>f__switch$map12.TryGetValue(text, out num))
{
if (num == 0)
{
return this.VerifySignature(x509.DSA);
}
}
}
return this.VerifySignature(x509.RSA);
}
// Token: 0x06000358 RID: 856 RVA: 0x000173D8 File Offset: 0x000155D8
private string GetHashName()
{
string text = this.signatureOID;
switch (text)
{
case "1.2.840.113549.1.1.2":
return "MD2";
case "1.2.840.113549.1.1.4":
return "MD5";
case "1.2.840.10040.4.3":
case "1.2.840.113549.1.1.5":
return "SHA1";
}
throw new CryptographicException("Unsupported hash algorithm: " + this.signatureOID);
}
// Token: 0x06000359 RID: 857 RVA: 0x0001748C File Offset: 0x0001568C
internal bool VerifySignature(DSA dsa)
{
if (this.signatureOID != "1.2.840.10040.4.3")
{
throw new CryptographicException("Unsupported hash algorithm: " + this.signatureOID);
}
DSASignatureDeformatter dsasignatureDeformatter = new DSASignatureDeformatter(dsa);
dsasignatureDeformatter.SetHashAlgorithm("SHA1");
ASN1 asn = new ASN1(this.signature);
if (asn == null || asn.Count != 2)
{
return false;
}
byte[] value = asn[0].Value;
byte[] value2 = asn[1].Value;
byte[] array = new byte[40];
int num = Math.Max(0, value.Length - 20);
int num2 = Math.Max(0, 20 - value.Length);
Buffer.BlockCopy(value, num, array, num2, value.Length - num);
int num3 = Math.Max(0, value2.Length - 20);
int num4 = Math.Max(20, 40 - value2.Length);
Buffer.BlockCopy(value2, num3, array, num4, value2.Length - num3);
return dsasignatureDeformatter.VerifySignature(this.Hash, array);
}
// Token: 0x0600035A RID: 858 RVA: 0x00017584 File Offset: 0x00015784
internal bool VerifySignature(RSA rsa)
{
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
rsapkcs1SignatureDeformatter.SetHashAlgorithm(this.GetHashName());
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.signature);
}
// Token: 0x0600035B RID: 859 RVA: 0x000175B8 File Offset: 0x000157B8
public bool VerifySignature(AsymmetricAlgorithm aa)
{
if (aa == null)
{
throw new ArgumentNullException("aa");
}
if (aa is RSA)
{
return this.VerifySignature(aa as RSA);
}
if (aa is DSA)
{
return this.VerifySignature(aa as DSA);
}
throw new NotSupportedException("Unknown Asymmetric Algorithm " + aa.ToString());
}
// Token: 0x0600035C RID: 860 RVA: 0x0001761C File Offset: 0x0001581C
public static X509Crl CreateFromFile(string filename)
{
byte[] array = null;
using (FileStream fileStream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
{
array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
fileStream.Close();
}
return new X509Crl(array);
}
// Token: 0x04000190 RID: 400
private string issuer;
// Token: 0x04000191 RID: 401
private byte version;
// Token: 0x04000192 RID: 402
private DateTime thisUpdate;
// Token: 0x04000193 RID: 403
private DateTime nextUpdate;
// Token: 0x04000194 RID: 404
private ArrayList entries;
// Token: 0x04000195 RID: 405
private string signatureOID;
// Token: 0x04000196 RID: 406
private byte[] signature;
// Token: 0x04000197 RID: 407
private X509ExtensionCollection extensions;
// Token: 0x04000198 RID: 408
private byte[] encoded;
// Token: 0x04000199 RID: 409
private byte[] hash_value;
// Token: 0x0200004A RID: 74
public class X509CrlEntry
{
// Token: 0x0600035D RID: 861 RVA: 0x00017688 File Offset: 0x00015888
internal X509CrlEntry(byte[] serialNumber, DateTime revocationDate, X509ExtensionCollection extensions)
{
this.sn = serialNumber;
this.revocationDate = revocationDate;
if (extensions == null)
{
this.extensions = new X509ExtensionCollection();
}
else
{
this.extensions = extensions;
}
}
// Token: 0x0600035E RID: 862 RVA: 0x000176BC File Offset: 0x000158BC
internal X509CrlEntry(ASN1 entry)
{
this.sn = entry[0].Value;
Array.Reverse(this.sn);
this.revocationDate = ASN1Convert.ToDateTime(entry[1]);
this.extensions = new X509ExtensionCollection(entry[2]);
}
// Token: 0x170000BC RID: 188
// (get) Token: 0x0600035F RID: 863 RVA: 0x00017710 File Offset: 0x00015910
public byte[] SerialNumber
{
get
{
return (byte[])this.sn.Clone();
}
}
// Token: 0x170000BD RID: 189
// (get) Token: 0x06000360 RID: 864 RVA: 0x00017724 File Offset: 0x00015924
public DateTime RevocationDate
{
get
{
return this.revocationDate;
}
}
// Token: 0x170000BE RID: 190
// (get) Token: 0x06000361 RID: 865 RVA: 0x0001772C File Offset: 0x0001592C
public X509ExtensionCollection Extensions
{
get
{
return this.extensions;
}
}
// Token: 0x06000362 RID: 866 RVA: 0x00017734 File Offset: 0x00015934
public byte[] GetBytes()
{
ASN1 asn = new ASN1(48);
asn.Add(new ASN1(2, this.sn));
asn.Add(ASN1Convert.FromDateTime(this.revocationDate));
if (this.extensions.Count > 0)
{
asn.Add(new ASN1(this.extensions.GetBytes()));
}
return asn.GetBytes();
}
// Token: 0x0400019C RID: 412
private byte[] sn;
// Token: 0x0400019D RID: 413
private DateTime revocationDate;
// Token: 0x0400019E RID: 414
private X509ExtensionCollection extensions;
}
}
}
@@ -0,0 +1,244 @@
using System;
using System.Globalization;
using System.Text;
namespace Mono.Security.X509
{
// Token: 0x0200004B RID: 75
public class X509Extension
{
// Token: 0x06000363 RID: 867 RVA: 0x0001779C File Offset: 0x0001599C
protected X509Extension()
{
this.extnCritical = false;
}
// Token: 0x06000364 RID: 868 RVA: 0x000177AC File Offset: 0x000159AC
public X509Extension(ASN1 asn1)
{
if (asn1.Tag != 48 || asn1.Count < 2)
{
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
}
if (asn1[0].Tag != 6)
{
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
}
this.extnOid = ASN1Convert.ToOid(asn1[0]);
this.extnCritical = asn1[1].Tag == 1 && asn1[1].Value[0] == byte.MaxValue;
this.extnValue = asn1[asn1.Count - 1];
if (this.extnValue.Tag == 4 && this.extnValue.Length > 0 && this.extnValue.Count == 0)
{
try
{
ASN1 asn2 = new ASN1(this.extnValue.Value);
this.extnValue.Value = null;
this.extnValue.Add(asn2);
}
catch
{
}
}
this.Decode();
}
// Token: 0x06000365 RID: 869 RVA: 0x000178EC File Offset: 0x00015AEC
public X509Extension(X509Extension extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
if (extension.Value == null || extension.Value.Tag != 4 || extension.Value.Count != 1)
{
throw new ArgumentException(Locale.GetText("Invalid X.509 extension."));
}
this.extnOid = extension.Oid;
this.extnCritical = extension.Critical;
this.extnValue = extension.Value;
this.Decode();
}
// Token: 0x06000366 RID: 870 RVA: 0x00017978 File Offset: 0x00015B78
protected virtual void Decode()
{
}
// Token: 0x06000367 RID: 871 RVA: 0x0001797C File Offset: 0x00015B7C
protected virtual void Encode()
{
}
// Token: 0x170000BF RID: 191
// (get) Token: 0x06000368 RID: 872 RVA: 0x00017980 File Offset: 0x00015B80
public ASN1 ASN1
{
get
{
ASN1 asn = new ASN1(48);
asn.Add(ASN1Convert.FromOid(this.extnOid));
if (this.extnCritical)
{
asn.Add(new ASN1(1, new byte[] { byte.MaxValue }));
}
this.Encode();
asn.Add(this.extnValue);
return asn;
}
}
// Token: 0x170000C0 RID: 192
// (get) Token: 0x06000369 RID: 873 RVA: 0x000179E4 File Offset: 0x00015BE4
public string Oid
{
get
{
return this.extnOid;
}
}
// Token: 0x170000C1 RID: 193
// (get) Token: 0x0600036A RID: 874 RVA: 0x000179EC File Offset: 0x00015BEC
// (set) Token: 0x0600036B RID: 875 RVA: 0x000179F4 File Offset: 0x00015BF4
public bool Critical
{
get
{
return this.extnCritical;
}
set
{
this.extnCritical = value;
}
}
// Token: 0x170000C2 RID: 194
// (get) Token: 0x0600036C RID: 876 RVA: 0x00017A00 File Offset: 0x00015C00
public virtual string Name
{
get
{
return this.extnOid;
}
}
// Token: 0x170000C3 RID: 195
// (get) Token: 0x0600036D RID: 877 RVA: 0x00017A08 File Offset: 0x00015C08
public ASN1 Value
{
get
{
if (this.extnValue == null)
{
this.Encode();
}
return this.extnValue;
}
}
// Token: 0x0600036E RID: 878 RVA: 0x00017A24 File Offset: 0x00015C24
public override bool Equals(object obj)
{
if (obj == null)
{
return false;
}
X509Extension x509Extension = obj as X509Extension;
if (x509Extension == null)
{
return false;
}
if (this.extnCritical != x509Extension.extnCritical)
{
return false;
}
if (this.extnOid != x509Extension.extnOid)
{
return false;
}
if (this.extnValue.Length != x509Extension.extnValue.Length)
{
return false;
}
for (int i = 0; i < this.extnValue.Length; i++)
{
if (this.extnValue[i] != x509Extension.extnValue[i])
{
return false;
}
}
return true;
}
// Token: 0x0600036F RID: 879 RVA: 0x00017ACC File Offset: 0x00015CCC
public byte[] GetBytes()
{
return this.ASN1.GetBytes();
}
// Token: 0x06000370 RID: 880 RVA: 0x00017ADC File Offset: 0x00015CDC
public override int GetHashCode()
{
return this.extnOid.GetHashCode();
}
// Token: 0x06000371 RID: 881 RVA: 0x00017AEC File Offset: 0x00015CEC
private void WriteLine(StringBuilder sb, int n, int pos)
{
byte[] value = this.extnValue.Value;
int num = pos;
for (int i = 0; i < 8; i++)
{
if (i < n)
{
sb.Append(value[num++].ToString("X2", CultureInfo.InvariantCulture));
sb.Append(" ");
}
else
{
sb.Append(" ");
}
}
sb.Append(" ");
num = pos;
for (int j = 0; j < n; j++)
{
byte b = value[num++];
if (b < 32)
{
sb.Append(".");
}
else
{
sb.Append(Convert.ToChar(b));
}
}
sb.Append(Environment.NewLine);
}
// Token: 0x06000372 RID: 882 RVA: 0x00017BBC File Offset: 0x00015DBC
public override string ToString()
{
StringBuilder stringBuilder = new StringBuilder();
int num = this.extnValue.Length >> 3;
int num2 = this.extnValue.Length - (num << 3);
int num3 = 0;
for (int i = 0; i < num; i++)
{
this.WriteLine(stringBuilder, 8, num3);
num3 += 8;
}
this.WriteLine(stringBuilder, num2, num3);
return stringBuilder.ToString();
}
// Token: 0x0400019F RID: 415
protected string extnOid;
// Token: 0x040001A0 RID: 416
protected bool extnCritical;
// Token: 0x040001A1 RID: 417
protected ASN1 extnValue;
}
}
@@ -0,0 +1,222 @@
using System;
using System.Collections;
namespace Mono.Security.X509
{
// Token: 0x0200004C RID: 76
public sealed class X509ExtensionCollection : CollectionBase, IEnumerable
{
// Token: 0x06000373 RID: 883 RVA: 0x00017C24 File Offset: 0x00015E24
public X509ExtensionCollection()
{
}
// Token: 0x06000374 RID: 884 RVA: 0x00017C2C File Offset: 0x00015E2C
public X509ExtensionCollection(ASN1 asn1)
: this()
{
this.readOnly = true;
if (asn1 == null)
{
return;
}
if (asn1.Tag != 48)
{
throw new Exception("Invalid extensions format");
}
for (int i = 0; i < asn1.Count; i++)
{
X509Extension x509Extension = new X509Extension(asn1[i]);
base.InnerList.Add(x509Extension);
}
}
// Token: 0x06000375 RID: 885 RVA: 0x00017C98 File Offset: 0x00015E98
IEnumerator IEnumerable.GetEnumerator()
{
return base.InnerList.GetEnumerator();
}
// Token: 0x06000376 RID: 886 RVA: 0x00017CA8 File Offset: 0x00015EA8
public int Add(X509Extension extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
if (this.readOnly)
{
throw new NotSupportedException("Extensions are read only");
}
return base.InnerList.Add(extension);
}
// Token: 0x06000377 RID: 887 RVA: 0x00017CE0 File Offset: 0x00015EE0
public void AddRange(X509Extension[] extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
if (this.readOnly)
{
throw new NotSupportedException("Extensions are read only");
}
for (int i = 0; i < extension.Length; i++)
{
base.InnerList.Add(extension[i]);
}
}
// Token: 0x06000378 RID: 888 RVA: 0x00017D38 File Offset: 0x00015F38
public void AddRange(X509ExtensionCollection collection)
{
if (collection == null)
{
throw new ArgumentNullException("collection");
}
if (this.readOnly)
{
throw new NotSupportedException("Extensions are read only");
}
for (int i = 0; i < collection.InnerList.Count; i++)
{
base.InnerList.Add(collection[i]);
}
}
// Token: 0x06000379 RID: 889 RVA: 0x00017D9C File Offset: 0x00015F9C
public bool Contains(X509Extension extension)
{
return this.IndexOf(extension) != -1;
}
// Token: 0x0600037A RID: 890 RVA: 0x00017DAC File Offset: 0x00015FAC
public bool Contains(string oid)
{
return this.IndexOf(oid) != -1;
}
// Token: 0x0600037B RID: 891 RVA: 0x00017DBC File Offset: 0x00015FBC
public void CopyTo(X509Extension[] extensions, int index)
{
if (extensions == null)
{
throw new ArgumentNullException("extensions");
}
base.InnerList.CopyTo(extensions, index);
}
// Token: 0x0600037C RID: 892 RVA: 0x00017DDC File Offset: 0x00015FDC
public int IndexOf(X509Extension extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
for (int i = 0; i < base.InnerList.Count; i++)
{
X509Extension x509Extension = (X509Extension)base.InnerList[i];
if (x509Extension.Equals(extension))
{
return i;
}
}
return -1;
}
// Token: 0x0600037D RID: 893 RVA: 0x00017E38 File Offset: 0x00016038
public int IndexOf(string oid)
{
if (oid == null)
{
throw new ArgumentNullException("oid");
}
for (int i = 0; i < base.InnerList.Count; i++)
{
X509Extension x509Extension = (X509Extension)base.InnerList[i];
if (x509Extension.Oid == oid)
{
return i;
}
}
return -1;
}
// Token: 0x0600037E RID: 894 RVA: 0x00017E98 File Offset: 0x00016098
public void Insert(int index, X509Extension extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
base.InnerList.Insert(index, extension);
}
// Token: 0x0600037F RID: 895 RVA: 0x00017EB8 File Offset: 0x000160B8
public void Remove(X509Extension extension)
{
if (extension == null)
{
throw new ArgumentNullException("extension");
}
base.InnerList.Remove(extension);
}
// Token: 0x06000380 RID: 896 RVA: 0x00017ED8 File Offset: 0x000160D8
public void Remove(string oid)
{
if (oid == null)
{
throw new ArgumentNullException("oid");
}
int num = this.IndexOf(oid);
if (num != -1)
{
base.InnerList.RemoveAt(num);
}
}
// Token: 0x170000C4 RID: 196
public X509Extension this[int index]
{
get
{
return (X509Extension)base.InnerList[index];
}
}
// Token: 0x170000C5 RID: 197
public X509Extension this[string oid]
{
get
{
int num = this.IndexOf(oid);
if (num == -1)
{
return null;
}
return (X509Extension)base.InnerList[num];
}
}
// Token: 0x06000383 RID: 899 RVA: 0x00017F58 File Offset: 0x00016158
public byte[] GetBytes()
{
if (base.InnerList.Count < 1)
{
return null;
}
ASN1 asn = new ASN1(48);
for (int i = 0; i < base.InnerList.Count; i++)
{
X509Extension x509Extension = (X509Extension)base.InnerList[i];
asn.Add(x509Extension.ASN1);
}
return asn.GetBytes();
}
// Token: 0x040001A2 RID: 418
private bool readOnly;
}
}
+315
View File
@@ -0,0 +1,315 @@
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Text;
using Mono.Security.X509.Extensions;
namespace Mono.Security.X509
{
// Token: 0x0200004D RID: 77
public class X509Store
{
// Token: 0x06000384 RID: 900 RVA: 0x00017FC4 File Offset: 0x000161C4
internal X509Store(string path, bool crl)
{
this._storePath = path;
this._crl = crl;
}
// Token: 0x170000C6 RID: 198
// (get) Token: 0x06000385 RID: 901 RVA: 0x00017FDC File Offset: 0x000161DC
public X509CertificateCollection Certificates
{
get
{
if (this._certificates == null)
{
this._certificates = this.BuildCertificatesCollection(this._storePath);
}
return this._certificates;
}
}
// Token: 0x170000C7 RID: 199
// (get) Token: 0x06000386 RID: 902 RVA: 0x00018004 File Offset: 0x00016204
public ArrayList Crls
{
get
{
if (!this._crl)
{
this._crls = new ArrayList();
}
if (this._crls == null)
{
this._crls = this.BuildCrlsCollection(this._storePath);
}
return this._crls;
}
}
// Token: 0x170000C8 RID: 200
// (get) Token: 0x06000387 RID: 903 RVA: 0x00018040 File Offset: 0x00016240
public string Name
{
get
{
if (this._name == null)
{
int num = this._storePath.LastIndexOf(Path.DirectorySeparatorChar);
this._name = this._storePath.Substring(num + 1);
}
return this._name;
}
}
// Token: 0x06000388 RID: 904 RVA: 0x00018084 File Offset: 0x00016284
public void Clear()
{
if (this._certificates != null)
{
this._certificates.Clear();
}
this._certificates = null;
if (this._crls != null)
{
this._crls.Clear();
}
this._crls = null;
}
// Token: 0x06000389 RID: 905 RVA: 0x000180CC File Offset: 0x000162CC
public void Import(X509Certificate certificate)
{
this.CheckStore(this._storePath, true);
string text = Path.Combine(this._storePath, this.GetUniqueName(certificate));
if (!File.Exists(text))
{
using (FileStream fileStream = File.Create(text))
{
byte[] rawData = certificate.RawData;
fileStream.Write(rawData, 0, rawData.Length);
fileStream.Close();
}
}
}
// Token: 0x0600038A RID: 906 RVA: 0x00018154 File Offset: 0x00016354
public void Import(X509Crl crl)
{
this.CheckStore(this._storePath, true);
string text = Path.Combine(this._storePath, this.GetUniqueName(crl));
if (!File.Exists(text))
{
using (FileStream fileStream = File.Create(text))
{
byte[] rawData = crl.RawData;
fileStream.Write(rawData, 0, rawData.Length);
}
}
}
// Token: 0x0600038B RID: 907 RVA: 0x000181D4 File Offset: 0x000163D4
public void Remove(X509Certificate certificate)
{
string text = Path.Combine(this._storePath, this.GetUniqueName(certificate));
if (File.Exists(text))
{
File.Delete(text);
}
}
// Token: 0x0600038C RID: 908 RVA: 0x00018208 File Offset: 0x00016408
public void Remove(X509Crl crl)
{
string text = Path.Combine(this._storePath, this.GetUniqueName(crl));
if (File.Exists(text))
{
File.Delete(text);
}
}
// Token: 0x0600038D RID: 909 RVA: 0x0001823C File Offset: 0x0001643C
private string GetUniqueName(X509Certificate certificate)
{
byte[] array = this.GetUniqueName(certificate.Extensions);
string text;
if (array == null)
{
text = "tbp";
array = certificate.Hash;
}
else
{
text = "ski";
}
return this.GetUniqueName(text, array, ".cer");
}
// Token: 0x0600038E RID: 910 RVA: 0x00018284 File Offset: 0x00016484
private string GetUniqueName(X509Crl crl)
{
byte[] array = this.GetUniqueName(crl.Extensions);
string text;
if (array == null)
{
text = "tbp";
array = crl.Hash;
}
else
{
text = "ski";
}
return this.GetUniqueName(text, array, ".crl");
}
// Token: 0x0600038F RID: 911 RVA: 0x000182CC File Offset: 0x000164CC
private byte[] GetUniqueName(X509ExtensionCollection extensions)
{
X509Extension x509Extension = extensions["2.5.29.14"];
if (x509Extension == null)
{
return null;
}
SubjectKeyIdentifierExtension subjectKeyIdentifierExtension = new SubjectKeyIdentifierExtension(x509Extension);
return subjectKeyIdentifierExtension.Identifier;
}
// Token: 0x06000390 RID: 912 RVA: 0x000182FC File Offset: 0x000164FC
private string GetUniqueName(string method, byte[] name, string fileExtension)
{
StringBuilder stringBuilder = new StringBuilder(method);
stringBuilder.Append("-");
foreach (byte b in name)
{
stringBuilder.Append(b.ToString("X2", CultureInfo.InvariantCulture));
}
stringBuilder.Append(fileExtension);
return stringBuilder.ToString();
}
// Token: 0x06000391 RID: 913 RVA: 0x0001835C File Offset: 0x0001655C
private byte[] Load(string filename)
{
byte[] array = null;
using (FileStream fileStream = File.OpenRead(filename))
{
array = new byte[fileStream.Length];
fileStream.Read(array, 0, array.Length);
fileStream.Close();
}
return array;
}
// Token: 0x06000392 RID: 914 RVA: 0x000183C0 File Offset: 0x000165C0
private X509Certificate LoadCertificate(string filename)
{
byte[] array = this.Load(filename);
return new X509Certificate(array);
}
// Token: 0x06000393 RID: 915 RVA: 0x000183E0 File Offset: 0x000165E0
private X509Crl LoadCrl(string filename)
{
byte[] array = this.Load(filename);
return new X509Crl(array);
}
// Token: 0x06000394 RID: 916 RVA: 0x00018400 File Offset: 0x00016600
private bool CheckStore(string path, bool throwException)
{
bool flag;
try
{
if (Directory.Exists(path))
{
flag = true;
}
else
{
Directory.CreateDirectory(path);
flag = Directory.Exists(path);
}
}
catch
{
if (throwException)
{
throw;
}
flag = false;
}
return flag;
}
// Token: 0x06000395 RID: 917 RVA: 0x0001846C File Offset: 0x0001666C
private X509CertificateCollection BuildCertificatesCollection(string storeName)
{
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
string text = Path.Combine(this._storePath, storeName);
if (!this.CheckStore(text, false))
{
return x509CertificateCollection;
}
string[] files = Directory.GetFiles(text, "*.cer");
if (files != null && files.Length > 0)
{
foreach (string text2 in files)
{
try
{
X509Certificate x509Certificate = this.LoadCertificate(text2);
x509CertificateCollection.Add(x509Certificate);
}
catch
{
}
}
}
return x509CertificateCollection;
}
// Token: 0x06000396 RID: 918 RVA: 0x00018514 File Offset: 0x00016714
private ArrayList BuildCrlsCollection(string storeName)
{
ArrayList arrayList = new ArrayList();
string text = Path.Combine(this._storePath, storeName);
if (!this.CheckStore(text, false))
{
return arrayList;
}
string[] files = Directory.GetFiles(text, "*.crl");
if (files != null && files.Length > 0)
{
foreach (string text2 in files)
{
try
{
X509Crl x509Crl = this.LoadCrl(text2);
arrayList.Add(x509Crl);
}
catch
{
}
}
}
return arrayList;
}
// Token: 0x040001A3 RID: 419
private string _storePath;
// Token: 0x040001A4 RID: 420
private X509CertificateCollection _certificates;
// Token: 0x040001A5 RID: 421
private ArrayList _crls;
// Token: 0x040001A6 RID: 422
private bool _crl;
// Token: 0x040001A7 RID: 423
private string _name;
}
}
@@ -0,0 +1,118 @@
using System;
using System.Collections;
using System.IO;
namespace Mono.Security.X509
{
// Token: 0x0200004E RID: 78
public sealed class X509StoreManager
{
// Token: 0x06000397 RID: 919 RVA: 0x000185BC File Offset: 0x000167BC
private X509StoreManager()
{
}
// Token: 0x170000C9 RID: 201
// (get) Token: 0x06000398 RID: 920 RVA: 0x000185C4 File Offset: 0x000167C4
public static X509Stores CurrentUser
{
get
{
if (X509StoreManager._userStore == null)
{
string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".mono");
text = Path.Combine(text, "certs");
X509StoreManager._userStore = new X509Stores(text);
}
return X509StoreManager._userStore;
}
}
// Token: 0x170000CA RID: 202
// (get) Token: 0x06000399 RID: 921 RVA: 0x0001860C File Offset: 0x0001680C
public static X509Stores LocalMachine
{
get
{
if (X509StoreManager._machineStore == null)
{
string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ".mono");
text = Path.Combine(text, "certs");
X509StoreManager._machineStore = new X509Stores(text);
}
return X509StoreManager._machineStore;
}
}
// Token: 0x170000CB RID: 203
// (get) Token: 0x0600039A RID: 922 RVA: 0x00018654 File Offset: 0x00016854
public static X509CertificateCollection IntermediateCACertificates
{
get
{
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Certificates);
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Certificates);
return x509CertificateCollection;
}
}
// Token: 0x170000CC RID: 204
// (get) Token: 0x0600039B RID: 923 RVA: 0x00018694 File Offset: 0x00016894
public static ArrayList IntermediateCACrls
{
get
{
ArrayList arrayList = new ArrayList();
arrayList.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Crls);
arrayList.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Crls);
return arrayList;
}
}
// Token: 0x170000CD RID: 205
// (get) Token: 0x0600039C RID: 924 RVA: 0x000186D4 File Offset: 0x000168D4
public static X509CertificateCollection TrustedRootCertificates
{
get
{
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Certificates);
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Certificates);
return x509CertificateCollection;
}
}
// Token: 0x170000CE RID: 206
// (get) Token: 0x0600039D RID: 925 RVA: 0x00018714 File Offset: 0x00016914
public static ArrayList TrustedRootCACrls
{
get
{
ArrayList arrayList = new ArrayList();
arrayList.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Crls);
arrayList.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Crls);
return arrayList;
}
}
// Token: 0x170000CF RID: 207
// (get) Token: 0x0600039E RID: 926 RVA: 0x00018754 File Offset: 0x00016954
public static X509CertificateCollection UntrustedCertificates
{
get
{
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.Untrusted.Certificates);
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.Untrusted.Certificates);
return x509CertificateCollection;
}
}
// Token: 0x040001A8 RID: 424
private static X509Stores _userStore;
// Token: 0x040001A9 RID: 425
private static X509Stores _machineStore;
}
}
+172
View File
@@ -0,0 +1,172 @@
using System;
using System.IO;
namespace Mono.Security.X509
{
// Token: 0x0200004F RID: 79
public class X509Stores
{
// Token: 0x0600039F RID: 927 RVA: 0x00018794 File Offset: 0x00016994
internal X509Stores(string path)
{
this._storePath = path;
}
// Token: 0x170000D0 RID: 208
// (get) Token: 0x060003A0 RID: 928 RVA: 0x000187A4 File Offset: 0x000169A4
public X509Store Personal
{
get
{
if (this._personal == null)
{
string text = Path.Combine(this._storePath, "My");
this._personal = new X509Store(text, false);
}
return this._personal;
}
}
// Token: 0x170000D1 RID: 209
// (get) Token: 0x060003A1 RID: 929 RVA: 0x000187E0 File Offset: 0x000169E0
public X509Store OtherPeople
{
get
{
if (this._other == null)
{
string text = Path.Combine(this._storePath, "AddressBook");
this._other = new X509Store(text, false);
}
return this._other;
}
}
// Token: 0x170000D2 RID: 210
// (get) Token: 0x060003A2 RID: 930 RVA: 0x0001881C File Offset: 0x00016A1C
public X509Store IntermediateCA
{
get
{
if (this._intermediate == null)
{
string text = Path.Combine(this._storePath, "CA");
this._intermediate = new X509Store(text, true);
}
return this._intermediate;
}
}
// Token: 0x170000D3 RID: 211
// (get) Token: 0x060003A3 RID: 931 RVA: 0x00018858 File Offset: 0x00016A58
public X509Store TrustedRoot
{
get
{
if (this._trusted == null)
{
string text = Path.Combine(this._storePath, "Trust");
this._trusted = new X509Store(text, true);
}
return this._trusted;
}
}
// Token: 0x170000D4 RID: 212
// (get) Token: 0x060003A4 RID: 932 RVA: 0x00018894 File Offset: 0x00016A94
public X509Store Untrusted
{
get
{
if (this._untrusted == null)
{
string text = Path.Combine(this._storePath, "Disallowed");
this._untrusted = new X509Store(text, false);
}
return this._untrusted;
}
}
// Token: 0x060003A5 RID: 933 RVA: 0x000188D0 File Offset: 0x00016AD0
public void Clear()
{
if (this._personal != null)
{
this._personal.Clear();
}
this._personal = null;
if (this._other != null)
{
this._other.Clear();
}
this._other = null;
if (this._intermediate != null)
{
this._intermediate.Clear();
}
this._intermediate = null;
if (this._trusted != null)
{
this._trusted.Clear();
}
this._trusted = null;
if (this._untrusted != null)
{
this._untrusted.Clear();
}
this._untrusted = null;
}
// Token: 0x060003A6 RID: 934 RVA: 0x00018970 File Offset: 0x00016B70
public X509Store Open(string storeName, bool create)
{
if (storeName == null)
{
throw new ArgumentNullException("storeName");
}
string text = Path.Combine(this._storePath, storeName);
if (!create && !Directory.Exists(text))
{
return null;
}
return new X509Store(text, true);
}
// Token: 0x040001AA RID: 426
private string _storePath;
// Token: 0x040001AB RID: 427
private X509Store _personal;
// Token: 0x040001AC RID: 428
private X509Store _other;
// Token: 0x040001AD RID: 429
private X509Store _intermediate;
// Token: 0x040001AE RID: 430
private X509Store _trusted;
// Token: 0x040001AF RID: 431
private X509Store _untrusted;
// Token: 0x02000050 RID: 80
public class Names
{
// Token: 0x040001B0 RID: 432
public const string Personal = "My";
// Token: 0x040001B1 RID: 433
public const string OtherPeople = "AddressBook";
// Token: 0x040001B2 RID: 434
public const string IntermediateCA = "CA";
// Token: 0x040001B3 RID: 435
public const string TrustedRoot = "Trust";
// Token: 0x040001B4 RID: 436
public const string Untrusted = "Disallowed";
}
}
}
+306
View File
@@ -0,0 +1,306 @@
using System;
using System.Text;
namespace Mono.Security.X509
{
// Token: 0x02000051 RID: 81
public class X520
{
// Token: 0x02000052 RID: 82
public abstract class AttributeTypeAndValue
{
// Token: 0x060003A9 RID: 937 RVA: 0x000189C8 File Offset: 0x00016BC8
protected AttributeTypeAndValue(string oid, int upperBound)
{
this.oid = oid;
this.upperBound = upperBound;
this.encoding = byte.MaxValue;
}
// Token: 0x060003AA RID: 938 RVA: 0x000189EC File Offset: 0x00016BEC
protected AttributeTypeAndValue(string oid, int upperBound, byte encoding)
{
this.oid = oid;
this.upperBound = upperBound;
this.encoding = encoding;
}
// Token: 0x170000D5 RID: 213
// (get) Token: 0x060003AB RID: 939 RVA: 0x00018A0C File Offset: 0x00016C0C
// (set) Token: 0x060003AC RID: 940 RVA: 0x00018A14 File Offset: 0x00016C14
public string Value
{
get
{
return this.attrValue;
}
set
{
if (this.attrValue != null && this.attrValue.Length > this.upperBound)
{
string text = Locale.GetText("Value length bigger than upperbound ({0}).");
throw new FormatException(string.Format(text, this.upperBound));
}
this.attrValue = value;
}
}
// Token: 0x170000D6 RID: 214
// (get) Token: 0x060003AD RID: 941 RVA: 0x00018A6C File Offset: 0x00016C6C
public ASN1 ASN1
{
get
{
return this.GetASN1();
}
}
// Token: 0x060003AE RID: 942 RVA: 0x00018A74 File Offset: 0x00016C74
internal ASN1 GetASN1(byte encoding)
{
byte b = encoding;
if (b == 255)
{
b = this.SelectBestEncoding();
}
ASN1 asn = new ASN1(48);
asn.Add(ASN1Convert.FromOid(this.oid));
byte b2 = b;
switch (b2)
{
case 19:
asn.Add(new ASN1(19, Encoding.ASCII.GetBytes(this.attrValue)));
break;
default:
if (b2 == 30)
{
asn.Add(new ASN1(30, Encoding.BigEndianUnicode.GetBytes(this.attrValue)));
}
break;
case 22:
asn.Add(new ASN1(22, Encoding.ASCII.GetBytes(this.attrValue)));
break;
}
return asn;
}
// Token: 0x060003AF RID: 943 RVA: 0x00018B44 File Offset: 0x00016D44
internal ASN1 GetASN1()
{
return this.GetASN1(this.encoding);
}
// Token: 0x060003B0 RID: 944 RVA: 0x00018B54 File Offset: 0x00016D54
public byte[] GetBytes(byte encoding)
{
return this.GetASN1(encoding).GetBytes();
}
// Token: 0x060003B1 RID: 945 RVA: 0x00018B64 File Offset: 0x00016D64
public byte[] GetBytes()
{
return this.GetASN1().GetBytes();
}
// Token: 0x060003B2 RID: 946 RVA: 0x00018B74 File Offset: 0x00016D74
private byte SelectBestEncoding()
{
foreach (char c in this.attrValue)
{
char c2 = c;
if (c2 == '@' || c2 == '_')
{
return 30;
}
if (c > '\u007f')
{
return 30;
}
}
return 19;
}
// Token: 0x040001B5 RID: 437
private string oid;
// Token: 0x040001B6 RID: 438
private string attrValue;
// Token: 0x040001B7 RID: 439
private int upperBound;
// Token: 0x040001B8 RID: 440
private byte encoding;
}
// Token: 0x02000053 RID: 83
public class Name : X520.AttributeTypeAndValue
{
// Token: 0x060003B3 RID: 947 RVA: 0x00018BD4 File Offset: 0x00016DD4
public Name()
: base("2.5.4.41", 32768)
{
}
}
// Token: 0x02000054 RID: 84
public class CommonName : X520.AttributeTypeAndValue
{
// Token: 0x060003B4 RID: 948 RVA: 0x00018BE8 File Offset: 0x00016DE8
public CommonName()
: base("2.5.4.3", 64)
{
}
}
// Token: 0x02000055 RID: 85
public class SerialNumber : X520.AttributeTypeAndValue
{
// Token: 0x060003B5 RID: 949 RVA: 0x00018BF8 File Offset: 0x00016DF8
public SerialNumber()
: base("2.5.4.5", 64, 19)
{
}
}
// Token: 0x02000056 RID: 86
public class LocalityName : X520.AttributeTypeAndValue
{
// Token: 0x060003B6 RID: 950 RVA: 0x00018C0C File Offset: 0x00016E0C
public LocalityName()
: base("2.5.4.7", 128)
{
}
}
// Token: 0x02000057 RID: 87
public class StateOrProvinceName : X520.AttributeTypeAndValue
{
// Token: 0x060003B7 RID: 951 RVA: 0x00018C20 File Offset: 0x00016E20
public StateOrProvinceName()
: base("2.5.4.8", 128)
{
}
}
// Token: 0x02000058 RID: 88
public class OrganizationName : X520.AttributeTypeAndValue
{
// Token: 0x060003B8 RID: 952 RVA: 0x00018C34 File Offset: 0x00016E34
public OrganizationName()
: base("2.5.4.10", 64)
{
}
}
// Token: 0x02000059 RID: 89
public class OrganizationalUnitName : X520.AttributeTypeAndValue
{
// Token: 0x060003B9 RID: 953 RVA: 0x00018C44 File Offset: 0x00016E44
public OrganizationalUnitName()
: base("2.5.4.11", 64)
{
}
}
// Token: 0x0200005A RID: 90
public class EmailAddress : X520.AttributeTypeAndValue
{
// Token: 0x060003BA RID: 954 RVA: 0x00018C54 File Offset: 0x00016E54
public EmailAddress()
: base("1.2.840.113549.1.9.1", 128, 22)
{
}
}
// Token: 0x0200005B RID: 91
public class DomainComponent : X520.AttributeTypeAndValue
{
// Token: 0x060003BB RID: 955 RVA: 0x00018C68 File Offset: 0x00016E68
public DomainComponent()
: base("0.9.2342.19200300.100.1.25", int.MaxValue, 22)
{
}
}
// Token: 0x0200005C RID: 92
public class UserId : X520.AttributeTypeAndValue
{
// Token: 0x060003BC RID: 956 RVA: 0x00018C7C File Offset: 0x00016E7C
public UserId()
: base("0.9.2342.19200300.100.1.1", 256)
{
}
}
// Token: 0x0200005D RID: 93
public class Oid : X520.AttributeTypeAndValue
{
// Token: 0x060003BD RID: 957 RVA: 0x00018C90 File Offset: 0x00016E90
public Oid(string oid)
: base(oid, int.MaxValue)
{
}
}
// Token: 0x0200005E RID: 94
public class Title : X520.AttributeTypeAndValue
{
// Token: 0x060003BE RID: 958 RVA: 0x00018CA0 File Offset: 0x00016EA0
public Title()
: base("2.5.4.12", 64)
{
}
}
// Token: 0x0200005F RID: 95
public class CountryName : X520.AttributeTypeAndValue
{
// Token: 0x060003BF RID: 959 RVA: 0x00018CB0 File Offset: 0x00016EB0
public CountryName()
: base("2.5.4.6", 2, 19)
{
}
}
// Token: 0x02000060 RID: 96
public class DnQualifier : X520.AttributeTypeAndValue
{
// Token: 0x060003C0 RID: 960 RVA: 0x00018CC0 File Offset: 0x00016EC0
public DnQualifier()
: base("2.5.4.46", 2, 19)
{
}
}
// Token: 0x02000061 RID: 97
public class Surname : X520.AttributeTypeAndValue
{
// Token: 0x060003C1 RID: 961 RVA: 0x00018CD0 File Offset: 0x00016ED0
public Surname()
: base("2.5.4.4", 32768)
{
}
}
// Token: 0x02000062 RID: 98
public class GivenName : X520.AttributeTypeAndValue
{
// Token: 0x060003C2 RID: 962 RVA: 0x00018CE4 File Offset: 0x00016EE4
public GivenName()
: base("2.5.4.42", 16)
{
}
}
// Token: 0x02000063 RID: 99
public class Initial : X520.AttributeTypeAndValue
{
// Token: 0x060003C3 RID: 963 RVA: 0x00018CF4 File Offset: 0x00016EF4
public Initial()
: base("2.5.4.43", 5)
{
}
}
}
}