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

UTF8String with uper #48

Closed
xusunny opened this issue Dec 20, 2018 · 11 comments
Closed

UTF8String with uper #48

xusunny opened this issue Dec 20, 2018 · 11 comments

Comments

@xusunny
Copy link

xusunny commented Dec 20, 2018

hello Eric,I encounter an issue when encoding UTF8String with uper and checkConstaints=True, it throws error
"Encode Error installationorder:uuid:Expected a Character in ' ',but got 'v'(0x76)."
I debugged and find "permitted_alphabet" in constaints_checker.py is ' ', can you help me with the issue? lots of thanks.

@eerimoq
Copy link
Owner

eerimoq commented Dec 20, 2018

This might be fixed on the master branch. Give it a try and I can create a new release if it works.

@xusunny
Copy link
Author

xusunny commented Dec 20, 2018

hello Eric, I just tested on master branch,and no error when check_constraints=True,but asn1tools seem like using per style to encode length.e.g.
uuid::=UTF8String(Size(1..36)), asn1tools don't minus 1 when encoding length, and the encoded result can't be decoded by marben.
Do I think right?

@eerimoq
Copy link
Owner

eerimoq commented Dec 20, 2018

Please supply data I can use to reproduce the issue

@eerimoq
Copy link
Owner

eerimoq commented Dec 20, 2018

I think Marben is wrong. Size constraints are ignored by PER and UPER for UTF8String as its not a known-multiplier character string type.

See 27.6 in https://www.itu.int/ITU-T/studygroups/com17/languages/X.691-0207.pdf.

@eerimoq
Copy link
Owner

eerimoq commented Dec 20, 2018

The new release is called 0.138.0, available on PyPI.

@xusunny
Copy link
Author

xusunny commented Dec 21, 2018

ok, thank you for new release, about UTF8String,I should check again.

@eerimoq
Copy link
Owner

eerimoq commented Dec 24, 2018

Any news?

@xusunny
Copy link
Author

xusunny commented Dec 25, 2018

I think you are right about length encoding with uper, but there's exactly difference when encoding UTF8String compared to marben, I paste here wish you can help me find out why, the bold is difference.

from marben:

d6 93 39 8b 26 6d 1a b6 6e e1 
cb 0a d2 67 31 64 cd a3 56 cd 
dc 39 60 c5 93 36 8d 5b 37 70 
e5 81 93 06 2e 16 b1 64 b5 8b 
04 0c 5a ba 62 cd d3 06 08 22 
d3 a8 38 62 64 66 68 6a 6c 6e 
70 72 60 62 64 66 68 6a 6c 6e 
70 72 60 62 64 66 68 6a 6c 6e 
71 4c bd b2 f2 f3 d3 46 9d d9 
d0 69 e6 83 76 fe 88 37 eb 

from asn1tools:

d6 93 39 8b 26 6d 1a b6 6e e1
cb 0a d2 67 31 64 cd a3 56 cd
dc 39 60 c5 93 36 8d 5b 37 70 
e5 **85d**93 06 2e 16 b1 64 b5 8b 
04 0c 5a ba 62 cd d3 06 08 22 
d3 a8 38 62 64 66 68 6a 6c 6e 
70 72 60 62 64 66 68 6a 6c 6e
70 72 60 62 64 66 68 6a 6c 6e 
71 4c bd b2 f2 f3 d3 46 9d d9 
d0 69 e6 83 76 fe 88 37 eb **0**

and .asn specification is

UUID ::= SEQUENCE {
   uuid   PrintableString(SIZE(36)) -- Constrained to an UUID
}
OpOTAAssignmentNotification-Notification ::= SEQUENCE {
	installationorder UUID,
	timestamp ISOTimeStamp,
	newstatus UTF8String(SIZE(2..28)),
	reason PrintableString(SIZE(0..22)) OPTIONAL
}
ISOTimeStamp ::= SEQUENCE {
	timestamp PrintableString(SIZE(0..24))
}

input data is

UUID = {'uuid': 'VIN1234567890VIN12345678901234567890'}
ISOTimeStamp = {'timestamp': '2018-12-10 15:13:00 EST'}
OpOTAAssignmentNotification_Notification = {'installationorder': UUID,
                                                'timestamp': ISOTimeStamp,
                                                'newstatus': u'1234567890123456789012345678',
                                                'reason': 'everything is not ok'}

Finally, happy Christmas Day!

@eerimoq
Copy link
Owner

eerimoq commented Dec 25, 2018

I don't have time to troubleshoot this in detail, but I think asn1tools is correct, and Marben wrong.

@xusunny
Copy link
Author

xusunny commented Dec 27, 2018

sorry for interrupting you,but it's because asn specification inconsistent which leads to different encode result.

@eerimoq
Copy link
Owner

eerimoq commented Dec 27, 2018

You can give http://asn1-playground.oss.com/ a try. It's pretty helpful troubleshooting bad encodings.

@eerimoq eerimoq closed this as completed Dec 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants