Function der_parser::parse_der_integer [] [src]

pub fn parse_der_integer(i: &[u8]) -> IResult<&[u8], DerObject>

Read an integer value

The encoding of a boolean value shall be primitive. The contents octets shall consist of one or more octets.

To access the content, use the as_u64, as_u32, as_biguint or as_bigint methods. Remember that a DER integer has unlimited size, so these methods return Result or Option objects.

Examples

let empty = &b""[..];
let bytes = [0x02, 0x03, 0x01, 0x00, 0x01];
let expected  = DerObject::from_obj(DerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
    parse_der_integer(&bytes),
    IResult::Done(empty, expected)
);