/// <summary> /// Read sequnce. (only check the value type) /// </summary> /// <returns>true if succeeded.</returns> public bool ReadSequence() { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.IsConstructed == true && tagInfo.TagNumber == TAG_SEQUENCE && (tagInfo.Length == LENGTH_INDEFINITE || tagInfo.Length > 0)) { return true; } return false; }
/// <summary> /// Read sequnce. (only check the value type) /// </summary> /// <returns>true if succeeded.</returns> public bool ReadSequence() { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.IsConstructed == true && tagInfo.TagNumber == TAG_SEQUENCE && (tagInfo.Length == LENGTH_INDEFINITE || tagInfo.Length > 0)) { return(true); } return(false); }
/// <summary> /// Read tag. (only check the value type) /// </summary> /// <param name="tagClass">expected tag class</param> /// <param name="isConstructed">expected value of "constructed" flag</param> /// <param name="tagNumber">expected tag number</param> /// <param name="length">length of the value field will be stored</param> /// <returns>true if succeeded.</returns> public bool ReadTag(TagClass tagClass, bool isConstructed, int tagNumber, out int length) { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.ClassBits == (int)tagClass && tagInfo.IsConstructed == isConstructed && tagInfo.TagNumber == tagNumber) { length = tagInfo.Length; return(true); } length = 0; return(false); }
/// <summary> /// Read integer. /// </summary> /// <param name="bigint">BigInteger instance will be stored if succeeded.</param> /// <returns>true if succeeded.</returns> public bool ReadInteger(out BigInteger bigint) { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.IsConstructed == false && tagInfo.TagNumber == TAG_INTEGER && tagInfo.Length != LENGTH_INDEFINITE && tagInfo.Length > 0) { byte[] buff = new byte[tagInfo.Length]; int len = strm.Read(buff, 0, tagInfo.Length); if (len == tagInfo.Length) { bigint = new BigInteger(buff); return true; } } bigint = null; return false; }
/// <summary> /// Read integer. /// </summary> /// <param name="bigint">BigInteger instance will be stored if succeeded.</param> /// <returns>true if succeeded.</returns> public bool ReadInteger(out BigInteger bigint) { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.IsConstructed == false && tagInfo.TagNumber == TAG_INTEGER && tagInfo.Length != LENGTH_INDEFINITE && tagInfo.Length > 0) { byte[] buff = new byte[tagInfo.Length]; int len = strm.Read(buff, 0, tagInfo.Length); if (len == tagInfo.Length) { bigint = new BigInteger(buff); return(true); } } bigint = null; return(false); }
internal bool ReadTagInfo(ref BERTagInfo tagInfo) { return(ReadTag(ref tagInfo.ClassBits, ref tagInfo.IsConstructed, ref tagInfo.TagNumber) && ReadLength(ref tagInfo.Length)); }
internal bool ReadTagInfo(ref BERTagInfo tagInfo) { return ReadTag(ref tagInfo.ClassBits, ref tagInfo.IsConstructed, ref tagInfo.TagNumber) && ReadLength(ref tagInfo.Length); }
/// <summary> /// Read tag. (only check the value type) /// </summary> /// <param name="tagClass">expected tag class</param> /// <param name="isConstructed">expected value of "constructed" flag</param> /// <param name="tagNumber">expected tag number</param> /// <param name="length">length of the value field will be stored</param> /// <returns>true if succeeded.</returns> public bool ReadTag(TagClass tagClass, bool isConstructed, int tagNumber, out int length) { BERTagInfo tagInfo = new BERTagInfo(); if (ReadTagInfo(ref tagInfo) && tagInfo.ClassBits == (int)tagClass && tagInfo.IsConstructed == isConstructed && tagInfo.TagNumber == tagNumber) { length = tagInfo.Length; return true; } length = 0; return false; }