307 lines
7.0 KiB
C#
307 lines
7.0 KiB
C#
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)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|