-
Notifications
You must be signed in to change notification settings - Fork 73
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
JER BIT STRING quoted hex #133
Conversation
My apologies - by now I managed to forget what the intended effect of this PR would be, compared with the current behavior. Could you please refresh my memory, and maybe give a couple of examples? |
Sorry about that, I could have added more details.
With
However, X.697 (Section 24 - Encoding of bitstring values) mandates to use an hex encoding for the BIT STRING. This PR fixes both of these issues. The encoding of the above becomes:
A bit awkward with the displaced comma, but still a valid JSON while partially following X.697. I am unsure if the function responsible for encoding a JER BIT STRING ( Let me know if there is anything I can do to improve this PR. |
Pretty sure that this provides a more precise implementation of x.697. But I am not sure if using sprintf is the |
Indeed, |
I've switched to the lookup approach instead of using Looks like the encoding of a JER OCTET STRING for large enough lengths also produces an invalid JSON due to the line breaks. For example,
with
Not sure if this PR can be used to fix this or should a new one be created. |
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.
Looks alright to me.
This line though seems a bit odd to me. What's the reason for this roundabout way of creating an array with a size of 52? And why was it reduced from 128?
char scratch[16 * 3 + 4];
A separate PR, please. One issue - one PR. ;-) Thanks! |
I've no clue. :-( |
I copied some code of the JER OCTET STRING encoder implementation: |
I don't see how it would be possible to comply with X.697 in regards to variable lengths.
Should actually encode to {
"Test":{
"number": 122,
"bsFixed": "9e44",
"bsVar": {
"length": 14,
"value": "9e44"
}
} I just don't see how that is possible under the current implementation. The constraints "belong" to the PDU itself. But the encoding has long since happened. There is just no way to check beforehand if the BIT STRING that is being encoded has any size constraints. I think it is best to just deviate from the specification in this case. At least until this has been properly discussed on how this should be solved. |
JER BIT STRING currently encodes to:
This PR fixes both of these issues.
Current limitation: this contribution assumes a BIT STRING of fixed size. X.697 provides a variant encoding for BIT STRING of variable size, however, from my understanding, the function in question (
BIT_STRING_encode_jer()
) may not have enough context to know if the BIT STRING element is constrained in size or not.