Skip to content

Commit

Permalink
der: fix MAX_DER for 32bit targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpu committed Jul 5, 2023
1 parent cfa1281 commit 0f0c601
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/der.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,14 @@ const LONG_FORM_LEN_THREE_BYTES_MAX: usize = (1 << (8 * 3)) - 1;
// Leading octet for long definite form DER length expressed in subsequent four bytes.
const LONG_FORM_LEN_FOUR_BYTES: u8 = 0x84;

#[cfg(target_pointer_width = "64")]
// Maximum size that can be expressed in a four byte long form der len.
const LONG_FORM_LEN_FOUR_BYTES_MAX: usize = (1 << (8 * 4)) - 1;

#[cfg(target_pointer_width = "32")]
// Maximum size that can be expressed on 32 bit platforms is the usize limit.
const LONG_FORM_LEN_FOUR_BYTES_MAX: usize = usize::MAX;

// TODO: investigate taking decoder as a reference to reduce generated code
// size.
pub(crate) fn nested_of_mut<'a, E>(
Expand Down

0 comments on commit 0f0c601

Please sign in to comment.