Giter Site home page Giter Site logo

Hexa Value Constraint about asn1ate HOT 8 OPEN

kimgr avatar kimgr commented on July 18, 2024
Hexa Value Constraint

from asn1ate.

Comments (8)

kimgr avatar kimgr commented on July 18, 2024

Hello Mourad,

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

Thanks!

from asn1ate.

Mourhamo avatar Mourhamo commented on July 18, 2024

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

from asn1ate.

kimgr avatar kimgr commented on July 18, 2024

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?

from asn1ate.

Mourhamo avatar Mourhamo commented on July 18, 2024

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

from asn1ate.

Mourhamo avatar Mourhamo commented on July 18, 2024

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

from asn1ate.

kimgr avatar kimgr commented on July 18, 2024

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

from asn1ate.

Mourhamo avatar Mourhamo commented on July 18, 2024

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

from asn1ate.

kimgr avatar kimgr commented on July 18, 2024

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

from asn1ate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.