-
Notifications
You must be signed in to change notification settings - Fork 557
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
Incorrest OER encoding of default BIT STRING value #293
Comments
You might have an trial with https://github.com/brchiu/asn1c/tree/fix_issue_293_incorrest_OER_encoding_of_default_BIT_STRING_value , if you can do more tests with different length conditions are welcomed. |
@DanyaFilatov any feedback? @velichkov what is your opinion - is the proposed fix safe to integrate into the master branch? If so, should @brchiu create a similar patch for |
For my purposes it works but I didn't have enough time to fully test other lengths, etc.. Anyway it would be great to merge it because potentially partial solution is better than no solution. |
similar fix for OCTET STRING)
With da56723, the following example asn.1 module
The generated S1 member info is :
You'd better check whether the default values are correctly set or not. |
What is your opinion? |
@brchiu , I did check - and found a problem with APER. In particular - if Here are the files, and the screen log:
OER and UPER appear fine:
When both are omitted - all the codecs seem to do the right thing:
Same thing happens with
Update
|
The proposed PR seems to work fine with OER and UPER, but screws up with APER - sticking default values regardless of whether the field value is or isn't present. Help debugging this would be appreciated. @brchiu please feel free to check my fork, as that's what I have applied your PR to. |
@brchiu, thank you!! I've tested your commit, and it worked fine with APER, as well with UPER and OER. Please feel free to check against my fork, where both of your commits are merged. Question: does DER respect DEFAULT? If so, we need another commit to fix that too... Update
|
Asn1c produces incorrect OER encoding when the value of the bit string field is equal to it default value.
According to the specification, when value of the field is equal to it default value, this field shall be treated as omitted.
For this type:
the S1 { 5, '00'H } is encoded as 80 01 05 00, but shall be 80 00 05
The issue is very urgent and important because out of this the COER encoding of IEEE 1609.2 certificate is invalid, and asn1c cannot be used to generate these certificates.
The actual reason is because the asn1c doesn't generate code for default values for BIT STRING sequence members:
generated code S1.c:
The 'fb' member definition doesn't have functions to compare and set default values. Providing these function manually, I was managed to solve the issue.
The same behavior was found for OCTET STRING.
The text was updated successfully, but these errors were encountered: