Files
Dec2017-Script-Dump/mscorlib/Mono/Security/X509/Extensions/BasicConstraintsExtension.cs
T
2026-06-04 11:42:34 +02:00

143 lines
3.5 KiB
C#

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;
}
}