Skip to content
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

ALL EXCEPT constraint not working as intended #25

Open
TheActualOtterOne opened this issue Dec 11, 2024 · 2 comments
Open

ALL EXCEPT constraint not working as intended #25

TheActualOtterOne opened this issue Dec 11, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@TheActualOtterOne
Copy link

Hello,
I found a bug, where using the ALL EXCEPT constraint, is being handled, but inreverse as it should be.
This ASN.1 schema schould work:

Prototype DEFINITIONS AUTOMATIC TAGS ::= BEGIN
    Name ::= VisibleString (ALL EXCEPT ("Cat"))
    firstName Name ::= "Notcat"
END

When I try to comile this, it raises "pycrate_asn1c.err.ASN1ObjErr: Prototype.firstName: internal object 0, value outside of the constraint" this errormessage.
When I change the schema to:

Prototype DEFINITIONS AUTOMATIC TAGS ::= BEGIN
    Name ::= VisibleString (ALL EXCEPT ("Cat"))
    firstName Name ::= "Cat"
END

It compiles and even serilizes the data. Should't the ALL EXCEPT allow everything else but "Cat" in this case?
If you need more information on this, I'll gladly try to help.

@mitshell mitshell self-assigned this Dec 17, 2024
@mitshell mitshell added the bug Something isn't working label Dec 17, 2024
@mitshell
Copy link
Member

Thanks for reporting. This looks like a bug in the compiler. Such an exclusive constraint is not transposed to the compiled Python module, as this is not a visible constraint (it has no impact on the encoding). I will check where exactly things should be fixed in the compiler, starting here:

def _parse_const_val(self, const):
, to have at least proper support there.

Having such a constraint available in the compiled Python code and supported in the runtime may need some more work.

@mitshell
Copy link
Member

mitshell commented Jan 6, 2025

A fix has been introduced in the ASN.1 compiler, to verify values provided in ASN.1 schema: see b71bfee
But the support in the ASN.1 runtime for exclusive values is still missing. A corresponding issue has been opened here: #28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants