Question

I have two modules of a software, one running on a PowerPC and another on x86 machine. The two modules communicate using ASN.1 generated functions. The PowerPC is big endian and x86 is little endian. I am not getting the expected data from the x86 to the PowerPC. Could endianess be a problem while using asn.1 ?

Was it helpful?

Solution 2

The bits on the wire produced by the encoding rules of ASN.1 (BER, PER, etc.) do not depend on the endianness of the computer on which the data is encoded.

OTHER TIPS

The bytes sent across the wire should be encoded big-endian. See: http://lists.asn1.org/pipermail/asn1/2004-August/000017.html

The two modules communicate using ASN.1 generated functions. [...] Could endianess be a problem while using ASN.1?

Lets break this down. There are 3 levels to this problem.

  1. ASN.1 notation and the associated specification is for an "abstract" syntax notation. It does not concern itself with how the values are encoded.

  2. The encoding of values (described by an ASN.1 schema) is handled by the ASN.1 "encoding" schemes; e.g. BER, CER, DER, PER and so on. (Wikipedia lists 11 distinct schemes.) To find out if a specific scheme is sensitive to "endian-ness" you would need to look at the corresponding specification1.

  3. If you are using generated functions to encode and decode ASN.1, then this is where issues of endianness-sensitivity would be dealt with. This will actually depend on how the vendor has implemented the generators, and what the generated code does.

So, to get a definitive answer for your specific case, you would need to find out which encoding you are using (BER, PER, etc), and then read the vendor documentation. However, I would expect that a good quality ASN.1 generator would generate functions that hid any endianness issues in an ASN.1 encoding from the application program.

The other way to find out if this is the source of your problem is to write a simple test. Design a simple ASN.1 schema, generate the functions, deploy to your two (or more) platforms, and see if you can pass simple integers.


1 - By my reading of the BER specification, BER uses an encoding for integers that is independent of the endianness of the sender or receiver. You can find the specs by following the "external references" links in the Wikipedia page.

Why didn't you debug the received data and compare it with the original? Wouldn't it much easier and faster than asking a question here? Just a breakpoint is enough

In general any multibyte data that is stored into memory or transfered between computers must follow a specific endian, or you must include the endian information in the stream and reverse the the data if necessary in the receiver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top