pub fn any<'cert>(
    buf: &mut untrusted::Reader<'cert>,
) -> Result<(Tag, untrusted::Input<'cert>), Error> {
    let tag = Tag::parse(buf)?;
    let len_byte = buf.read_byte()?;
    // NOTE: the header is always two bytes long.

    // If `len` has the high bit set, then it is a "long form" length.
    let len = if len_byte & 0x80 == 0 {
        len_byte as usize
    } else {
        let num_bytes = len_byte & 0x7f;

        if num_bytes == 0 || num_bytes > 4 {
            // We only support lengths at most 32 bits.
            //
            // This also catches indefinite-length constructed objects,
            // which we absolutely don't support.
            return Err(Error::BadEncoding);
        }

        let len = be(buf, num_bytes as usize)?;
        if len < 128 {
            // This should have been a short-form encoding.
            return Err(Error::BadEncoding);
        }
        if len >> ((num_bytes - 1) * 8) == 0 {
            // Superfluous zero bytes; the encoding was not
            // minimal.
            return Err(Error::BadEncoding);
        }
        len as usize
    };

    let data = buf.read_bytes(len)?;
    Ok((tag, data))
}
/// Parse a single element of a `SEQUENCE`, returning its tag and contents.
Parse a single element of a `SEQUENCE`, returning its tag and contents.
Parse a single element of a ` SEQUENCE ` returning its tag and contents .
pub fn any<'cert>(
    buf: &mut untrusted::Reader<'cert>,
) -> Result<(Tag, untrusted::Input<'cert>), Error> {
    let tag = Tag::parse(buf)?;
    let len_byte = buf.read_byte()?;
    // NOTE: the header is always two bytes long.
    // If `len` has the high bit set, then it is a "long form" length.
    let len = if len_byte & 0x80 == 0 {
        len_byte as usize
    } else {
        let num_bytes = len_byte & 0x7f;
        if num_bytes == 0 || num_bytes > 4 {
            // We only support lengths at most 32 bits.
            //
            // This also catches indefinite-length constructed objects,
            // which we absolutely don't support.
            return Err(Error::BadEncoding);
        }
        let len = be(buf, num_bytes as usize)?;
        if len < 128 {
            // This should have been a short-form encoding.
            return Err(Error::BadEncoding);
        }
        if len >> ((num_bytes - 1) * 8) == 0 {
            // Superfluous zero bytes; the encoding was not
            // minimal.
            return Err(Error::BadEncoding);
        }
        len as usize
    };
    let data = buf.read_bytes(len)?;
    Ok((tag, data))
}
pub fn any < ' cert > ( buf : & mut untrusted :: Reader < ' cert > , ) -> Result < ( Tag , untrusted :: Input < ' cert > ) , Error > { let tag = Tag :: parse ( buf ) ? ; let len_byte = buf . read_byte ( ) ? ; // NOTE: the header is always two bytes long. // If `len` has the high bit set, then it is a "long form" length. let len = if len_byte & 0x80 == 0 { len_byte as usize } else { let num_bytes = len_byte & 0x7f ; if num_bytes == 0 || num_bytes > 4 { // We only support lengths at most 32 bits. // // This also catches indefinite-length constructed objects, // which we absolutely don't support. return Err ( Error :: BadEncoding ) ; } let len = be ( buf , num_bytes as usize ) ? ; if len < 128 { // This should have been a short-form encoding. return Err ( Error :: BadEncoding ) ; } if len >> ( ( num_bytes - 1 ) * 8 ) == 0 { // Superfluous zero bytes; the encoding was not // minimal. return Err ( Error :: BadEncoding ) ; } len as usize } ; let data = buf . read_bytes ( len ) ? ; Ok ( ( tag , data ) ) }
Parse a single element of a `SEQUENCE`, returning its tag and contents.
Parse a single element of a ` SEQUENCE ` returning its tag and contents .
buf
&mut untrusted::Reader<'cert>
buf
&mut untrusted::Reader<'cert>