-
Notifications
You must be signed in to change notification settings - Fork 154
der, x509-cert: fix handling of negative integers #831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
130f52c
b9ee5e4
054d0ca
234f858
5652f96
20f0dd8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//! Support for encoding negative integers | ||
//! Support for encoding signed integers | ||
|
||
use super::is_highest_bit_set; | ||
use crate::{ErrorKind, Length, Result, Tag, Writer}; | ||
|
@@ -46,9 +46,9 @@ where | |
writer.write(strip_leading_ones(bytes)) | ||
} | ||
|
||
/// Get the encoded length for the given signed integer serialized as bytes. | ||
/// Get the encoded length for the given **negative** integer serialized as bytes. | ||
#[inline] | ||
pub(super) fn encoded_len(bytes: &[u8]) -> Result<Length> { | ||
pub(super) fn negative_encoded_len(bytes: &[u8]) -> Result<Length> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N.B.: I renamed this to emphasize what this function is actually doing, as currently implemented: it doesn't calculate the encoded length of any signed integer represented as bytes, but only negative signed integers. Passing a positive signed integer here would result in the wrong length, since we only trim leading ones, not zeroes. (I confirmed that the one remaining callsite for this only calls it on negative integers, and removed the other misleading callsites.) |
||
Length::try_from(strip_leading_ones(bytes).len()) | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.