vlm / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
1.03k stars 551 forks source link

IEEE 1609.2a D8 2016 has been published #219

Open DanyaFilatov opened 6 years ago

DanyaFilatov commented 6 years ago

Just to inform you that the consolidated version of IEEE 1609.2a-2016 D8 was finally published. See IEEE 1609.2a-2017 The most recent version of ASN.1 files of IEEE 1609.2 can be constantly accessible on the author's github: @wwhyte-si/1609dot2-asn

The ETSI TS 103 097 v2 (european security protocol, based on 1609.2) is finalized and going to be publishing soon. Please see attached file. TS_103_097_v2_0_8_Security_Headers.zip

vlm commented 6 years ago

Smoke-tested asn1c on https://github.com/wwhyte-si/1609dot2-asn:

asn1c -gen-OER -pdu=Certificate 1609*asn
make -f Makefile.am.example
./converter-example TestCertificate.coer

Worked:

<Certificate>
    <version>3</version>
    <type><implicit/></type>
    <issuer>
        <sha256AndDigest>01 01 01 01 01 01 01 01</sha256AndDigest>
    </issuer>
    <toBeSigned>
        <id>
            <linkageData>
                <iCert>2</iCert>
                <linkage-value>03 03 03 03 03 03 03 03 03</linkage-value>
            </linkageData>
        </id>
...

Supplied test dump:

value1 TestCertificate ::= {
  version 3,
  type implicit,
  issuer sha256AndDigest : '0101010101010101'H,
  toBeSigned {
    id linkageData : {
      iCert 2,
      linkage-value '030303030303030303'H
    },
...
tesslinger commented 6 years ago

@DanyaFilatov I tried to compile the ASN.1 files of ETSI TS 103 097 V1.3.1

compiled with branch master.

asn1c etsi.asn1 ieee1609_1.asn1 ieee1609_2.asn1 gcc -I. *.c -c

Then I get many of these errors: `... In file included from ./asn_application.h:167:0, from VerificationKeyIndicator.h:11, from VerificationKeyIndicator.c:7: ./constr_TYPE.h:51:60: fatal error: oer_decoder.h: No such file or directory

include / Octet Encoding Rules encoder /

                                                        ^

compilation terminated. ...`

If I add a second Include to the skeletons folder, I get only the Uint64 warnings. But I can't link the files together.

Is there missing a setup?

vlm commented 6 years ago
  1. Ensure you're using the latest compiler from the master branch.

  2. Do this instead:

asn1c -gen-OER -gen-PER -pdu=auto -pdu=FOO etsi.asn1 ieee1609_1.asn1 ieee1609_2.asn1
make -f Makefile.am.example

(where FOO is the top level type that you'd wish to debug).

Please send me these files to vlm@lionet.info so I could check out the way you're compiling them and possibly fix asn1c operation without -gen-OER

tesslinger commented 6 years ago

ok. Thank you. Code Generation und Compilation was sucessfull. With the converter-example I decoded the TestCertificate.coer and saw the XER-Encoding.

But if I try to decode it on my own it stucks. The return code from oer_decode(...) is not RC_OK. There is also a strange output. You see it below of the example. I can't figure out why. I followed the usage-manual. If I take the XER-Dump and the xer_decode(...) everything works fine.

#include <Certificate.h>
int main()
{
    Certificate_t *cert = (Certificate_t *) calloc(1, sizeof(Certificate_t));
    if (NULL == cert)
        printf("Allocation was not possible\n");

    //Hex dump from https://github.com/wwhyte-si/1609dot2-asn/blob/master/TestCertificate.coer.hex
    char buff[] = "00 03 01 80  01 01 01 01   01 01 01 01  50 80 00 00 \
                    02 03 03 03  03 03 03 03   03 03 04 04  04 00 05 06 \
                    06 06 06 84  00 A9 83 01   03 80 00 7C  80 01 E4 80 \
                    03 48 01 01  00 01 20 81   83 08 08 08  08 08 08 08 \
                    08 08 08 08  08 08 08 08   08 08 08 08  08 08 08 08 \
                    08 08 08 08  08 08 08 08   08";

    asn_dec_rval_t retValue = oer_decode(0, &asn_DEF_Certificate, (void**)&cert, (void*)buff, sizeof(buff));
    if(retValue.code != RC_OK)
    {
        printf("Decode ASN.1 was not successful\n");
    }
    xer_fprint(stdout, &asn_DEF_Certificate, cert);
    return 0;
}

/****************************************
  Output:
  Decode ASN.1 was not successful
    <Certificate>
    <version>48</version>
    <type>

 ****************************************/
tesslinger commented 6 years ago

@vlm if I run as you./converter-example TestCertificate.coer with -c to check the constraints, there is a segementation fault. Do you have a solution for this?

I look up your code in converter-example.c. I don't know if there is maybe a internal wrong pointer transfer? Can you check this out please?

brchiu commented 6 years ago

@coley7, you can add -g in makefile to build program with debug information and then use gdb to debug segmentation fault.