scripts
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000AF RID: 175
|
||||
internal class BasicConstraintsExtension : X509Extension
|
||||
{
|
||||
// Token: 0x06000994 RID: 2452 RVA: 0x00027844 File Offset: 0x00025A44
|
||||
public BasicConstraintsExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.19";
|
||||
this.pathLenConstraint = -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000995 RID: 2453 RVA: 0x00027860 File Offset: 0x00025A60
|
||||
public BasicConstraintsExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000996 RID: 2454 RVA: 0x0002786C File Offset: 0x00025A6C
|
||||
public BasicConstraintsExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000997 RID: 2455 RVA: 0x00027878 File Offset: 0x00025A78
|
||||
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: 0x06000998 RID: 2456 RVA: 0x0002791C File Offset: 0x00025B1C
|
||||
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: 0x17000116 RID: 278
|
||||
// (get) Token: 0x06000999 RID: 2457 RVA: 0x0002799C File Offset: 0x00025B9C
|
||||
// (set) Token: 0x0600099A RID: 2458 RVA: 0x000279A4 File Offset: 0x00025BA4
|
||||
public bool CertificateAuthority
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.cA;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.cA = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000117 RID: 279
|
||||
// (get) Token: 0x0600099B RID: 2459 RVA: 0x000279B0 File Offset: 0x00025BB0
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Basic Constraints";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000118 RID: 280
|
||||
// (get) Token: 0x0600099C RID: 2460 RVA: 0x000279B8 File Offset: 0x00025BB8
|
||||
// (set) Token: 0x0600099D RID: 2461 RVA: 0x000279C0 File Offset: 0x00025BC0
|
||||
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: 0x0600099E RID: 2462 RVA: 0x000279FC File Offset: 0x00025BFC
|
||||
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: 0x0400022A RID: 554
|
||||
public const int NoPathLengthConstraint = -1;
|
||||
|
||||
// Token: 0x0400022B RID: 555
|
||||
private bool cA;
|
||||
|
||||
// Token: 0x0400022C RID: 556
|
||||
private int pathLenConstraint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B1 RID: 177
|
||||
internal class KeyUsageExtension : X509Extension
|
||||
{
|
||||
// Token: 0x0600099F RID: 2463 RVA: 0x00027A9C File Offset: 0x00025C9C
|
||||
public KeyUsageExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009A0 RID: 2464 RVA: 0x00027AA8 File Offset: 0x00025CA8
|
||||
public KeyUsageExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009A1 RID: 2465 RVA: 0x00027AB4 File Offset: 0x00025CB4
|
||||
public KeyUsageExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.15";
|
||||
}
|
||||
|
||||
// Token: 0x060009A2 RID: 2466 RVA: 0x00027AC8 File Offset: 0x00025CC8
|
||||
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: 0x060009A3 RID: 2467 RVA: 0x00027B30 File Offset: 0x00025D30
|
||||
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: 0x17000119 RID: 281
|
||||
// (get) Token: 0x060009A4 RID: 2468 RVA: 0x00027C20 File Offset: 0x00025E20
|
||||
// (set) Token: 0x060009A5 RID: 2469 RVA: 0x00027C28 File Offset: 0x00025E28
|
||||
public KeyUsages KeyUsage
|
||||
{
|
||||
get
|
||||
{
|
||||
return (KeyUsages)this.kubits;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.kubits = Convert.ToInt32(value, CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011A RID: 282
|
||||
// (get) Token: 0x060009A6 RID: 2470 RVA: 0x00027C40 File Offset: 0x00025E40
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Key Usage";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009A7 RID: 2471 RVA: 0x00027C48 File Offset: 0x00025E48
|
||||
public bool Support(KeyUsages usage)
|
||||
{
|
||||
int num = Convert.ToInt32(usage, CultureInfo.InvariantCulture);
|
||||
return (num & this.kubits) == num;
|
||||
}
|
||||
|
||||
// Token: 0x060009A8 RID: 2472 RVA: 0x00027C74 File Offset: 0x00025E74
|
||||
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: 0x04000238 RID: 568
|
||||
private int kubits;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B0 RID: 176
|
||||
[Flags]
|
||||
internal enum KeyUsages
|
||||
{
|
||||
// Token: 0x0400022E RID: 558
|
||||
digitalSignature = 128,
|
||||
// Token: 0x0400022F RID: 559
|
||||
nonRepudiation = 64,
|
||||
// Token: 0x04000230 RID: 560
|
||||
keyEncipherment = 32,
|
||||
// Token: 0x04000231 RID: 561
|
||||
dataEncipherment = 16,
|
||||
// Token: 0x04000232 RID: 562
|
||||
keyAgreement = 8,
|
||||
// Token: 0x04000233 RID: 563
|
||||
keyCertSign = 4,
|
||||
// Token: 0x04000234 RID: 564
|
||||
cRLSign = 2,
|
||||
// Token: 0x04000235 RID: 565
|
||||
encipherOnly = 1,
|
||||
// Token: 0x04000236 RID: 566
|
||||
decipherOnly = 2048,
|
||||
// Token: 0x04000237 RID: 567
|
||||
none = 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509.Extensions
|
||||
{
|
||||
// Token: 0x020000B2 RID: 178
|
||||
internal class SubjectKeyIdentifierExtension : X509Extension
|
||||
{
|
||||
// Token: 0x060009A9 RID: 2473 RVA: 0x00027E70 File Offset: 0x00026070
|
||||
public SubjectKeyIdentifierExtension()
|
||||
{
|
||||
this.extnOid = "2.5.29.14";
|
||||
}
|
||||
|
||||
// Token: 0x060009AA RID: 2474 RVA: 0x00027E84 File Offset: 0x00026084
|
||||
public SubjectKeyIdentifierExtension(ASN1 asn1)
|
||||
: base(asn1)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009AB RID: 2475 RVA: 0x00027E90 File Offset: 0x00026090
|
||||
public SubjectKeyIdentifierExtension(X509Extension extension)
|
||||
: base(extension)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009AC RID: 2476 RVA: 0x00027E9C File Offset: 0x0002609C
|
||||
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: 0x1700011B RID: 283
|
||||
// (get) Token: 0x060009AD RID: 2477 RVA: 0x00027EE0 File Offset: 0x000260E0
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Subject Key Identifier";
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011C RID: 284
|
||||
// (get) Token: 0x060009AE RID: 2478 RVA: 0x00027EE8 File Offset: 0x000260E8
|
||||
public byte[] Identifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.ski == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.ski.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009AF RID: 2479 RVA: 0x00027F08 File Offset: 0x00026108
|
||||
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: 0x04000239 RID: 569
|
||||
private byte[] ski;
|
||||
}
|
||||
}
|
||||
@@ -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: 0x020000B6 RID: 182
|
||||
internal class PKCS12 : ICloneable
|
||||
{
|
||||
// Token: 0x060009B5 RID: 2485 RVA: 0x00027FB8 File Offset: 0x000261B8
|
||||
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: 0x060009B6 RID: 2486 RVA: 0x00028018 File Offset: 0x00026218
|
||||
public PKCS12(byte[] data)
|
||||
: this()
|
||||
{
|
||||
this.Password = null;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009B7 RID: 2487 RVA: 0x00028030 File Offset: 0x00026230
|
||||
public PKCS12(byte[] data, string password)
|
||||
: this()
|
||||
{
|
||||
this.Password = password;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009B8 RID: 2488 RVA: 0x00028048 File Offset: 0x00026248
|
||||
public PKCS12(byte[] data, byte[] password)
|
||||
: this()
|
||||
{
|
||||
this._password = password;
|
||||
this.Decode(data);
|
||||
}
|
||||
|
||||
// Token: 0x060009BA RID: 2490 RVA: 0x00028078 File Offset: 0x00026278
|
||||
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$map8 == null)
|
||||
{
|
||||
PKCS12.<>f__switch$map8 = 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$map8.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: 0x060009BB RID: 2491 RVA: 0x000283A8 File Offset: 0x000265A8
|
||||
~PKCS12()
|
||||
{
|
||||
if (this._password != null)
|
||||
{
|
||||
Array.Clear(this._password, 0, this._password.Length);
|
||||
}
|
||||
this._password = null;
|
||||
}
|
||||
|
||||
// Token: 0x1700011F RID: 287
|
||||
// (set) Token: 0x060009BC RID: 2492 RVA: 0x00028404 File Offset: 0x00026604
|
||||
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: 0x17000120 RID: 288
|
||||
// (get) Token: 0x060009BD RID: 2493 RVA: 0x00028494 File Offset: 0x00026694
|
||||
// (set) Token: 0x060009BE RID: 2494 RVA: 0x0002849C File Offset: 0x0002669C
|
||||
public int IterationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iterations;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._iterations = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000121 RID: 289
|
||||
// (get) Token: 0x060009BF RID: 2495 RVA: 0x000284A8 File Offset: 0x000266A8
|
||||
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: 0x17000122 RID: 290
|
||||
// (get) Token: 0x060009C0 RID: 2496 RVA: 0x000286C0 File Offset: 0x000268C0
|
||||
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: 0x17000123 RID: 291
|
||||
// (get) Token: 0x060009C1 RID: 2497 RVA: 0x00028790 File Offset: 0x00026990
|
||||
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: 0x17000124 RID: 292
|
||||
// (get) Token: 0x060009C2 RID: 2498 RVA: 0x00028874 File Offset: 0x00026A74
|
||||
internal RandomNumberGenerator RNG
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._rng == null)
|
||||
{
|
||||
this._rng = RandomNumberGenerator.Create();
|
||||
}
|
||||
return this._rng;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009C3 RID: 2499 RVA: 0x00028894 File Offset: 0x00026A94
|
||||
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: 0x060009C4 RID: 2500 RVA: 0x000288D4 File Offset: 0x00026AD4
|
||||
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$map9 == null)
|
||||
{
|
||||
PKCS12.<>f__switch$map9 = 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$map9.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: 0x060009C5 RID: 2501 RVA: 0x00028B84 File Offset: 0x00026D84
|
||||
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: 0x060009C6 RID: 2502 RVA: 0x00028BE4 File Offset: 0x00026DE4
|
||||
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: 0x060009C7 RID: 2503 RVA: 0x00028C34 File Offset: 0x00026E34
|
||||
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: 0x060009C8 RID: 2504 RVA: 0x00028C94 File Offset: 0x00026E94
|
||||
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: 0x060009C9 RID: 2505 RVA: 0x00028D34 File Offset: 0x00026F34
|
||||
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: 0x060009CA RID: 2506 RVA: 0x00028DC0 File Offset: 0x00026FC0
|
||||
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$mapA == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapA = 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$mapA.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$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 }
|
||||
};
|
||||
}
|
||||
if (PKCS12.<>f__switch$mapB.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: 0x060009CB RID: 2507 RVA: 0x00029128 File Offset: 0x00027328
|
||||
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$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 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: 0x060009CC RID: 2508 RVA: 0x00029478 File Offset: 0x00027678
|
||||
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$mapD == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapD = 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$mapD.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: 0x060009CD RID: 2509 RVA: 0x00029784 File Offset: 0x00027984
|
||||
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$mapE == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapE = 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$mapE.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: 0x060009CE RID: 2510 RVA: 0x00029A0C File Offset: 0x00027C0C
|
||||
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$mapF == null)
|
||||
{
|
||||
PKCS12.<>f__switch$mapF = 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$mapF.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: 0x060009CF RID: 2511 RVA: 0x00029CD8 File Offset: 0x00027ED8
|
||||
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)HMAC.Create();
|
||||
hmacsha.Key = deriveBytes.DeriveMAC(20);
|
||||
return hmacsha.ComputeHash(data, 0, data.Length);
|
||||
}
|
||||
|
||||
// Token: 0x060009D0 RID: 2512 RVA: 0x00029D34 File Offset: 0x00027F34
|
||||
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: 0x060009D1 RID: 2513 RVA: 0x0002A488 File Offset: 0x00028688
|
||||
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: 0x060009D2 RID: 2514 RVA: 0x0002A598 File Offset: 0x00028798
|
||||
public void AddCertificate(X509Certificate cert)
|
||||
{
|
||||
this.AddCertificate(cert, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D3 RID: 2515 RVA: 0x0002A5A4 File Offset: 0x000287A4
|
||||
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: 0x060009D4 RID: 2516 RVA: 0x0002A678 File Offset: 0x00028878
|
||||
public void RemoveCertificate(X509Certificate cert)
|
||||
{
|
||||
this.RemoveCertificate(cert, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D5 RID: 2517 RVA: 0x0002A684 File Offset: 0x00028884
|
||||
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: 0x060009D6 RID: 2518 RVA: 0x0002A850 File Offset: 0x00028A50
|
||||
private bool CompareAsymmetricAlgorithm(AsymmetricAlgorithm a1, AsymmetricAlgorithm a2)
|
||||
{
|
||||
return a1.KeySize == a2.KeySize && a1.ToXmlString(false) == a2.ToXmlString(false);
|
||||
}
|
||||
|
||||
// Token: 0x060009D7 RID: 2519 RVA: 0x0002A884 File Offset: 0x00028A84
|
||||
public void AddPkcs8ShroudedKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
this.AddPkcs8ShroudedKeyBag(aa, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009D8 RID: 2520 RVA: 0x0002A890 File Offset: 0x00028A90
|
||||
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: 0x060009D9 RID: 2521 RVA: 0x0002A9F4 File Offset: 0x00028BF4
|
||||
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: 0x060009DA RID: 2522 RVA: 0x0002AB48 File Offset: 0x00028D48
|
||||
public void AddKeyBag(AsymmetricAlgorithm aa)
|
||||
{
|
||||
this.AddKeyBag(aa, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009DB RID: 2523 RVA: 0x0002AB54 File Offset: 0x00028D54
|
||||
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: 0x060009DC RID: 2524 RVA: 0x0002AC74 File Offset: 0x00028E74
|
||||
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: 0x060009DD RID: 2525 RVA: 0x0002AD84 File Offset: 0x00028F84
|
||||
public void AddSecretBag(byte[] secret)
|
||||
{
|
||||
this.AddSecretBag(secret, null);
|
||||
}
|
||||
|
||||
// Token: 0x060009DE RID: 2526 RVA: 0x0002AD90 File Offset: 0x00028F90
|
||||
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: 0x060009DF RID: 2527 RVA: 0x0002AE38 File Offset: 0x00029038
|
||||
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: 0x060009E0 RID: 2528 RVA: 0x0002AED0 File Offset: 0x000290D0
|
||||
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: 0x060009E1 RID: 2529 RVA: 0x0002B1B8 File Offset: 0x000293B8
|
||||
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: 0x060009E2 RID: 2530 RVA: 0x0002B354 File Offset: 0x00029554
|
||||
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: 0x060009E3 RID: 2531 RVA: 0x0002B50C File Offset: 0x0002970C
|
||||
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: 0x060009E4 RID: 2532 RVA: 0x0002B7AC File Offset: 0x000299AC
|
||||
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: 0x060009E5 RID: 2533 RVA: 0x0002B924 File Offset: 0x00029B24
|
||||
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: 0x060009E6 RID: 2534 RVA: 0x0002B98C File Offset: 0x00029B8C
|
||||
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: 0x17000125 RID: 293
|
||||
// (get) Token: 0x060009E7 RID: 2535 RVA: 0x0002B9E0 File Offset: 0x00029BE0
|
||||
// (set) Token: 0x060009E8 RID: 2536 RVA: 0x0002B9E8 File Offset: 0x00029BE8
|
||||
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: 0x060009E9 RID: 2537 RVA: 0x0002BA28 File Offset: 0x00029C28
|
||||
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: 0x060009EA RID: 2538 RVA: 0x0002BA8C File Offset: 0x00029C8C
|
||||
public static PKCS12 LoadFromFile(string filename)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
return new PKCS12(PKCS12.LoadFile(filename));
|
||||
}
|
||||
|
||||
// Token: 0x060009EB RID: 2539 RVA: 0x0002BAAC File Offset: 0x00029CAC
|
||||
public static PKCS12 LoadFromFile(string filename, string password)
|
||||
{
|
||||
if (filename == null)
|
||||
{
|
||||
throw new ArgumentNullException("filename");
|
||||
}
|
||||
return new PKCS12(PKCS12.LoadFile(filename), password);
|
||||
}
|
||||
|
||||
// Token: 0x04000244 RID: 580
|
||||
public const string pbeWithSHAAnd128BitRC4 = "1.2.840.113549.1.12.1.1";
|
||||
|
||||
// Token: 0x04000245 RID: 581
|
||||
public const string pbeWithSHAAnd40BitRC4 = "1.2.840.113549.1.12.1.2";
|
||||
|
||||
// Token: 0x04000246 RID: 582
|
||||
public const string pbeWithSHAAnd3KeyTripleDESCBC = "1.2.840.113549.1.12.1.3";
|
||||
|
||||
// Token: 0x04000247 RID: 583
|
||||
public const string pbeWithSHAAnd2KeyTripleDESCBC = "1.2.840.113549.1.12.1.4";
|
||||
|
||||
// Token: 0x04000248 RID: 584
|
||||
public const string pbeWithSHAAnd128BitRC2CBC = "1.2.840.113549.1.12.1.5";
|
||||
|
||||
// Token: 0x04000249 RID: 585
|
||||
public const string pbeWithSHAAnd40BitRC2CBC = "1.2.840.113549.1.12.1.6";
|
||||
|
||||
// Token: 0x0400024A RID: 586
|
||||
public const string keyBag = "1.2.840.113549.1.12.10.1.1";
|
||||
|
||||
// Token: 0x0400024B RID: 587
|
||||
public const string pkcs8ShroudedKeyBag = "1.2.840.113549.1.12.10.1.2";
|
||||
|
||||
// Token: 0x0400024C RID: 588
|
||||
public const string certBag = "1.2.840.113549.1.12.10.1.3";
|
||||
|
||||
// Token: 0x0400024D RID: 589
|
||||
public const string crlBag = "1.2.840.113549.1.12.10.1.4";
|
||||
|
||||
// Token: 0x0400024E RID: 590
|
||||
public const string secretBag = "1.2.840.113549.1.12.10.1.5";
|
||||
|
||||
// Token: 0x0400024F RID: 591
|
||||
public const string safeContentsBag = "1.2.840.113549.1.12.10.1.6";
|
||||
|
||||
// Token: 0x04000250 RID: 592
|
||||
public const string x509Certificate = "1.2.840.113549.1.9.22.1";
|
||||
|
||||
// Token: 0x04000251 RID: 593
|
||||
public const string sdsiCertificate = "1.2.840.113549.1.9.22.2";
|
||||
|
||||
// Token: 0x04000252 RID: 594
|
||||
public const string x509Crl = "1.2.840.113549.1.9.23.1";
|
||||
|
||||
// Token: 0x04000253 RID: 595
|
||||
public const int CryptoApiPasswordLimit = 32;
|
||||
|
||||
// Token: 0x04000254 RID: 596
|
||||
private static int recommendedIterationCount = 2000;
|
||||
|
||||
// Token: 0x04000255 RID: 597
|
||||
private byte[] _password;
|
||||
|
||||
// Token: 0x04000256 RID: 598
|
||||
private ArrayList _keyBags;
|
||||
|
||||
// Token: 0x04000257 RID: 599
|
||||
private ArrayList _secretBags;
|
||||
|
||||
// Token: 0x04000258 RID: 600
|
||||
private X509CertificateCollection _certs;
|
||||
|
||||
// Token: 0x04000259 RID: 601
|
||||
private bool _keyBagsChanged;
|
||||
|
||||
// Token: 0x0400025A RID: 602
|
||||
private bool _secretBagsChanged;
|
||||
|
||||
// Token: 0x0400025B RID: 603
|
||||
private bool _certsChanged;
|
||||
|
||||
// Token: 0x0400025C RID: 604
|
||||
private int _iterations;
|
||||
|
||||
// Token: 0x0400025D RID: 605
|
||||
private ArrayList _safeBags;
|
||||
|
||||
// Token: 0x0400025E RID: 606
|
||||
private RandomNumberGenerator _rng;
|
||||
|
||||
// Token: 0x0400025F RID: 607
|
||||
private static int password_max_length = int.MaxValue;
|
||||
|
||||
// Token: 0x020000B7 RID: 183
|
||||
public class DeriveBytes
|
||||
{
|
||||
// Token: 0x17000126 RID: 294
|
||||
// (get) Token: 0x060009EE RID: 2542 RVA: 0x0002BB28 File Offset: 0x00029D28
|
||||
// (set) Token: 0x060009EF RID: 2543 RVA: 0x0002BB30 File Offset: 0x00029D30
|
||||
public string HashName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._hashName;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._hashName = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000127 RID: 295
|
||||
// (get) Token: 0x060009F0 RID: 2544 RVA: 0x0002BB3C File Offset: 0x00029D3C
|
||||
// (set) Token: 0x060009F1 RID: 2545 RVA: 0x0002BB44 File Offset: 0x00029D44
|
||||
public int IterationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._iterations;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._iterations = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000128 RID: 296
|
||||
// (get) Token: 0x060009F2 RID: 2546 RVA: 0x0002BB50 File Offset: 0x00029D50
|
||||
// (set) Token: 0x060009F3 RID: 2547 RVA: 0x0002BB64 File Offset: 0x00029D64
|
||||
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: 0x17000129 RID: 297
|
||||
// (get) Token: 0x060009F4 RID: 2548 RVA: 0x0002BB9C File Offset: 0x00029D9C
|
||||
// (set) Token: 0x060009F5 RID: 2549 RVA: 0x0002BBB0 File Offset: 0x00029DB0
|
||||
public byte[] Salt
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this._salt.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
this._salt = (byte[])value.Clone();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._salt = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060009F6 RID: 2550 RVA: 0x0002BBD8 File Offset: 0x00029DD8
|
||||
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: 0x060009F7 RID: 2551 RVA: 0x0002BC50 File Offset: 0x00029E50
|
||||
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: 0x060009F8 RID: 2552 RVA: 0x0002BE90 File Offset: 0x0002A090
|
||||
public byte[] DeriveKey(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.keyDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x060009F9 RID: 2553 RVA: 0x0002BEA0 File Offset: 0x0002A0A0
|
||||
public byte[] DeriveIV(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.ivDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x060009FA RID: 2554 RVA: 0x0002BEB0 File Offset: 0x0002A0B0
|
||||
public byte[] DeriveMAC(int size)
|
||||
{
|
||||
return this.Derive(PKCS12.DeriveBytes.macDiversifier, size);
|
||||
}
|
||||
|
||||
// Token: 0x04000268 RID: 616
|
||||
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: 0x04000269 RID: 617
|
||||
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: 0x0400026A RID: 618
|
||||
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: 0x0400026B RID: 619
|
||||
private string _hashName;
|
||||
|
||||
// Token: 0x0400026C RID: 620
|
||||
private int _iterations;
|
||||
|
||||
// Token: 0x0400026D RID: 621
|
||||
private byte[] _password;
|
||||
|
||||
// Token: 0x0400026E RID: 622
|
||||
private byte[] _salt;
|
||||
|
||||
// Token: 0x020000B8 RID: 184
|
||||
public enum Purpose
|
||||
{
|
||||
// Token: 0x04000270 RID: 624
|
||||
Key,
|
||||
// Token: 0x04000271 RID: 625
|
||||
IV,
|
||||
// Token: 0x04000272 RID: 626
|
||||
MAC
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B3 RID: 179
|
||||
internal class PKCS5
|
||||
{
|
||||
// Token: 0x0400023A RID: 570
|
||||
public const string pbeWithMD2AndDESCBC = "1.2.840.113549.1.5.1";
|
||||
|
||||
// Token: 0x0400023B RID: 571
|
||||
public const string pbeWithMD5AndDESCBC = "1.2.840.113549.1.5.3";
|
||||
|
||||
// Token: 0x0400023C RID: 572
|
||||
public const string pbeWithMD2AndRC2CBC = "1.2.840.113549.1.5.4";
|
||||
|
||||
// Token: 0x0400023D RID: 573
|
||||
public const string pbeWithMD5AndRC2CBC = "1.2.840.113549.1.5.6";
|
||||
|
||||
// Token: 0x0400023E RID: 574
|
||||
public const string pbeWithSHA1AndDESCBC = "1.2.840.113549.1.5.10";
|
||||
|
||||
// Token: 0x0400023F RID: 575
|
||||
public const string pbeWithSHA1AndRC2CBC = "1.2.840.113549.1.5.11";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B4 RID: 180
|
||||
internal class PKCS9
|
||||
{
|
||||
// Token: 0x04000240 RID: 576
|
||||
public const string friendlyName = "1.2.840.113549.1.9.20";
|
||||
|
||||
// Token: 0x04000241 RID: 577
|
||||
public const string localKeyId = "1.2.840.113549.1.9.21";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B5 RID: 181
|
||||
internal class SafeBag
|
||||
{
|
||||
// Token: 0x060009B2 RID: 2482 RVA: 0x00027F90 File Offset: 0x00026190
|
||||
public SafeBag(string bagOID, ASN1 asn1)
|
||||
{
|
||||
this._bagOID = bagOID;
|
||||
this._asn1 = asn1;
|
||||
}
|
||||
|
||||
// Token: 0x1700011D RID: 285
|
||||
// (get) Token: 0x060009B3 RID: 2483 RVA: 0x00027FA8 File Offset: 0x000261A8
|
||||
public string BagOID
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._bagOID;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011E RID: 286
|
||||
// (get) Token: 0x060009B4 RID: 2484 RVA: 0x00027FB0 File Offset: 0x000261B0
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._asn1;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000242 RID: 578
|
||||
private string _bagOID;
|
||||
|
||||
// Token: 0x04000243 RID: 579
|
||||
private ASN1 _asn1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000B9 RID: 185
|
||||
internal sealed class X501
|
||||
{
|
||||
// Token: 0x060009FB RID: 2555 RVA: 0x0002BEC0 File Offset: 0x0002A0C0
|
||||
private X501()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060009FD RID: 2557 RVA: 0x0002C044 File Offset: 0x0002A244
|
||||
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: 0x060009FE RID: 2558 RVA: 0x0002C0A0 File Offset: 0x0002A2A0
|
||||
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: 0x060009FF RID: 2559 RVA: 0x0002C13C File Offset: 0x0002A33C
|
||||
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: 0x06000A00 RID: 2560 RVA: 0x0002C4B4 File Offset: 0x0002A6B4
|
||||
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: 0x06000A01 RID: 2561 RVA: 0x0002C684 File Offset: 0x0002A884
|
||||
private static bool IsOid(string oid)
|
||||
{
|
||||
bool flag;
|
||||
try
|
||||
{
|
||||
ASN1 asn = ASN1Convert.FromOid(oid);
|
||||
flag = asn.Tag == 6;
|
||||
}
|
||||
catch
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
// Token: 0x06000A02 RID: 2562 RVA: 0x0002C6D8 File Offset: 0x0002A8D8
|
||||
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: 0x06000A03 RID: 2563 RVA: 0x0002C76C File Offset: 0x0002A96C
|
||||
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: 0x06000A04 RID: 2564 RVA: 0x0002C7A8 File Offset: 0x0002A9A8
|
||||
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: 0x06000A05 RID: 2565 RVA: 0x0002C858 File Offset: 0x0002AA58
|
||||
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: 0x06000A06 RID: 2566 RVA: 0x0002C900 File Offset: 0x0002AB00
|
||||
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: 0x06000A07 RID: 2567 RVA: 0x0002C980 File Offset: 0x0002AB80
|
||||
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: 0x06000A08 RID: 2568 RVA: 0x0002CA88 File Offset: 0x0002AC88
|
||||
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: 0x04000273 RID: 627
|
||||
private static byte[] countryName = new byte[] { 85, 4, 6 };
|
||||
|
||||
// Token: 0x04000274 RID: 628
|
||||
private static byte[] organizationName = new byte[] { 85, 4, 10 };
|
||||
|
||||
// Token: 0x04000275 RID: 629
|
||||
private static byte[] organizationalUnitName = new byte[] { 85, 4, 11 };
|
||||
|
||||
// Token: 0x04000276 RID: 630
|
||||
private static byte[] commonName = new byte[] { 85, 4, 3 };
|
||||
|
||||
// Token: 0x04000277 RID: 631
|
||||
private static byte[] localityName = new byte[] { 85, 4, 7 };
|
||||
|
||||
// Token: 0x04000278 RID: 632
|
||||
private static byte[] stateOrProvinceName = new byte[] { 85, 4, 8 };
|
||||
|
||||
// Token: 0x04000279 RID: 633
|
||||
private static byte[] streetAddress = new byte[] { 85, 4, 9 };
|
||||
|
||||
// Token: 0x0400027A RID: 634
|
||||
private static byte[] domainComponent = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 25 };
|
||||
|
||||
// Token: 0x0400027B RID: 635
|
||||
private static byte[] userid = new byte[] { 9, 146, 38, 137, 147, 242, 44, 100, 1, 1 };
|
||||
|
||||
// Token: 0x0400027C RID: 636
|
||||
private static byte[] email = new byte[] { 42, 134, 72, 134, 247, 13, 1, 9, 1 };
|
||||
|
||||
// Token: 0x0400027D RID: 637
|
||||
private static byte[] dnQualifier = new byte[] { 85, 4, 46 };
|
||||
|
||||
// Token: 0x0400027E RID: 638
|
||||
private static byte[] title = new byte[] { 85, 4, 12 };
|
||||
|
||||
// Token: 0x0400027F RID: 639
|
||||
private static byte[] surname = new byte[] { 85, 4, 4 };
|
||||
|
||||
// Token: 0x04000280 RID: 640
|
||||
private static byte[] givenName = new byte[] { 85, 4, 42 };
|
||||
|
||||
// Token: 0x04000281 RID: 641
|
||||
private static byte[] initial = new byte[] { 85, 4, 43 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,713 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BC RID: 188
|
||||
internal class X509Certificate : ISerializable
|
||||
{
|
||||
// Token: 0x06000A29 RID: 2601 RVA: 0x0002D4B8 File Offset: 0x0002B6B8
|
||||
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: 0x06000A2A RID: 2602 RVA: 0x0002D52C File Offset: 0x0002B72C
|
||||
protected X509Certificate(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
this.Parse((byte[])info.GetValue("raw", typeof(byte[])));
|
||||
}
|
||||
|
||||
// Token: 0x06000A2C RID: 2604 RVA: 0x0002D574 File Offset: 0x0002B774
|
||||
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: 0x06000A2D RID: 2605 RVA: 0x0002D904 File Offset: 0x0002BB04
|
||||
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: 0x1700013A RID: 314
|
||||
// (get) Token: 0x06000A2E RID: 2606 RVA: 0x0002D934 File Offset: 0x0002BB34
|
||||
// (set) Token: 0x06000A2F RID: 2607 RVA: 0x0002DA78 File Offset: 0x0002BC78
|
||||
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: 0x1700013B RID: 315
|
||||
// (get) Token: 0x06000A30 RID: 2608 RVA: 0x0002DA90 File Offset: 0x0002BC90
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013C RID: 316
|
||||
// (get) Token: 0x06000A31 RID: 2609 RVA: 0x0002DA98 File Offset: 0x0002BC98
|
||||
public byte[] Hash
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.certhash == null)
|
||||
{
|
||||
string signaturealgo = this.m_signaturealgo;
|
||||
if (signaturealgo != null)
|
||||
{
|
||||
if (X509Certificate.<>f__switch$map13 == null)
|
||||
{
|
||||
X509Certificate.<>f__switch$map13 = new Dictionary<string, int>(5)
|
||||
{
|
||||
{ "1.2.840.113549.1.1.2", 0 },
|
||||
{ "1.2.840.113549.1.1.4", 1 },
|
||||
{ "1.2.840.113549.1.1.5", 2 },
|
||||
{ "1.3.14.3.2.29", 2 },
|
||||
{ "1.2.840.10040.4.3", 2 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (X509Certificate.<>f__switch$map13.TryGetValue(signaturealgo, out num))
|
||||
{
|
||||
HashAlgorithm hashAlgorithm;
|
||||
switch (num)
|
||||
{
|
||||
case 0:
|
||||
hashAlgorithm = HashAlgorithm.Create("MD2");
|
||||
break;
|
||||
case 1:
|
||||
hashAlgorithm = MD5.Create();
|
||||
break;
|
||||
case 2:
|
||||
hashAlgorithm = SHA1.Create();
|
||||
break;
|
||||
default:
|
||||
goto IL_BD;
|
||||
}
|
||||
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_100;
|
||||
}
|
||||
}
|
||||
IL_BD:
|
||||
return null;
|
||||
}
|
||||
IL_100:
|
||||
return (byte[])this.certhash.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013D RID: 317
|
||||
// (get) Token: 0x06000A32 RID: 2610 RVA: 0x0002DBB8 File Offset: 0x0002BDB8
|
||||
public virtual string IssuerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_issuername;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013E RID: 318
|
||||
// (get) Token: 0x06000A33 RID: 2611 RVA: 0x0002DBC0 File Offset: 0x0002BDC0
|
||||
public virtual string KeyAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_keyalgo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700013F RID: 319
|
||||
// (get) Token: 0x06000A34 RID: 2612 RVA: 0x0002DBC8 File Offset: 0x0002BDC8
|
||||
// (set) Token: 0x06000A35 RID: 2613 RVA: 0x0002DBE8 File Offset: 0x0002BDE8
|
||||
public virtual byte[] KeyAlgorithmParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_keyalgoparams == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_keyalgoparams.Clone();
|
||||
}
|
||||
set
|
||||
{
|
||||
this.m_keyalgoparams = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000140 RID: 320
|
||||
// (get) Token: 0x06000A36 RID: 2614 RVA: 0x0002DBF4 File Offset: 0x0002BDF4
|
||||
public virtual byte[] PublicKey
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_publickey == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_publickey.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000141 RID: 321
|
||||
// (get) Token: 0x06000A37 RID: 2615 RVA: 0x0002DC14 File Offset: 0x0002BE14
|
||||
// (set) Token: 0x06000A38 RID: 2616 RVA: 0x0002DCC0 File Offset: 0x0002BEC0
|
||||
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: 0x17000142 RID: 322
|
||||
// (get) Token: 0x06000A39 RID: 2617 RVA: 0x0002DCD8 File Offset: 0x0002BED8
|
||||
public virtual byte[] RawData
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_encodedcert == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.m_encodedcert.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000143 RID: 323
|
||||
// (get) Token: 0x06000A3A RID: 2618 RVA: 0x0002DCF8 File Offset: 0x0002BEF8
|
||||
public virtual byte[] SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.serialnumber == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.serialnumber.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000144 RID: 324
|
||||
// (get) Token: 0x06000A3B RID: 2619 RVA: 0x0002DD18 File Offset: 0x0002BF18
|
||||
public virtual byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string signaturealgo = this.m_signaturealgo;
|
||||
if (signaturealgo != null)
|
||||
{
|
||||
if (X509Certificate.<>f__switch$map14 == null)
|
||||
{
|
||||
X509Certificate.<>f__switch$map14 = new Dictionary<string, int>(5)
|
||||
{
|
||||
{ "1.2.840.113549.1.1.2", 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.10040.4.3", 1 }
|
||||
};
|
||||
}
|
||||
int num;
|
||||
if (X509Certificate.<>f__switch$map14.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: 0x17000145 RID: 325
|
||||
// (get) Token: 0x06000A3C RID: 2620 RVA: 0x0002DE88 File Offset: 0x0002C088
|
||||
public virtual string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_signaturealgo;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000146 RID: 326
|
||||
// (get) Token: 0x06000A3D RID: 2621 RVA: 0x0002DE90 File Offset: 0x0002C090
|
||||
public virtual byte[] SignatureAlgorithmParameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_signaturealgoparams == null)
|
||||
{
|
||||
return this.m_signaturealgoparams;
|
||||
}
|
||||
return (byte[])this.m_signaturealgoparams.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000147 RID: 327
|
||||
// (get) Token: 0x06000A3E RID: 2622 RVA: 0x0002DEC0 File Offset: 0x0002C0C0
|
||||
public virtual string SubjectName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_subject;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000148 RID: 328
|
||||
// (get) Token: 0x06000A3F RID: 2623 RVA: 0x0002DEC8 File Offset: 0x0002C0C8
|
||||
public virtual DateTime ValidFrom
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_from;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000149 RID: 329
|
||||
// (get) Token: 0x06000A40 RID: 2624 RVA: 0x0002DED0 File Offset: 0x0002C0D0
|
||||
public virtual DateTime ValidUntil
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_until;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014A RID: 330
|
||||
// (get) Token: 0x06000A41 RID: 2625 RVA: 0x0002DED8 File Offset: 0x0002C0D8
|
||||
public int Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014B RID: 331
|
||||
// (get) Token: 0x06000A42 RID: 2626 RVA: 0x0002DEE0 File Offset: 0x0002C0E0
|
||||
public bool IsCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.WasCurrent(DateTime.UtcNow);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A43 RID: 2627 RVA: 0x0002DEF0 File Offset: 0x0002C0F0
|
||||
public bool WasCurrent(DateTime instant)
|
||||
{
|
||||
return instant > this.ValidFrom && instant <= this.ValidUntil;
|
||||
}
|
||||
|
||||
// Token: 0x1700014C RID: 332
|
||||
// (get) Token: 0x06000A44 RID: 2628 RVA: 0x0002DF20 File Offset: 0x0002C120
|
||||
public byte[] IssuerUniqueIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.issuerUniqueID == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.issuerUniqueID.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700014D RID: 333
|
||||
// (get) Token: 0x06000A45 RID: 2629 RVA: 0x0002DF40 File Offset: 0x0002C140
|
||||
public byte[] SubjectUniqueIdentifier
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.subjectUniqueID == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.subjectUniqueID.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A46 RID: 2630 RVA: 0x0002DF60 File Offset: 0x0002C160
|
||||
internal bool VerifySignature(DSA dsa)
|
||||
{
|
||||
DSASignatureDeformatter dsasignatureDeformatter = new DSASignatureDeformatter(dsa);
|
||||
dsasignatureDeformatter.SetHashAlgorithm("SHA1");
|
||||
return dsasignatureDeformatter.VerifySignature(this.Hash, this.Signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A47 RID: 2631 RVA: 0x0002DF94 File Offset: 0x0002C194
|
||||
internal string GetHashNameFromOID(string oid)
|
||||
{
|
||||
switch (oid)
|
||||
{
|
||||
case "1.2.840.113549.1.1.2":
|
||||
return "MD2";
|
||||
case "1.2.840.113549.1.1.4":
|
||||
return "MD5";
|
||||
case "1.2.840.113549.1.1.5":
|
||||
case "1.3.14.3.2.29":
|
||||
return "SHA1";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A48 RID: 2632 RVA: 0x0002E02C File Offset: 0x0002C22C
|
||||
internal bool VerifySignature(RSA rsa)
|
||||
{
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
string hashNameFromOID = this.GetHashNameFromOID(this.m_signaturealgo);
|
||||
if (hashNameFromOID == null)
|
||||
{
|
||||
throw new CryptographicException("Unsupported hash algorithm: " + this.m_signaturealgo);
|
||||
}
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm(hashNameFromOID);
|
||||
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.Signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A49 RID: 2633 RVA: 0x0002E084 File Offset: 0x0002C284
|
||||
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: 0x06000A4A RID: 2634 RVA: 0x0002E0E8 File Offset: 0x0002C2E8
|
||||
public bool CheckSignature(byte[] hash, string hashAlgorithm, byte[] signature)
|
||||
{
|
||||
RSACryptoServiceProvider rsacryptoServiceProvider = (RSACryptoServiceProvider)this.RSA;
|
||||
return rsacryptoServiceProvider.VerifyHash(hash, hashAlgorithm, signature);
|
||||
}
|
||||
|
||||
// Token: 0x1700014E RID: 334
|
||||
// (get) Token: 0x06000A4B RID: 2635 RVA: 0x0002E10C File Offset: 0x0002C30C
|
||||
public bool IsSelfSigned
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.m_issuername == this.m_subject && this.VerifySignature(this.RSA);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A4C RID: 2636 RVA: 0x0002E140 File Offset: 0x0002C340
|
||||
public ASN1 GetIssuerName()
|
||||
{
|
||||
return this.issuer;
|
||||
}
|
||||
|
||||
// Token: 0x06000A4D RID: 2637 RVA: 0x0002E148 File Offset: 0x0002C348
|
||||
public ASN1 GetSubjectName()
|
||||
{
|
||||
return this.subject;
|
||||
}
|
||||
|
||||
// Token: 0x06000A4E RID: 2638 RVA: 0x0002E150 File Offset: 0x0002C350
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("raw", this.m_encodedcert);
|
||||
}
|
||||
|
||||
// Token: 0x06000A4F RID: 2639 RVA: 0x0002E164 File Offset: 0x0002C364
|
||||
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: 0x04000292 RID: 658
|
||||
private ASN1 decoder;
|
||||
|
||||
// Token: 0x04000293 RID: 659
|
||||
private byte[] m_encodedcert;
|
||||
|
||||
// Token: 0x04000294 RID: 660
|
||||
private DateTime m_from;
|
||||
|
||||
// Token: 0x04000295 RID: 661
|
||||
private DateTime m_until;
|
||||
|
||||
// Token: 0x04000296 RID: 662
|
||||
private ASN1 issuer;
|
||||
|
||||
// Token: 0x04000297 RID: 663
|
||||
private string m_issuername;
|
||||
|
||||
// Token: 0x04000298 RID: 664
|
||||
private string m_keyalgo;
|
||||
|
||||
// Token: 0x04000299 RID: 665
|
||||
private byte[] m_keyalgoparams;
|
||||
|
||||
// Token: 0x0400029A RID: 666
|
||||
private ASN1 subject;
|
||||
|
||||
// Token: 0x0400029B RID: 667
|
||||
private string m_subject;
|
||||
|
||||
// Token: 0x0400029C RID: 668
|
||||
private byte[] m_publickey;
|
||||
|
||||
// Token: 0x0400029D RID: 669
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x0400029E RID: 670
|
||||
private string m_signaturealgo;
|
||||
|
||||
// Token: 0x0400029F RID: 671
|
||||
private byte[] m_signaturealgoparams;
|
||||
|
||||
// Token: 0x040002A0 RID: 672
|
||||
private byte[] certhash;
|
||||
|
||||
// Token: 0x040002A1 RID: 673
|
||||
private RSA _rsa;
|
||||
|
||||
// Token: 0x040002A2 RID: 674
|
||||
private DSA _dsa;
|
||||
|
||||
// Token: 0x040002A3 RID: 675
|
||||
private int version;
|
||||
|
||||
// Token: 0x040002A4 RID: 676
|
||||
private byte[] serialnumber;
|
||||
|
||||
// Token: 0x040002A5 RID: 677
|
||||
private byte[] issuerUniqueID;
|
||||
|
||||
// Token: 0x040002A6 RID: 678
|
||||
private byte[] subjectUniqueID;
|
||||
|
||||
// Token: 0x040002A7 RID: 679
|
||||
private X509ExtensionCollection extensions;
|
||||
|
||||
// Token: 0x040002A8 RID: 680
|
||||
private static string encoding_error = Locale.GetText("Input data cannot be coded as a valid certificate.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BD RID: 189
|
||||
[Serializable]
|
||||
internal class X509CertificateCollection : CollectionBase, IEnumerable
|
||||
{
|
||||
// Token: 0x06000A50 RID: 2640 RVA: 0x0002E1C4 File Offset: 0x0002C3C4
|
||||
public X509CertificateCollection()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A51 RID: 2641 RVA: 0x0002E1CC File Offset: 0x0002C3CC
|
||||
public X509CertificateCollection(X509Certificate[] value)
|
||||
{
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A52 RID: 2642 RVA: 0x0002E1DC File Offset: 0x0002C3DC
|
||||
public X509CertificateCollection(X509CertificateCollection value)
|
||||
{
|
||||
this.AddRange(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A53 RID: 2643 RVA: 0x0002E1EC File Offset: 0x0002C3EC
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return base.InnerList.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x1700014F RID: 335
|
||||
public X509Certificate this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Certificate)base.InnerList[index];
|
||||
}
|
||||
set
|
||||
{
|
||||
base.InnerList[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A56 RID: 2646 RVA: 0x0002E220 File Offset: 0x0002C420
|
||||
public int Add(X509Certificate value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
throw new ArgumentNullException("value");
|
||||
}
|
||||
return base.InnerList.Add(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A57 RID: 2647 RVA: 0x0002E240 File Offset: 0x0002C440
|
||||
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: 0x06000A58 RID: 2648 RVA: 0x0002E284 File Offset: 0x0002C484
|
||||
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: 0x06000A59 RID: 2649 RVA: 0x0002E2D4 File Offset: 0x0002C4D4
|
||||
public bool Contains(X509Certificate value)
|
||||
{
|
||||
return this.IndexOf(value) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A5A RID: 2650 RVA: 0x0002E2E4 File Offset: 0x0002C4E4
|
||||
public void CopyTo(X509Certificate[] array, int index)
|
||||
{
|
||||
base.InnerList.CopyTo(array, index);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5B RID: 2651 RVA: 0x0002E2F4 File Offset: 0x0002C4F4
|
||||
public new X509CertificateCollection.X509CertificateEnumerator GetEnumerator()
|
||||
{
|
||||
return new X509CertificateCollection.X509CertificateEnumerator(this);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5C RID: 2652 RVA: 0x0002E2FC File Offset: 0x0002C4FC
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.InnerList.GetHashCode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A5D RID: 2653 RVA: 0x0002E30C File Offset: 0x0002C50C
|
||||
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: 0x06000A5E RID: 2654 RVA: 0x0002E374 File Offset: 0x0002C574
|
||||
public void Insert(int index, X509Certificate value)
|
||||
{
|
||||
base.InnerList.Insert(index, value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A5F RID: 2655 RVA: 0x0002E384 File Offset: 0x0002C584
|
||||
public void Remove(X509Certificate value)
|
||||
{
|
||||
base.InnerList.Remove(value);
|
||||
}
|
||||
|
||||
// Token: 0x06000A60 RID: 2656 RVA: 0x0002E394 File Offset: 0x0002C594
|
||||
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: 0x020000BE RID: 190
|
||||
public class X509CertificateEnumerator : IEnumerator
|
||||
{
|
||||
// Token: 0x06000A61 RID: 2657 RVA: 0x0002E3EC File Offset: 0x0002C5EC
|
||||
public X509CertificateEnumerator(X509CertificateCollection mappings)
|
||||
{
|
||||
this.enumerator = ((IEnumerable)mappings).GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x17000150 RID: 336
|
||||
// (get) Token: 0x06000A62 RID: 2658 RVA: 0x0002E400 File Offset: 0x0002C600
|
||||
object IEnumerator.Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A63 RID: 2659 RVA: 0x0002E410 File Offset: 0x0002C610
|
||||
bool IEnumerator.MoveNext()
|
||||
{
|
||||
return this.enumerator.MoveNext();
|
||||
}
|
||||
|
||||
// Token: 0x06000A64 RID: 2660 RVA: 0x0002E420 File Offset: 0x0002C620
|
||||
void IEnumerator.Reset()
|
||||
{
|
||||
this.enumerator.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x17000151 RID: 337
|
||||
// (get) Token: 0x06000A65 RID: 2661 RVA: 0x0002E430 File Offset: 0x0002C630
|
||||
public X509Certificate Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Certificate)this.enumerator.Current;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A66 RID: 2662 RVA: 0x0002E444 File Offset: 0x0002C644
|
||||
public bool MoveNext()
|
||||
{
|
||||
return this.enumerator.MoveNext();
|
||||
}
|
||||
|
||||
// Token: 0x06000A67 RID: 2663 RVA: 0x0002E454 File Offset: 0x0002C654
|
||||
public void Reset()
|
||||
{
|
||||
this.enumerator.Reset();
|
||||
}
|
||||
|
||||
// Token: 0x040002AC RID: 684
|
||||
private IEnumerator enumerator;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using Mono.Security.X509.Extensions;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000BF RID: 191
|
||||
internal class X509Chain
|
||||
{
|
||||
// Token: 0x06000A68 RID: 2664 RVA: 0x0002E464 File Offset: 0x0002C664
|
||||
public X509Chain()
|
||||
{
|
||||
this.certs = new X509CertificateCollection();
|
||||
}
|
||||
|
||||
// Token: 0x06000A69 RID: 2665 RVA: 0x0002E478 File Offset: 0x0002C678
|
||||
public X509Chain(X509CertificateCollection chain)
|
||||
: this()
|
||||
{
|
||||
this._chain = new X509CertificateCollection();
|
||||
this._chain.AddRange(chain);
|
||||
}
|
||||
|
||||
// Token: 0x17000152 RID: 338
|
||||
// (get) Token: 0x06000A6A RID: 2666 RVA: 0x0002E498 File Offset: 0x0002C698
|
||||
public X509CertificateCollection Chain
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._chain;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000153 RID: 339
|
||||
// (get) Token: 0x06000A6B RID: 2667 RVA: 0x0002E4A0 File Offset: 0x0002C6A0
|
||||
public X509Certificate Root
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._root;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000154 RID: 340
|
||||
// (get) Token: 0x06000A6C RID: 2668 RVA: 0x0002E4A8 File Offset: 0x0002C6A8
|
||||
public X509ChainStatusFlags Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._status;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000155 RID: 341
|
||||
// (get) Token: 0x06000A6D RID: 2669 RVA: 0x0002E4B0 File Offset: 0x0002C6B0
|
||||
// (set) Token: 0x06000A6E RID: 2670 RVA: 0x0002E4E8 File Offset: 0x0002C6E8
|
||||
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: 0x06000A6F RID: 2671 RVA: 0x0002E4F4 File Offset: 0x0002C6F4
|
||||
public void LoadCertificate(X509Certificate x509)
|
||||
{
|
||||
this.certs.Add(x509);
|
||||
}
|
||||
|
||||
// Token: 0x06000A70 RID: 2672 RVA: 0x0002E504 File Offset: 0x0002C704
|
||||
public void LoadCertificates(X509CertificateCollection collection)
|
||||
{
|
||||
this.certs.AddRange(collection);
|
||||
}
|
||||
|
||||
// Token: 0x06000A71 RID: 2673 RVA: 0x0002E514 File Offset: 0x0002C714
|
||||
public X509Certificate FindByIssuerName(string issuerName)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate in this.certs)
|
||||
{
|
||||
if (x509Certificate.IssuerName == issuerName)
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A72 RID: 2674 RVA: 0x0002E594 File Offset: 0x0002C794
|
||||
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: 0x06000A73 RID: 2675 RVA: 0x0002E770 File Offset: 0x0002C970
|
||||
public void Reset()
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NoError;
|
||||
this.roots = null;
|
||||
this.certs.Clear();
|
||||
if (this._chain != null)
|
||||
{
|
||||
this._chain.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A74 RID: 2676 RVA: 0x0002E7A4 File Offset: 0x0002C9A4
|
||||
private bool IsValid(X509Certificate cert)
|
||||
{
|
||||
if (!cert.IsCurrent)
|
||||
{
|
||||
this._status = X509ChainStatusFlags.NotTimeNested;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x06000A75 RID: 2677 RVA: 0x0002E7BC File Offset: 0x0002C9BC
|
||||
private X509Certificate FindCertificateParent(X509Certificate child)
|
||||
{
|
||||
foreach (X509Certificate x509Certificate in this.certs)
|
||||
{
|
||||
if (this.IsParent(child, x509Certificate))
|
||||
{
|
||||
return x509Certificate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A76 RID: 2678 RVA: 0x0002E838 File Offset: 0x0002CA38
|
||||
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: 0x06000A77 RID: 2679 RVA: 0x0002E8F4 File Offset: 0x0002CAF4
|
||||
private bool IsTrusted(X509Certificate potentialTrusted)
|
||||
{
|
||||
return this.TrustAnchors.Contains(potentialTrusted);
|
||||
}
|
||||
|
||||
// Token: 0x06000A78 RID: 2680 RVA: 0x0002E904 File Offset: 0x0002CB04
|
||||
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: 0x040002AD RID: 685
|
||||
private X509CertificateCollection roots;
|
||||
|
||||
// Token: 0x040002AE RID: 686
|
||||
private X509CertificateCollection certs;
|
||||
|
||||
// Token: 0x040002AF RID: 687
|
||||
private X509Certificate _root;
|
||||
|
||||
// Token: 0x040002B0 RID: 688
|
||||
private X509CertificateCollection _chain;
|
||||
|
||||
// Token: 0x040002B1 RID: 689
|
||||
private X509ChainStatusFlags _status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C0 RID: 192
|
||||
[Flags]
|
||||
[Serializable]
|
||||
internal enum X509ChainStatusFlags
|
||||
{
|
||||
// Token: 0x040002B3 RID: 691
|
||||
InvalidBasicConstraints = 1024,
|
||||
// Token: 0x040002B4 RID: 692
|
||||
NoError = 0,
|
||||
// Token: 0x040002B5 RID: 693
|
||||
NotSignatureValid = 8,
|
||||
// Token: 0x040002B6 RID: 694
|
||||
NotTimeNested = 2,
|
||||
// Token: 0x040002B7 RID: 695
|
||||
NotTimeValid = 1,
|
||||
// Token: 0x040002B8 RID: 696
|
||||
PartialChain = 65536,
|
||||
// Token: 0x040002B9 RID: 697
|
||||
UntrustedRoot = 32
|
||||
}
|
||||
}
|
||||
@@ -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: 0x020000BA RID: 186
|
||||
internal class X509Crl
|
||||
{
|
||||
// Token: 0x06000A09 RID: 2569 RVA: 0x0002CAF8 File Offset: 0x0002ACF8
|
||||
public X509Crl(byte[] crl)
|
||||
{
|
||||
if (crl == null)
|
||||
{
|
||||
throw new ArgumentNullException("crl");
|
||||
}
|
||||
this.encoded = (byte[])crl.Clone();
|
||||
this.Parse(this.encoded);
|
||||
}
|
||||
|
||||
// Token: 0x06000A0A RID: 2570 RVA: 0x0002CB3C File Offset: 0x0002AD3C
|
||||
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: 0x1700012A RID: 298
|
||||
// (get) Token: 0x06000A0B RID: 2571 RVA: 0x0002CDBC File Offset: 0x0002AFBC
|
||||
public ArrayList Entries
|
||||
{
|
||||
get
|
||||
{
|
||||
return ArrayList.ReadOnly(this.entries);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012B RID: 299
|
||||
public X509Crl.X509CrlEntry this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Crl.X509CrlEntry)this.entries[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012C RID: 300
|
||||
public X509Crl.X509CrlEntry this[byte[] serialNumber]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetCrlEntry(serialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012D RID: 301
|
||||
// (get) Token: 0x06000A0E RID: 2574 RVA: 0x0002CDEC File Offset: 0x0002AFEC
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700012E RID: 302
|
||||
// (get) Token: 0x06000A0F RID: 2575 RVA: 0x0002CDF4 File Offset: 0x0002AFF4
|
||||
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: 0x1700012F RID: 303
|
||||
// (get) Token: 0x06000A10 RID: 2576 RVA: 0x0002CE44 File Offset: 0x0002B044
|
||||
public string IssuerName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.issuer;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000130 RID: 304
|
||||
// (get) Token: 0x06000A11 RID: 2577 RVA: 0x0002CE4C File Offset: 0x0002B04C
|
||||
public DateTime NextUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.nextUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000131 RID: 305
|
||||
// (get) Token: 0x06000A12 RID: 2578 RVA: 0x0002CE54 File Offset: 0x0002B054
|
||||
public DateTime ThisUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.thisUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000132 RID: 306
|
||||
// (get) Token: 0x06000A13 RID: 2579 RVA: 0x0002CE5C File Offset: 0x0002B05C
|
||||
public string SignatureAlgorithm
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.signatureOID;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000133 RID: 307
|
||||
// (get) Token: 0x06000A14 RID: 2580 RVA: 0x0002CE64 File Offset: 0x0002B064
|
||||
public byte[] Signature
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.signature == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (byte[])this.signature.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000134 RID: 308
|
||||
// (get) Token: 0x06000A15 RID: 2581 RVA: 0x0002CE84 File Offset: 0x0002B084
|
||||
public byte[] RawData
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this.encoded.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000135 RID: 309
|
||||
// (get) Token: 0x06000A16 RID: 2582 RVA: 0x0002CE98 File Offset: 0x0002B098
|
||||
public byte Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000136 RID: 310
|
||||
// (get) Token: 0x06000A17 RID: 2583 RVA: 0x0002CEA0 File Offset: 0x0002B0A0
|
||||
public bool IsCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.WasCurrent(DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A18 RID: 2584 RVA: 0x0002CEB0 File Offset: 0x0002B0B0
|
||||
public bool WasCurrent(DateTime instant)
|
||||
{
|
||||
if (this.nextUpdate == DateTime.MinValue)
|
||||
{
|
||||
return instant >= this.thisUpdate;
|
||||
}
|
||||
return instant >= this.thisUpdate && instant <= this.nextUpdate;
|
||||
}
|
||||
|
||||
// Token: 0x06000A19 RID: 2585 RVA: 0x0002CF00 File Offset: 0x0002B100
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return (byte[])this.encoded.Clone();
|
||||
}
|
||||
|
||||
// Token: 0x06000A1A RID: 2586 RVA: 0x0002CF14 File Offset: 0x0002B114
|
||||
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: 0x06000A1B RID: 2587 RVA: 0x0002CF6C File Offset: 0x0002B16C
|
||||
public X509Crl.X509CrlEntry GetCrlEntry(X509Certificate x509)
|
||||
{
|
||||
if (x509 == null)
|
||||
{
|
||||
throw new ArgumentNullException("x509");
|
||||
}
|
||||
return this.GetCrlEntry(x509.SerialNumber);
|
||||
}
|
||||
|
||||
// Token: 0x06000A1C RID: 2588 RVA: 0x0002CF8C File Offset: 0x0002B18C
|
||||
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: 0x06000A1D RID: 2589 RVA: 0x0002CFF0 File Offset: 0x0002B1F0
|
||||
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$map11 == null)
|
||||
{
|
||||
X509Crl.<>f__switch$map11 = new Dictionary<string, int>(1) { { "1.2.840.10040.4.3", 0 } };
|
||||
}
|
||||
int num;
|
||||
if (X509Crl.<>f__switch$map11.TryGetValue(text, out num))
|
||||
{
|
||||
if (num == 0)
|
||||
{
|
||||
return this.VerifySignature(x509.DSA);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.VerifySignature(x509.RSA);
|
||||
}
|
||||
|
||||
// Token: 0x06000A1E RID: 2590 RVA: 0x0002D0F4 File Offset: 0x0002B2F4
|
||||
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: 0x06000A1F RID: 2591 RVA: 0x0002D1A8 File Offset: 0x0002B3A8
|
||||
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: 0x06000A20 RID: 2592 RVA: 0x0002D2A0 File Offset: 0x0002B4A0
|
||||
internal bool VerifySignature(RSA rsa)
|
||||
{
|
||||
RSAPKCS1SignatureDeformatter rsapkcs1SignatureDeformatter = new RSAPKCS1SignatureDeformatter(rsa);
|
||||
rsapkcs1SignatureDeformatter.SetHashAlgorithm(this.GetHashName());
|
||||
return rsapkcs1SignatureDeformatter.VerifySignature(this.Hash, this.signature);
|
||||
}
|
||||
|
||||
// Token: 0x06000A21 RID: 2593 RVA: 0x0002D2D4 File Offset: 0x0002B4D4
|
||||
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: 0x06000A22 RID: 2594 RVA: 0x0002D338 File Offset: 0x0002B538
|
||||
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: 0x04000283 RID: 643
|
||||
private string issuer;
|
||||
|
||||
// Token: 0x04000284 RID: 644
|
||||
private byte version;
|
||||
|
||||
// Token: 0x04000285 RID: 645
|
||||
private DateTime thisUpdate;
|
||||
|
||||
// Token: 0x04000286 RID: 646
|
||||
private DateTime nextUpdate;
|
||||
|
||||
// Token: 0x04000287 RID: 647
|
||||
private ArrayList entries;
|
||||
|
||||
// Token: 0x04000288 RID: 648
|
||||
private string signatureOID;
|
||||
|
||||
// Token: 0x04000289 RID: 649
|
||||
private byte[] signature;
|
||||
|
||||
// Token: 0x0400028A RID: 650
|
||||
private X509ExtensionCollection extensions;
|
||||
|
||||
// Token: 0x0400028B RID: 651
|
||||
private byte[] encoded;
|
||||
|
||||
// Token: 0x0400028C RID: 652
|
||||
private byte[] hash_value;
|
||||
|
||||
// Token: 0x020000BB RID: 187
|
||||
public class X509CrlEntry
|
||||
{
|
||||
// Token: 0x06000A23 RID: 2595 RVA: 0x0002D3A4 File Offset: 0x0002B5A4
|
||||
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: 0x06000A24 RID: 2596 RVA: 0x0002D3D8 File Offset: 0x0002B5D8
|
||||
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: 0x17000137 RID: 311
|
||||
// (get) Token: 0x06000A25 RID: 2597 RVA: 0x0002D42C File Offset: 0x0002B62C
|
||||
public byte[] SerialNumber
|
||||
{
|
||||
get
|
||||
{
|
||||
return (byte[])this.sn.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000138 RID: 312
|
||||
// (get) Token: 0x06000A26 RID: 2598 RVA: 0x0002D440 File Offset: 0x0002B640
|
||||
public DateTime RevocationDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.revocationDate;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000139 RID: 313
|
||||
// (get) Token: 0x06000A27 RID: 2599 RVA: 0x0002D448 File Offset: 0x0002B648
|
||||
public X509ExtensionCollection Extensions
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extensions;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A28 RID: 2600 RVA: 0x0002D450 File Offset: 0x0002B650
|
||||
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: 0x0400028F RID: 655
|
||||
private byte[] sn;
|
||||
|
||||
// Token: 0x04000290 RID: 656
|
||||
private DateTime revocationDate;
|
||||
|
||||
// Token: 0x04000291 RID: 657
|
||||
private X509ExtensionCollection extensions;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C1 RID: 193
|
||||
internal class X509Extension
|
||||
{
|
||||
// Token: 0x06000A79 RID: 2681 RVA: 0x0002E9A0 File Offset: 0x0002CBA0
|
||||
protected X509Extension()
|
||||
{
|
||||
this.extnCritical = false;
|
||||
}
|
||||
|
||||
// Token: 0x06000A7A RID: 2682 RVA: 0x0002E9B0 File Offset: 0x0002CBB0
|
||||
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: 0x06000A7B RID: 2683 RVA: 0x0002EAF0 File Offset: 0x0002CCF0
|
||||
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: 0x06000A7C RID: 2684 RVA: 0x0002EB7C File Offset: 0x0002CD7C
|
||||
protected virtual void Decode()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A7D RID: 2685 RVA: 0x0002EB80 File Offset: 0x0002CD80
|
||||
protected virtual void Encode()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000156 RID: 342
|
||||
// (get) Token: 0x06000A7E RID: 2686 RVA: 0x0002EB84 File Offset: 0x0002CD84
|
||||
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: 0x17000157 RID: 343
|
||||
// (get) Token: 0x06000A7F RID: 2687 RVA: 0x0002EBE8 File Offset: 0x0002CDE8
|
||||
public string Oid
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnOid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000158 RID: 344
|
||||
// (get) Token: 0x06000A80 RID: 2688 RVA: 0x0002EBF0 File Offset: 0x0002CDF0
|
||||
// (set) Token: 0x06000A81 RID: 2689 RVA: 0x0002EBF8 File Offset: 0x0002CDF8
|
||||
public bool Critical
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnCritical;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.extnCritical = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000159 RID: 345
|
||||
// (get) Token: 0x06000A82 RID: 2690 RVA: 0x0002EC04 File Offset: 0x0002CE04
|
||||
public virtual string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.extnOid;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015A RID: 346
|
||||
// (get) Token: 0x06000A83 RID: 2691 RVA: 0x0002EC0C File Offset: 0x0002CE0C
|
||||
public ASN1 Value
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.extnValue == null)
|
||||
{
|
||||
this.Encode();
|
||||
}
|
||||
return this.extnValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A84 RID: 2692 RVA: 0x0002EC28 File Offset: 0x0002CE28
|
||||
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: 0x06000A85 RID: 2693 RVA: 0x0002ECD0 File Offset: 0x0002CED0
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.ASN1.GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000A86 RID: 2694 RVA: 0x0002ECE0 File Offset: 0x0002CEE0
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return this.extnOid.GetHashCode();
|
||||
}
|
||||
|
||||
// Token: 0x06000A87 RID: 2695 RVA: 0x0002ECF0 File Offset: 0x0002CEF0
|
||||
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: 0x06000A88 RID: 2696 RVA: 0x0002EDC0 File Offset: 0x0002CFC0
|
||||
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: 0x040002BA RID: 698
|
||||
protected string extnOid;
|
||||
|
||||
// Token: 0x040002BB RID: 699
|
||||
protected bool extnCritical;
|
||||
|
||||
// Token: 0x040002BC RID: 700
|
||||
protected ASN1 extnValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C2 RID: 194
|
||||
internal sealed class X509ExtensionCollection : CollectionBase, IEnumerable
|
||||
{
|
||||
// Token: 0x06000A89 RID: 2697 RVA: 0x0002EE28 File Offset: 0x0002D028
|
||||
public X509ExtensionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000A8A RID: 2698 RVA: 0x0002EE30 File Offset: 0x0002D030
|
||||
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: 0x06000A8B RID: 2699 RVA: 0x0002EE9C File Offset: 0x0002D09C
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return base.InnerList.GetEnumerator();
|
||||
}
|
||||
|
||||
// Token: 0x06000A8C RID: 2700 RVA: 0x0002EEAC File Offset: 0x0002D0AC
|
||||
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: 0x06000A8D RID: 2701 RVA: 0x0002EEE4 File Offset: 0x0002D0E4
|
||||
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: 0x06000A8E RID: 2702 RVA: 0x0002EF3C File Offset: 0x0002D13C
|
||||
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: 0x06000A8F RID: 2703 RVA: 0x0002EFA0 File Offset: 0x0002D1A0
|
||||
public bool Contains(X509Extension extension)
|
||||
{
|
||||
return this.IndexOf(extension) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A90 RID: 2704 RVA: 0x0002EFB0 File Offset: 0x0002D1B0
|
||||
public bool Contains(string oid)
|
||||
{
|
||||
return this.IndexOf(oid) != -1;
|
||||
}
|
||||
|
||||
// Token: 0x06000A91 RID: 2705 RVA: 0x0002EFC0 File Offset: 0x0002D1C0
|
||||
public void CopyTo(X509Extension[] extensions, int index)
|
||||
{
|
||||
if (extensions == null)
|
||||
{
|
||||
throw new ArgumentNullException("extensions");
|
||||
}
|
||||
base.InnerList.CopyTo(extensions, index);
|
||||
}
|
||||
|
||||
// Token: 0x06000A92 RID: 2706 RVA: 0x0002EFE0 File Offset: 0x0002D1E0
|
||||
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: 0x06000A93 RID: 2707 RVA: 0x0002F03C File Offset: 0x0002D23C
|
||||
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: 0x06000A94 RID: 2708 RVA: 0x0002F09C File Offset: 0x0002D29C
|
||||
public void Insert(int index, X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
base.InnerList.Insert(index, extension);
|
||||
}
|
||||
|
||||
// Token: 0x06000A95 RID: 2709 RVA: 0x0002F0BC File Offset: 0x0002D2BC
|
||||
public void Remove(X509Extension extension)
|
||||
{
|
||||
if (extension == null)
|
||||
{
|
||||
throw new ArgumentNullException("extension");
|
||||
}
|
||||
base.InnerList.Remove(extension);
|
||||
}
|
||||
|
||||
// Token: 0x06000A96 RID: 2710 RVA: 0x0002F0DC File Offset: 0x0002D2DC
|
||||
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: 0x1700015B RID: 347
|
||||
public X509Extension this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return (X509Extension)base.InnerList[index];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015C RID: 348
|
||||
public X509Extension this[string oid]
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = this.IndexOf(oid);
|
||||
if (num == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (X509Extension)base.InnerList[num];
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000A99 RID: 2713 RVA: 0x0002F15C File Offset: 0x0002D35C
|
||||
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: 0x040002BD RID: 701
|
||||
private bool readOnly;
|
||||
}
|
||||
}
|
||||
@@ -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: 0x020000C3 RID: 195
|
||||
internal class X509Store
|
||||
{
|
||||
// Token: 0x06000A9A RID: 2714 RVA: 0x0002F1C8 File Offset: 0x0002D3C8
|
||||
internal X509Store(string path, bool crl)
|
||||
{
|
||||
this._storePath = path;
|
||||
this._crl = crl;
|
||||
}
|
||||
|
||||
// Token: 0x1700015D RID: 349
|
||||
// (get) Token: 0x06000A9B RID: 2715 RVA: 0x0002F1E0 File Offset: 0x0002D3E0
|
||||
public X509CertificateCollection Certificates
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._certificates == null)
|
||||
{
|
||||
this._certificates = this.BuildCertificatesCollection(this._storePath);
|
||||
}
|
||||
return this._certificates;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700015E RID: 350
|
||||
// (get) Token: 0x06000A9C RID: 2716 RVA: 0x0002F208 File Offset: 0x0002D408
|
||||
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: 0x1700015F RID: 351
|
||||
// (get) Token: 0x06000A9D RID: 2717 RVA: 0x0002F244 File Offset: 0x0002D444
|
||||
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: 0x06000A9E RID: 2718 RVA: 0x0002F288 File Offset: 0x0002D488
|
||||
public void Clear()
|
||||
{
|
||||
if (this._certificates != null)
|
||||
{
|
||||
this._certificates.Clear();
|
||||
}
|
||||
this._certificates = null;
|
||||
if (this._crls != null)
|
||||
{
|
||||
this._crls.Clear();
|
||||
}
|
||||
this._crls = null;
|
||||
}
|
||||
|
||||
// Token: 0x06000A9F RID: 2719 RVA: 0x0002F2D0 File Offset: 0x0002D4D0
|
||||
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: 0x06000AA0 RID: 2720 RVA: 0x0002F358 File Offset: 0x0002D558
|
||||
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: 0x06000AA1 RID: 2721 RVA: 0x0002F3D8 File Offset: 0x0002D5D8
|
||||
public void Remove(X509Certificate certificate)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(certificate));
|
||||
if (File.Exists(text))
|
||||
{
|
||||
File.Delete(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA2 RID: 2722 RVA: 0x0002F40C File Offset: 0x0002D60C
|
||||
public void Remove(X509Crl crl)
|
||||
{
|
||||
string text = Path.Combine(this._storePath, this.GetUniqueName(crl));
|
||||
if (File.Exists(text))
|
||||
{
|
||||
File.Delete(text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AA3 RID: 2723 RVA: 0x0002F440 File Offset: 0x0002D640
|
||||
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: 0x06000AA4 RID: 2724 RVA: 0x0002F488 File Offset: 0x0002D688
|
||||
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: 0x06000AA5 RID: 2725 RVA: 0x0002F4D0 File Offset: 0x0002D6D0
|
||||
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: 0x06000AA6 RID: 2726 RVA: 0x0002F500 File Offset: 0x0002D700
|
||||
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: 0x06000AA7 RID: 2727 RVA: 0x0002F560 File Offset: 0x0002D760
|
||||
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: 0x06000AA8 RID: 2728 RVA: 0x0002F5C4 File Offset: 0x0002D7C4
|
||||
private X509Certificate LoadCertificate(string filename)
|
||||
{
|
||||
byte[] array = this.Load(filename);
|
||||
return new X509Certificate(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000AA9 RID: 2729 RVA: 0x0002F5E4 File Offset: 0x0002D7E4
|
||||
private X509Crl LoadCrl(string filename)
|
||||
{
|
||||
byte[] array = this.Load(filename);
|
||||
return new X509Crl(array);
|
||||
}
|
||||
|
||||
// Token: 0x06000AAA RID: 2730 RVA: 0x0002F604 File Offset: 0x0002D804
|
||||
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: 0x06000AAB RID: 2731 RVA: 0x0002F670 File Offset: 0x0002D870
|
||||
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: 0x06000AAC RID: 2732 RVA: 0x0002F718 File Offset: 0x0002D918
|
||||
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: 0x040002BE RID: 702
|
||||
private string _storePath;
|
||||
|
||||
// Token: 0x040002BF RID: 703
|
||||
private X509CertificateCollection _certificates;
|
||||
|
||||
// Token: 0x040002C0 RID: 704
|
||||
private ArrayList _crls;
|
||||
|
||||
// Token: 0x040002C1 RID: 705
|
||||
private bool _crl;
|
||||
|
||||
// Token: 0x040002C2 RID: 706
|
||||
private string _name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C4 RID: 196
|
||||
internal sealed class X509StoreManager
|
||||
{
|
||||
// Token: 0x06000AAD RID: 2733 RVA: 0x0002F7C0 File Offset: 0x0002D9C0
|
||||
private X509StoreManager()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x17000160 RID: 352
|
||||
// (get) Token: 0x06000AAE RID: 2734 RVA: 0x0002F7C8 File Offset: 0x0002D9C8
|
||||
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: 0x17000161 RID: 353
|
||||
// (get) Token: 0x06000AAF RID: 2735 RVA: 0x0002F810 File Offset: 0x0002DA10
|
||||
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: 0x17000162 RID: 354
|
||||
// (get) Token: 0x06000AB0 RID: 2736 RVA: 0x0002F858 File Offset: 0x0002DA58
|
||||
public static X509CertificateCollection IntermediateCACertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000163 RID: 355
|
||||
// (get) Token: 0x06000AB1 RID: 2737 RVA: 0x0002F898 File Offset: 0x0002DA98
|
||||
public static ArrayList IntermediateCACrls
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.AddRange(X509StoreManager.CurrentUser.IntermediateCA.Crls);
|
||||
arrayList.AddRange(X509StoreManager.LocalMachine.IntermediateCA.Crls);
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000164 RID: 356
|
||||
// (get) Token: 0x06000AB2 RID: 2738 RVA: 0x0002F8D8 File Offset: 0x0002DAD8
|
||||
public static X509CertificateCollection TrustedRootCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000165 RID: 357
|
||||
// (get) Token: 0x06000AB3 RID: 2739 RVA: 0x0002F918 File Offset: 0x0002DB18
|
||||
public static ArrayList TrustedRootCACrls
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
arrayList.AddRange(X509StoreManager.CurrentUser.TrustedRoot.Crls);
|
||||
arrayList.AddRange(X509StoreManager.LocalMachine.TrustedRoot.Crls);
|
||||
return arrayList;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000166 RID: 358
|
||||
// (get) Token: 0x06000AB4 RID: 2740 RVA: 0x0002F958 File Offset: 0x0002DB58
|
||||
public static X509CertificateCollection UntrustedCertificates
|
||||
{
|
||||
get
|
||||
{
|
||||
X509CertificateCollection x509CertificateCollection = new X509CertificateCollection();
|
||||
x509CertificateCollection.AddRange(X509StoreManager.CurrentUser.Untrusted.Certificates);
|
||||
x509CertificateCollection.AddRange(X509StoreManager.LocalMachine.Untrusted.Certificates);
|
||||
return x509CertificateCollection;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040002C3 RID: 707
|
||||
private static X509Stores _userStore;
|
||||
|
||||
// Token: 0x040002C4 RID: 708
|
||||
private static X509Stores _machineStore;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C5 RID: 197
|
||||
internal class X509Stores
|
||||
{
|
||||
// Token: 0x06000AB5 RID: 2741 RVA: 0x0002F998 File Offset: 0x0002DB98
|
||||
internal X509Stores(string path)
|
||||
{
|
||||
this._storePath = path;
|
||||
}
|
||||
|
||||
// Token: 0x17000167 RID: 359
|
||||
// (get) Token: 0x06000AB6 RID: 2742 RVA: 0x0002F9A8 File Offset: 0x0002DBA8
|
||||
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: 0x17000168 RID: 360
|
||||
// (get) Token: 0x06000AB7 RID: 2743 RVA: 0x0002F9E4 File Offset: 0x0002DBE4
|
||||
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: 0x17000169 RID: 361
|
||||
// (get) Token: 0x06000AB8 RID: 2744 RVA: 0x0002FA20 File Offset: 0x0002DC20
|
||||
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: 0x1700016A RID: 362
|
||||
// (get) Token: 0x06000AB9 RID: 2745 RVA: 0x0002FA5C File Offset: 0x0002DC5C
|
||||
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: 0x1700016B RID: 363
|
||||
// (get) Token: 0x06000ABA RID: 2746 RVA: 0x0002FA98 File Offset: 0x0002DC98
|
||||
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: 0x06000ABB RID: 2747 RVA: 0x0002FAD4 File Offset: 0x0002DCD4
|
||||
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: 0x06000ABC RID: 2748 RVA: 0x0002FB74 File Offset: 0x0002DD74
|
||||
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: 0x040002C5 RID: 709
|
||||
private string _storePath;
|
||||
|
||||
// Token: 0x040002C6 RID: 710
|
||||
private X509Store _personal;
|
||||
|
||||
// Token: 0x040002C7 RID: 711
|
||||
private X509Store _other;
|
||||
|
||||
// Token: 0x040002C8 RID: 712
|
||||
private X509Store _intermediate;
|
||||
|
||||
// Token: 0x040002C9 RID: 713
|
||||
private X509Store _trusted;
|
||||
|
||||
// Token: 0x040002CA RID: 714
|
||||
private X509Store _untrusted;
|
||||
|
||||
// Token: 0x020000C6 RID: 198
|
||||
public class Names
|
||||
{
|
||||
// Token: 0x040002CB RID: 715
|
||||
public const string Personal = "My";
|
||||
|
||||
// Token: 0x040002CC RID: 716
|
||||
public const string OtherPeople = "AddressBook";
|
||||
|
||||
// Token: 0x040002CD RID: 717
|
||||
public const string IntermediateCA = "CA";
|
||||
|
||||
// Token: 0x040002CE RID: 718
|
||||
public const string TrustedRoot = "Trust";
|
||||
|
||||
// Token: 0x040002CF RID: 719
|
||||
public const string Untrusted = "Disallowed";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Mono.Security.X509
|
||||
{
|
||||
// Token: 0x020000C7 RID: 199
|
||||
internal class X520
|
||||
{
|
||||
// Token: 0x020000C8 RID: 200
|
||||
public abstract class AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ABF RID: 2751 RVA: 0x0002FBCC File Offset: 0x0002DDCC
|
||||
protected AttributeTypeAndValue(string oid, int upperBound)
|
||||
{
|
||||
this.oid = oid;
|
||||
this.upperBound = upperBound;
|
||||
this.encoding = byte.MaxValue;
|
||||
}
|
||||
|
||||
// Token: 0x06000AC0 RID: 2752 RVA: 0x0002FBF0 File Offset: 0x0002DDF0
|
||||
protected AttributeTypeAndValue(string oid, int upperBound, byte encoding)
|
||||
{
|
||||
this.oid = oid;
|
||||
this.upperBound = upperBound;
|
||||
this.encoding = encoding;
|
||||
}
|
||||
|
||||
// Token: 0x1700016C RID: 364
|
||||
// (get) Token: 0x06000AC1 RID: 2753 RVA: 0x0002FC10 File Offset: 0x0002DE10
|
||||
// (set) Token: 0x06000AC2 RID: 2754 RVA: 0x0002FC18 File Offset: 0x0002DE18
|
||||
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: 0x1700016D RID: 365
|
||||
// (get) Token: 0x06000AC3 RID: 2755 RVA: 0x0002FC70 File Offset: 0x0002DE70
|
||||
public ASN1 ASN1
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetASN1();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000AC4 RID: 2756 RVA: 0x0002FC78 File Offset: 0x0002DE78
|
||||
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: 0x06000AC5 RID: 2757 RVA: 0x0002FD48 File Offset: 0x0002DF48
|
||||
internal ASN1 GetASN1()
|
||||
{
|
||||
return this.GetASN1(this.encoding);
|
||||
}
|
||||
|
||||
// Token: 0x06000AC6 RID: 2758 RVA: 0x0002FD58 File Offset: 0x0002DF58
|
||||
public byte[] GetBytes(byte encoding)
|
||||
{
|
||||
return this.GetASN1(encoding).GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000AC7 RID: 2759 RVA: 0x0002FD68 File Offset: 0x0002DF68
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return this.GetASN1().GetBytes();
|
||||
}
|
||||
|
||||
// Token: 0x06000AC8 RID: 2760 RVA: 0x0002FD78 File Offset: 0x0002DF78
|
||||
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: 0x040002D0 RID: 720
|
||||
private string oid;
|
||||
|
||||
// Token: 0x040002D1 RID: 721
|
||||
private string attrValue;
|
||||
|
||||
// Token: 0x040002D2 RID: 722
|
||||
private int upperBound;
|
||||
|
||||
// Token: 0x040002D3 RID: 723
|
||||
private byte encoding;
|
||||
}
|
||||
|
||||
// Token: 0x020000C9 RID: 201
|
||||
public class Name : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AC9 RID: 2761 RVA: 0x0002FDD8 File Offset: 0x0002DFD8
|
||||
public Name()
|
||||
: base("2.5.4.41", 32768)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CA RID: 202
|
||||
public class CommonName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACA RID: 2762 RVA: 0x0002FDEC File Offset: 0x0002DFEC
|
||||
public CommonName()
|
||||
: base("2.5.4.3", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CB RID: 203
|
||||
public class SerialNumber : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACB RID: 2763 RVA: 0x0002FDFC File Offset: 0x0002DFFC
|
||||
public SerialNumber()
|
||||
: base("2.5.4.5", 64, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CC RID: 204
|
||||
public class LocalityName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACC RID: 2764 RVA: 0x0002FE10 File Offset: 0x0002E010
|
||||
public LocalityName()
|
||||
: base("2.5.4.7", 128)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CD RID: 205
|
||||
public class StateOrProvinceName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACD RID: 2765 RVA: 0x0002FE24 File Offset: 0x0002E024
|
||||
public StateOrProvinceName()
|
||||
: base("2.5.4.8", 128)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CE RID: 206
|
||||
public class OrganizationName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACE RID: 2766 RVA: 0x0002FE38 File Offset: 0x0002E038
|
||||
public OrganizationName()
|
||||
: base("2.5.4.10", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000CF RID: 207
|
||||
public class OrganizationalUnitName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000ACF RID: 2767 RVA: 0x0002FE48 File Offset: 0x0002E048
|
||||
public OrganizationalUnitName()
|
||||
: base("2.5.4.11", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D0 RID: 208
|
||||
public class EmailAddress : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD0 RID: 2768 RVA: 0x0002FE58 File Offset: 0x0002E058
|
||||
public EmailAddress()
|
||||
: base("1.2.840.113549.1.9.1", 128, 22)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D1 RID: 209
|
||||
public class DomainComponent : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD1 RID: 2769 RVA: 0x0002FE6C File Offset: 0x0002E06C
|
||||
public DomainComponent()
|
||||
: base("0.9.2342.19200300.100.1.25", int.MaxValue, 22)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D2 RID: 210
|
||||
public class UserId : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD2 RID: 2770 RVA: 0x0002FE80 File Offset: 0x0002E080
|
||||
public UserId()
|
||||
: base("0.9.2342.19200300.100.1.1", 256)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D3 RID: 211
|
||||
public class Oid : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD3 RID: 2771 RVA: 0x0002FE94 File Offset: 0x0002E094
|
||||
public Oid(string oid)
|
||||
: base(oid, int.MaxValue)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D4 RID: 212
|
||||
public class Title : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD4 RID: 2772 RVA: 0x0002FEA4 File Offset: 0x0002E0A4
|
||||
public Title()
|
||||
: base("2.5.4.12", 64)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D5 RID: 213
|
||||
public class CountryName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD5 RID: 2773 RVA: 0x0002FEB4 File Offset: 0x0002E0B4
|
||||
public CountryName()
|
||||
: base("2.5.4.6", 2, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D6 RID: 214
|
||||
public class DnQualifier : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD6 RID: 2774 RVA: 0x0002FEC4 File Offset: 0x0002E0C4
|
||||
public DnQualifier()
|
||||
: base("2.5.4.46", 2, 19)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D7 RID: 215
|
||||
public class Surname : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD7 RID: 2775 RVA: 0x0002FED4 File Offset: 0x0002E0D4
|
||||
public Surname()
|
||||
: base("2.5.4.4", 32768)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D8 RID: 216
|
||||
public class GivenName : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD8 RID: 2776 RVA: 0x0002FEE8 File Offset: 0x0002E0E8
|
||||
public GivenName()
|
||||
: base("2.5.4.42", 16)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x020000D9 RID: 217
|
||||
public class Initial : X520.AttributeTypeAndValue
|
||||
{
|
||||
// Token: 0x06000AD9 RID: 2777 RVA: 0x0002FEF8 File Offset: 0x0002E0F8
|
||||
public Initial()
|
||||
: base("2.5.4.43", 5)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user