public static AsnBoolean Decode(byte[] source, ref int pos) { AsnBoolean instance = new AsnBoolean(); //CheckContextTag(source, ref pos); pos++; long length = instance.GetLength(source, ref pos); instance.value = (bool)(source[pos] != 0); pos++; return(instance); }
public static AsnExtension Decode(byte[] source, ref int pos) { AsnExtension instance = new AsnExtension(); pos++; long len = instance.GetLength(source, ref pos); instance.extnID = AsnOid.Decode(source, ref pos); if (source[pos] == 0x1) { instance.critical = AsnBoolean.Decode(source, ref pos); } instance.extnValue = AsnOctetstring.Decode(source, ref pos); return(instance); }
// TODO: note 4.1.2.9 of RFC5280 - there are some additional requirements on CAs // especially regarding the optional path length stuff public void ExtensionBasicConstraints(bool ca) { if (extensions == null) { extensions = new AsnExtensions(); } AsnBoolean caFlag = new AsnBoolean(ca); int length = caFlag.Encode(); byte[] bytes = new byte[length + 2]; bytes[0] = 0x30; // it's a sequence bytes[1] = (byte)length; Array.Copy(caFlag.derValue, 0, bytes, 2, caFlag.derValue.Length); AsnExtension extension = new AsnExtension(new AsnOid("2.5.29.19"), true, bytes); extensions.extensions.Add(extension); }
public AsnExtension(string oid, bool isCritical, byte[] value) { extnID = new AsnOid(oid); critical = new AsnBoolean(isCritical); extnValue = new AsnOctetstring(value); }