-
Notifications
You must be signed in to change notification settings - Fork 14
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
reject non canonical encoding length. #29
Conversation
spdmlib/src/crypto/x509v3.rs
Outdated
length[i] = *b; | ||
let length_byte0 = data[0]; | ||
let (length, byte_comsumed) = match length_byte0 { | ||
n if (n & 0x80) == 0 => (n as usize, 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't use hardcoded 0x80 or 0x81.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please don't use hardcoded 0x80 or 0x81.
updated.
@@ -25,7 +25,6 @@ const ASN1_TAG_SEQUENCE: u8 = | |||
ASN1_TAG_CLASS_UNIVERSAL_MASK | ASN1_FORM_CONSTRUCTED_MASK | ASN1_TAG_NUMBER_SEQUENCE; | |||
const ASN1_TAG_EXPLICIT_EXTENSION: u8 = 0xA3; | |||
const ASN1_TAG_EXTN_VALUE: u8 = 0x04; | |||
const ASN1_LENGTH_MULTI_OCTET_MASK: u8 = 0x80; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove it?
updated.
spdmlib/src/crypto/x509v3.rs
Outdated
let length_byte0 = data[0]; | ||
let (length, byte_comsumed) = match length_byte0 { | ||
n if (n & ASN1_LENGTH_MULTI_OCTET_MASK) == 0 => (n as usize, 1), | ||
one_octet if one_octet == ASN1_LENGTH_MULTI_OCTET_MASK + 1 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please define a new static variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please define a new static variable.
updated.
spdmlib/src/crypto/x509v3.rs
Outdated
} | ||
Ok((usize::from_le_bytes(length), length_count as usize + 1)) | ||
} | ||
two_octet if two_octet == ASN1_LENGTH_MULTI_OCTET_MASK + 2 => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please define a new static variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please define a new static variable.
updated.
fix ccc-spdm-tools#28. Signed-off-by: Yang, Longlong <[email protected]>
fix #28.