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

Hexa Value Constraint #35

Open
Mourhamo opened this issue May 31, 2016 · 8 comments
Open

Hexa Value Constraint #35

Mourhamo opened this issue May 31, 2016 · 8 comments

Comments

@Mourhamo
Copy link

Hi guys,

found a new issue, regarding to the size constraint:
In case of a HexaString, the length have to be div by 2
file : constraint.py
function : ValueSizeConstraint
line 106 : l = len(value)/2 to count the number of OCTET

bye

Mourad

@kimgr
Copy link
Owner

kimgr commented May 31, 2016

Hello Mourad,

I'm having trouble seeing the bigger picture. What do you suggest asn1ate is doing wrong?

Thanks!

@Mourhamo
Copy link
Author

Mourhamo commented Jun 1, 2016

Sorry I did the issue too quickly.

If ASN1 file define a variable with the terms : "fileID OCTET STRING (SIZE(2))"
That means,it has to be an octet string of length 2 Octets

eg: fileID = '0102'

or in the function ValueSizeConstraint (in constraint.py)
in line 106 we count the number of string characters and not octets

to day : line 106 : l = len(value)
I corrected by : line 106 : l = len(value)/2
to count the number of OCTETs and not the string characters

in my case it correct the problem

@kimgr
Copy link
Owner

kimgr commented Jun 1, 2016

constraint.py is part of pyasn1, not asn1ate.

But it could very well be that asn1ate is producing the wrong data for pyasn1, so I don't think you should modify pyasn1.

Can you create a reproducible example and run it by the pyasn1 mailing list (cc me), and maybe we can work out together where the problem is, and how it should be solved?

@Mourhamo
Copy link
Author

Mourhamo commented Jun 1, 2016

oh yes I'm quite lost in files :D
Yes for sure i will

@Mourhamo
Copy link
Author

Mourhamo commented Jun 2, 2016

Hi Kim,

In fact the probleme is not in pyasn1,

i was thinking that pyasn1 was expecting an hexa like 'FF0D'

but it wait for a b'\xFF\x0D', so the length in string is the double.

in asn1ate, a default Value 'FF0D'H is converted to 'FF0D'H (not a pretty python syntax) when it have to be converted by b'\xFF\x0D' to be pretty regarding to pyasn1

Sorry for the confusing issue :)

Mourad

@kimgr
Copy link
Owner

kimgr commented Jun 5, 2016

I think I understand what the problem is now, but a small, contained example ASN.1 fragment would definitely help.

@Mourhamo
Copy link
Author

Mourhamo commented Jun 6, 2016

Here it is:

exctracted from the SimAlliance ASN1

ApplicationInstance ::= SEQUENCE {
applicationLoadPackageAID [APPLICATION 15] ApplicationIdentifier,
classAID [APPLICATION 15] ApplicationIdentifier,
instanceAID [APPLICATION 15] ApplicationIdentifier,
extraditeSecurityDomainAID [APPLICATION 15] ApplicationIdentifier OPTIONAL,
applicationPrivileges [2] OCTET STRING,
lifeCycleState [3] OCTET STRING (SIZE(1)) DEFAULT '07'H,
/* Coding according to GP Life Cycle State. */

applicationSpecificParametersC9 [PRIVATE 9] OCTET STRING,
systemSpecificParameters [PRIVATE 15] ApplicationSystemParameters OPTIONAL,
applicationParameters [PRIVATE 10] UICCApplicationParameters OPTIONAL,
processData SEQUENCE OF OCTET STRING OPTIONAL
}

The line lifeCycleState [3] OCTET STRING (SIZE(1)) DEFAULT '07'H, define a Default value to '07'H
or asn1ate will convert in python as '07'H (not python friendly)
it has to be b'\x07' or binascii.unhexlify('07')
but definitively not '07'H :)

Regards

@kimgr
Copy link
Owner

kimgr commented Jun 6, 2016

Thanks, just what I needed. I'll try and look into this.

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