-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
[Backport 2.28] Fix bugs in OID to string conversion #7138
Merged
gilles-peskine-arm
merged 9 commits into
Mbed-TLS:mbedtls-2.28
from
davidhorstmann-arm:2.28-fix-oid-printing-bug
Feb 21, 2023
Merged
[Backport 2.28] Fix bugs in OID to string conversion #7138
gilles-peskine-arm
merged 9 commits into
Mbed-TLS:mbedtls-2.28
from
davidhorstmann-arm:2.28-fix-oid-printing-bug
Feb 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The first 2 components of an OID are combined together into the same subidentifier via the formula: subidentifier = (component1 * 40) + component2 The current code extracts component1 and component2 using division and modulo as one would expect. However, there is a subtlety in the specification[1]: >This packing of the first two object identifier components recognizes >that only three values are allocated from the root node, and at most >39 subsequent values from nodes reached by X = 0 and X = 1. If the root node (component1) is 2, the subsequent node (component2) may be greater than 38. For example, the following are real OIDs: * 2.40.0.25, UPU standard S25 * 2.49.0.0.826.0, Met Office * 2.999, Allocated example OID This has 2 implications that the current parsing code does not take account of: 1. The second component may be > 39, so (subidentifier % 40) is not correct in all circumstances. 2. The first subidentifier (containing the first 2 components) may be more than one byte long. Currently we assume it is just 1 byte. Improve parsing code to deal with these cases correctly. [1] Rec. ITU-T X.690 (02/2021), 8.19.4 Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: David Horstmann <[email protected]>
OID subidentifiers are encoded as follow. For every byte: * The top bit is 1 if there is another byte to come, 0 if this is the last byte. * The other 7 bits form 7 bits of the number. These groups of 7 are concatenated together in big-endian order. Overlong encodings are explicitly disallowed by the BER/DER/X690 specification. For example, the number 1 cannot be encoded as: 0x80 0x80 0x01 It must be encoded as: 0x01 Enforce this in Mbed TLS' OID DER-to-string parser. Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: David Horstmann <[email protected]>
Signed-off-by: David Horstmann <[email protected]>
The more precise error codes are borrowed from the ASN1 module. Signed-off-by: David Horstmann <[email protected]>
3 tasks
tom-cosgrove-arm
previously approved these changes
Feb 20, 2023
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.
LGTM - faithful backport
tom-cosgrove-arm
added
bug
approved
Design and code approved - may be waiting for CI or backports
component-x509
needs-ci
Needs to pass CI tests
single-reviewer
This PR qualifies for having only one reviewer
labels
Feb 20, 2023
Signed-off-by: David Horstmann <[email protected]>
davidhorstmann-arm
added
needs-review
Every commit must be reviewed by at least two team members,
and removed
approved
Design and code approved - may be waiting for CI or backports
labels
Feb 20, 2023
tom-cosgrove-arm
approved these changes
Feb 20, 2023
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.
LGTM
davidhorstmann-arm
added
approved
Design and code approved - may be waiting for CI or backports
and removed
needs-review
Every commit must be reviewed by at least two team members,
labels
Feb 20, 2023
gilles-peskine-arm
approved these changes
Feb 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
approved
Design and code approved - may be waiting for CI or backports
bug
component-x509
single-reviewer
This PR qualifies for having only one reviewer
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trivial backport of #7105.
Gatekeeper checklist
or not requiredor not required