Skip to main content

read_integer

Function read_integer 

Source
pub fn read_integer(input: &[u8]) -> Option<(&[u8], &[u8])>
Expand description

Read a DER INTEGER.

Returns the canonical unsigned big-endian content bytes (with the disambiguating 0x00 pad stripped, if present) and the remainder. The single-byte [0x00] (canonical zero) is returned as-is; callers that disallow zero must check bytes == &[0x00] post-read.

Strict-canonical rules per X.690 §8.3.2 / §10.2:

  • empty content rejected;
  • sign-bit-set first byte without 0x00 pad rejected (would be negative in two’s complement);
  • redundant 0x00 leading-pad (BER style) rejected.