pub fn parse_der_integer(i: &[u8]) -> Result<(&[u8], BerObject<'_>), Err<Error>>
Available on crate feature
mtls
only.Expand description
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 BER 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),
Ok((empty, expected))
);