internal byte[] ReadOctetString(Asn1Tag?expectedTag = default) { byte[] ret = AsnDecoder.ReadOctetString( _span, _ruleSet, out int consumed, expectedTag); _span = _span.Slice(consumed); return(ret); }
/// <summary> /// Reads the next value as an OCTET STRING with tag UNIVERSAL 4, returning the value /// in a byte array. /// </summary> /// <param name="expectedTag"> /// The tag to check for before reading, or <see langword="null"/> for the default tag (Universal 4). /// </param> /// <returns> /// A copy of the value in a newly allocated, precisely sized, array. /// </returns> /// <exception cref="AsnContentException"> /// the next value does not have the correct tag. /// /// -or- /// /// the length encoding is not valid under the current encoding rules. /// /// -or- /// /// the contents are not valid under the current encoding rules. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagClass"/> is /// <see cref="TagClass.Universal"/>, but /// <paramref name="expectedTag"/>.<see cref="Asn1Tag.TagValue"/> is not correct for /// the method. /// </exception> /// <seealso cref="TryReadPrimitiveOctetString"/> /// <seealso cref="TryReadOctetString"/> public byte[] ReadOctetString(Asn1Tag?expectedTag = null) { byte[] ret = AsnDecoder.ReadOctetString(_data.Span, RuleSet, out int consumed, expectedTag); _data = _data.Slice(consumed); return(ret); }