private void ParseCons(IAsn1TaggedEventHandler handler, int len) { var tag2 = new Asn1Tag(); var holder = new IntHolder(); var byteCount = base.ByteCount; while (true) { ParseElement(handler, tag2, holder); if (len == Asn1Status.IndefiniteLength) { if (tag2.IsEoc() && (holder.Value == 0)) { return; } continue; } if ((base.ByteCount - byteCount) >= len) { return; } } }
private void ParseElement(IAsn1TaggedEventHandler handler, Asn1Tag tag, IntHolder len) { _parserCaptureBuffer.Seek(0L, SeekOrigin.Begin); _parserCaptureBuffer.SetLength(0L); len.Value = DecodeTagAndLength(tag); if (!tag.IsEoc() || (len.Value != 0)) { handler.StartElement(tag, len.Value, _parserCaptureBuffer.ToArray()); _parserCaptureBuffer.Seek(0L, SeekOrigin.Begin); _parserCaptureBuffer.SetLength(0L); if ((len.Value > 0) || (len.Value == Asn1Status.IndefiniteLength)) { if (tag.Constructed) { ParseCons(handler, len.Value); } else { ParsePrim(handler, len.Value); } } handler.EndElement(tag); } }
protected void MovePastEoc(bool saveData) { var tag = new Asn1Tag(); var num = 1; while (num > 0) { var nbytes = DecodeTagAndLength(tag); if (nbytes > 0) { if (saveData) { Capture(nbytes); } else { Skip(nbytes); } } else if (nbytes == Asn1Status.IndefiniteLength) { num++; } else if (tag.IsEoc() && (nbytes == 0)) { num--; } } }
public static int CalcIndefLen(byte[] data, int offset, int len) { Asn1BerDecodeBuffer buffer; if ((offset == 0) && (len == data.Length)) { buffer = new Asn1BerDecodeBuffer(data); } else { var destinationArray = new byte[len]; Array.Copy(data, offset, destinationArray, 0, len); buffer = new Asn1BerDecodeBuffer(destinationArray); } var tag = new Asn1Tag(); var num = buffer.DecodeTagAndLength(tag); if (num == Asn1Status.IndefiniteLength) { var num2 = 1; num = 0; while (num2 > 0) { var byteCount = buffer.ByteCount; var num4 = buffer.DecodeTagAndLength(tag); num += buffer.ByteCount - byteCount; if (num4 > 0) { buffer.Skip(num4); num += num4; } else { if (num4 == Asn1Status.IndefiniteLength) { num2++; continue; } if (tag.IsEoc() && (num4 == 0)) { num2--; } } } } return(num); }
public static int CalcIndefLen(byte[] data, int offset, int len) { Asn1BerDecodeBuffer buffer; if ((offset == 0) && (len == data.Length)) { buffer = new Asn1BerDecodeBuffer(data); } else { var destinationArray = new byte[len]; Array.Copy(data, offset, destinationArray, 0, len); buffer = new Asn1BerDecodeBuffer(destinationArray); } var tag = new Asn1Tag(); var num = buffer.DecodeTagAndLength(tag); if (num == Asn1Status.IndefiniteLength) { var num2 = 1; num = 0; while (num2 > 0) { var byteCount = buffer.ByteCount; var num4 = buffer.DecodeTagAndLength(tag); num += buffer.ByteCount - byteCount; if (num4 > 0) { buffer.Skip(num4); num += num4; } else { if (num4 == Asn1Status.IndefiniteLength) { num2++; continue; } if (tag.IsEoc() && (num4 == 0)) { num2--; } } } } return num; }