-
Notifications
You must be signed in to change notification settings - Fork 153
Negative test case for constructed, definite-length octet string #1931
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
base: master
Are you sure you want to change the base?
Negative test case for constructed, definite-length octet string #1931
Conversation
This is incomplete, but here’s an attempt at ensuring that constructed, definite-length method encoded octet strings are detected and rejected. Seeking feedback; I made a few attempts but finally realized what you, @dishmaker, meant by your comment As the I thought it might be fair game to draft a change to the |
94e1198
to
78a3118
Compare
Propagating the original |
@@ -13,6 +13,8 @@ pub struct Header { | |||
|
|||
/// Length of the encoded value | |||
pub length: Length, | |||
|
|||
constructed: bool, |
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.
Hmm, not sure how I feel about the mixed visibility here. Maybe make it pub
for now and perhaps we could have a followup to make all of the fields private? (I imagine that would be a bit more invasive)
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.
Yep, definitely ugly.
Revised in 544e397
and perhaps we could have a followup to make all of the fields private? (I imagine that would be a bit more invasive)
I counted 24 occurrences in the der crate; for now I also added accessor methods so that new code has the option to use them in the event that the fields become private.
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.
Maybe just go through with it, if it seems mostly internal to the der
crate
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.
I went through with it: 0c5789e
However, tests are failing due to at least
https://github.com/RustCrypto/signatures/blob/1ff759e67a1675d759e901fdb5903a07a1d7caec/ecdsa/src/der.rs#L206-L210
It looks like this change would have to be phased in?
Should I
- roll back all the changes for using accessor methods rather than directly accessing struct fields, OR
- roll back making the fields private but keep the pattern of using accessor methods rather than direct field access
?
78a3118
to
544e397
Compare
Ensure octet strings with constructed, definite-length method return an error, rather than an incorrect decoding.
544e397
to
0c5789e
Compare
Ensure octet strings with constructed, definite-length method return an error, rather than an incorrect decoding.