Name | asn1tool JSON |
Version |
0.167.1
JSON |
| download |
home_page | None |
Summary | ASN.1 parsing, encoding and decoding. |
upload_time | 2024-11-10 21:37:33 |
maintainer | None |
docs_url | None |
author | Erik Moqvist |
requires_python | None |
license | MIT |
keywords |
asn.1
asn1
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
|coverage|_
|codecov|_
|nala|_
About
=====
A Python package for `ASN.1`_ parsing, encoding and decoding.
This project is *under development* and does only support a subset
of the ASN.1 specification syntax.
Supported codecs:
- Basic Encoding Rules (BER)
- Distinguished Encoding Rules (DER)
- Generic String Encoding Rules (GSER)
- JSON Encoding Rules (JER)
- Basic Octet Encoding Rules (OER)
- Aligned Packed Encoding Rules (PER)
- Unaligned Packed Encoding Rules (UPER)
- XML Encoding Rules (XER)
Miscellaneous features:
- `C` source code generator for OER and UPER (with some limitations).
Project homepage: https://github.com/eerimoq/asn1tools
Documentation: http://asn1tools.readthedocs.org/en/latest
Known limitations
=================
- The ``CLASS`` keyword (X.681) and its friends are not yet supported.
- Parametrization (X.683) is not yet supported.
- The ``EMBEDDED PDV`` type is not yet supported.
- The ``ANY`` and ``ANY DEFINED BY`` types are not supported. They
were removed from the ASN.1 standard 1994.
- ``WITH COMPONENT`` and ``WITH COMPONENTS`` constraints are ignored,
except for OER ``REAL``.
- The ``DURATION`` type is not yet supported.
Installation
============
.. code-block:: python
pip install asn1tools
Example Usage
=============
This is an example ASN.1 specification defining the messages of a
fictitious Foo protocol (based on the FooProtocol on Wikipedia).
.. code-block:: text
Foo DEFINITIONS ::= BEGIN
Question ::= SEQUENCE {
id INTEGER,
question IA5String
}
Answer ::= SEQUENCE {
id INTEGER,
answer BOOLEAN
}
END
Scripting
---------
`Compile`_ the ASN.1 specification, and `encode`_ and `decode`_ a
question using the default codec (BER).
.. code-block:: python
>>> import asn1tools
>>> foo = asn1tools.compile_files('tests/files/foo.asn')
>>> encoded = foo.encode('Question', {'id': 1, 'question': 'Is 1+1=3?'})
>>> encoded
bytearray(b'0\x0e\x02\x01\x01\x16\x09Is 1+1=3?')
>>> foo.decode('Question', encoded)
{'id': 1, 'question': 'Is 1+1=3?'}
The same ASN.1 specification, but using the PER codec.
.. code-block:: python
>>> import asn1tools
>>> foo = asn1tools.compile_files('tests/files/foo.asn', 'per')
>>> encoded = foo.encode('Question', {'id': 1, 'question': 'Is 1+1=3?'})
>>> encoded
bytearray(b'\x01\x01\tIs 1+1=3?')
>>> foo.decode('Question', encoded)
{'id': 1, 'question': 'Is 1+1=3?'}
See the `examples`_ folder for additional examples.
Command line tool
-----------------
The shell subcommand
^^^^^^^^^^^^^^^^^^^^
Use the command line shell to convert data between given formats. The
default input codec is BER and output codec is GSER (produces human
readable text).
.. code-block:: text
> asn1tools shell
Welcome to the asn1tools shell!
$ help
Commands:
compile
convert
exit
help
$ compile tests/files/foo.asn
$ convert Question 300e0201011609497320312b313d333f
question Question ::= {
id 1,
question "Is 1+1=3?"
}
$ compile --output-codec xer tests/files/foo.asn
$ convert Question 300e0201011609497320312b313d333f
<Question>
<id>1</id>
<question>Is 1+1=3?</question>
</Question>
$ compile -o uper tests/files/foo.asn
$ convert Question 300e0201011609497320312b313d333f
01010993cd03156c5eb37e
$ exit
>
The convert subcommand
^^^^^^^^^^^^^^^^^^^^^^
Convert given encoded Question from BER to GSER (produces human
readable text).
.. code-block:: text
> asn1tools convert tests/files/foo.asn Question 300e0201011609497320312b313d333f
question Question ::= {
id 1,
question "Is 1+1=3?"
}
>
Convert given encoded Question from UPER to XER (xml).
.. code-block:: text
> asn1tools convert -i uper -o xer tests/files/foo.asn Question 01010993cd03156c5eb37e
<Question>
<id>1</id>
<question>Is 1+1=3?</question>
</Question>
>
Convert given encoded Question from UPER to JER (json).
.. code-block:: text
> asn1tools convert -i uper -o jer tests/files/foo.asn Question 01010993cd03156c5eb37e
{
"id": 1,
"question": "Is 1+1=3?"
}
>
Continuously convert encoded Questions read from standard input. Any
line that cannot be converted is printed as is, in this example the
dates.
.. code-block:: text
> cat encoded.txt
2018-02-24 11:22:09
300e0201011609497320312b313d333f
2018-02-24 11:24:15
300e0201021609497320322b323d353f
> cat encoded.txt | asn1tools convert tests/files/foo.asn Question -
2018-02-24 11:22:09
question Question ::= {
id 1,
question "Is 1+1=3?"
}
2018-02-24 11:24:15
question Question ::= {
id 2,
question "Is 2+2=5?"
}
>
The convert subcommand with a cache
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Convert given encoded PCCH-Message from UPER to GSER with the
``--cache-dir`` option set to ``my_cache``. Using a cache
significantly reduces the command execution time after the first call.
.. code-block:: text
> time asn1tools convert --cache-dir my_cache -i uper tests/files/3gpp/rrc_8_6_0.asn PCCH-Message 28
pcch-message PCCH-Message ::= {
message c1 : paging : {
systemInfoModification true,
nonCriticalExtension {
}
}
}
real 0m2.090s
user 0m1.977s
sys 0m0.032s
> time asn1tools convert --cache-dir my_cache -i uper tests/files/3gpp/rrc_8_6_0.asn PCCH-Message 28
pcch-message PCCH-Message ::= {
message c1 : paging : {
systemInfoModification true,
nonCriticalExtension {
}
}
}
real 0m0.276s
user 0m0.197s
sys 0m0.026s
>
The parse subcommand
^^^^^^^^^^^^^^^^^^^^
Parse given ASN.1 specification and write it as a Python dictionary to
given file. Use the created file to convert given encoded Question
from BER to GSER (produces human readable text). The conversion is
significantly faster than passing .asn-file(s) to the convert
subcommand, especially for larger ASN.1 specifications.
.. code-block:: text
> asn1tools parse tests/files/foo.asn foo.py
> asn1tools convert foo.py Question 300e0201011609497320312b313d333f
question Question ::= {
id 1,
question "Is 1+1=3?"
}
>
The generate C source subcommand
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Generate OER or UPER C source code from an ASN.1 specification.
No dynamic memory is used in the generated code. To achieve this all
types in the ASN.1 specification must have a known maximum size,
i.e. ``INTEGER (0..7)``, ``OCTET STRING (SIZE(12))``, etc.
Below is an example generating OER C source code from
`tests/files/c_source/c_source.asn`_.
.. code-block:: text
> asn1tools generate_c_source --namespace oer tests/files/c_source/c_source.asn
Successfully generated oer.h and oer.c.
The same as above, but generate UPER C source code instead of OER.
.. code-block:: text
> asn1tools generate_c_source --codec uper --namespace uper tests/files/c_source/c_source.asn
Successfully generated uper.h and uper.c.
The same as the first example, but also generate fuzz testing C source
code for `libFuzzer`_.
.. code-block:: text
> asn1tools generate_c_source --namespace oer --generate-fuzzer tests/files/c_source/c_source.asn
Successfully generated oer.h and oer.c.
Successfully generated oer_fuzzer.c and oer_fuzzer.mk.
Run "make -f oer_fuzzer.mk" to build and run the fuzzer. Requires a
recent version of clang.
See `oer.h`_, `oer.c`_, `uper.h`_, `uper.c`_, `oer_fuzzer.c`_ and
`oer_fuzzer.mk`_ for the contents of the generated files.
Limitations by design:
- Only the types ``BOOLEAN``, ``INTEGER``, ``NULL``, ``OCTET STRING``,
``BIT STRING``, ``ENUMERATED``, ``SEQUENCE``, ``SEQUENCE OF``, and ``CHOICE``
are supported. The OER generator also supports ``REAL``.
- All types must have a known maximum size, i.e. ``INTEGER (0..7)``,
``OCTET STRING (SIZE(12))``.
- ``INTEGER`` must be 64 bits or less.
- ``REAL`` must be IEEE 754 binary32 or binary64. binary32 is
generated as ``float`` and binary64 as ``double``.
- Recursive types are not supported.
Known limitations:
- Extension additions (``...``) are only supported in the OER generator.
See `compact_extensions_uper`_ for how to make UPER ``CHOICE`` and
``SEQUENCE`` extendable without using ``...``.
- Named numbers in ``ENUMERATED`` are not yet supported.
Other OER and/or UPER C code generators:
- https://github.com/vlm/asn1c
- https://github.com/ttsiodras/asn1scc
See the `benchmark example`_ for a comparison of `asn1c`, `asn1scc`
and `asn1tools`.
Contributing
============
#. Fork the repository.
#. Install prerequisites.
.. code-block:: text
pip install -r requirements.txt
#. Implement the new feature or bug fix.
#. Implement test case(s) to ensure that future changes do not break
legacy.
#. Run the tests.
.. code-block:: text
make test
#. Create a pull request.
Specifications
==============
ASN.1 specifications released by ITU and IETF.
General
-------
- `X.680: Specification of basic notation
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf>`_
- `X.681: Information object specification
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.681-0207.pdf>`_
- `X.682: Constraint specification
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.682-0207.pdf>`_
- `X.683: Parameterization of ASN.1 specifications
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.683-0207.pdf>`_
Encodings
---------
- `X.690: Specification of Basic Encoding Rules (BER), Canonical
Encoding Rules (CER) and Distinguished Encoding Rules (DER)
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf>`_
- `X.691: Specification of Packed Encoding Rules (PER)
<https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.691-201508-I!!PDF-E&type=items>`_
- `X.693: XML Encoding Rules (XER)
<https://www.itu.int/ITU-T/studygroups/com17/languages/X.693-0112.pdf>`_
- `X.696: Specification of Octet Encoding Rules (OER)
<https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.696-201508-I!!PDF-E&type=items>`_
- `RFC 3641: Generic String Encoding Rules (GSER) for ASN.1
<https://tools.ietf.org/html/rfc3641>`_
- `Overview of the JSON Encoding Rules (JER)
<http://www.oss.com/asn1/resources/asn1-papers/Overview_of_JER.pdf>`_
.. |coverage| image:: https://coveralls.io/repos/github/eerimoq/asn1tools/badge.svg?branch=master
.. _coverage: https://coveralls.io/github/eerimoq/asn1tools
.. |codecov| image:: https://codecov.io/gh/eerimoq/asn1tools/branch/master/graph/badge.svg
.. _codecov: https://codecov.io/gh/eerimoq/asn1tools
.. |nala| image:: https://img.shields.io/badge/nala-test-blue.svg
.. _nala: https://github.com/eerimoq/nala
.. _ASN.1: https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One
.. _Compile: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compile_files
.. _encode: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compiler.Specification.encode
.. _decode: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compiler.Specification.decode
.. _examples: https://github.com/eerimoq/asn1tools/tree/master/examples
.. _tests/files/c_source/c_source.asn: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/c_source.asn
.. _oer.h: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer.h
.. _oer.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer.c
.. _uper.h: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/uper.h
.. _uper.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/uper.c
.. _oer_fuzzer.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer_fuzzer.c
.. _oer_fuzzer.mk: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer_fuzzer.mk
.. _libFuzzer: https://llvm.org/docs/LibFuzzer.html
.. _benchmark example: https://github.com/eerimoq/asn1tools/blob/master/examples/benchmarks/c_source
.. _compact_extensions_uper: https://github.com/eerimoq/asn1tools/blob/master/examples/compact_extensions_uper
Raw data
{
"_id": null,
"home_page": null,
"name": "asn1tool",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "ASN.1, asn1",
"author": "Erik Moqvist",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/6f/3e/abac9702a2119e11a76de92a3f75467b490348fd317ae1ec61abf37a1dfb/asn1tool-0.167.1.tar.gz",
"platform": null,
"description": "|coverage|_\r\n|codecov|_\r\n|nala|_\r\n\r\nAbout\r\n=====\r\n\r\nA Python package for `ASN.1`_ parsing, encoding and decoding.\r\n\r\nThis project is *under development* and does only support a subset\r\nof the ASN.1 specification syntax.\r\n\r\nSupported codecs:\r\n\r\n- Basic Encoding Rules (BER)\r\n- Distinguished Encoding Rules (DER)\r\n- Generic String Encoding Rules (GSER)\r\n- JSON Encoding Rules (JER)\r\n- Basic Octet Encoding Rules (OER)\r\n- Aligned Packed Encoding Rules (PER)\r\n- Unaligned Packed Encoding Rules (UPER)\r\n- XML Encoding Rules (XER)\r\n\r\nMiscellaneous features:\r\n\r\n- `C` source code generator for OER and UPER (with some limitations).\r\n\r\nProject homepage: https://github.com/eerimoq/asn1tools\r\n\r\nDocumentation: http://asn1tools.readthedocs.org/en/latest\r\n\r\nKnown limitations\r\n=================\r\n\r\n- The ``CLASS`` keyword (X.681) and its friends are not yet supported.\r\n\r\n- Parametrization (X.683) is not yet supported.\r\n\r\n- The ``EMBEDDED PDV`` type is not yet supported.\r\n\r\n- The ``ANY`` and ``ANY DEFINED BY`` types are not supported. They\r\n were removed from the ASN.1 standard 1994.\r\n\r\n- ``WITH COMPONENT`` and ``WITH COMPONENTS`` constraints are ignored,\r\n except for OER ``REAL``.\r\n\r\n- The ``DURATION`` type is not yet supported.\r\n\r\nInstallation\r\n============\r\n\r\n.. code-block:: python\r\n\r\n pip install asn1tools\r\n\r\nExample Usage\r\n=============\r\n\r\nThis is an example ASN.1 specification defining the messages of a\r\nfictitious Foo protocol (based on the FooProtocol on Wikipedia).\r\n\r\n.. code-block:: text\r\n\r\n Foo DEFINITIONS ::= BEGIN\r\n\r\n Question ::= SEQUENCE {\r\n id INTEGER,\r\n question IA5String\r\n }\r\n\r\n Answer ::= SEQUENCE {\r\n id INTEGER,\r\n answer BOOLEAN\r\n }\r\n\r\n END\r\n\r\nScripting\r\n---------\r\n\r\n`Compile`_ the ASN.1 specification, and `encode`_ and `decode`_ a\r\nquestion using the default codec (BER).\r\n\r\n.. code-block:: python\r\n\r\n >>> import asn1tools\r\n >>> foo = asn1tools.compile_files('tests/files/foo.asn')\r\n >>> encoded = foo.encode('Question', {'id': 1, 'question': 'Is 1+1=3?'})\r\n >>> encoded\r\n bytearray(b'0\\x0e\\x02\\x01\\x01\\x16\\x09Is 1+1=3?')\r\n >>> foo.decode('Question', encoded)\r\n {'id': 1, 'question': 'Is 1+1=3?'}\r\n\r\nThe same ASN.1 specification, but using the PER codec.\r\n\r\n.. code-block:: python\r\n\r\n >>> import asn1tools\r\n >>> foo = asn1tools.compile_files('tests/files/foo.asn', 'per')\r\n >>> encoded = foo.encode('Question', {'id': 1, 'question': 'Is 1+1=3?'})\r\n >>> encoded\r\n bytearray(b'\\x01\\x01\\tIs 1+1=3?')\r\n >>> foo.decode('Question', encoded)\r\n {'id': 1, 'question': 'Is 1+1=3?'}\r\n\r\nSee the `examples`_ folder for additional examples.\r\n\r\nCommand line tool\r\n-----------------\r\n\r\nThe shell subcommand\r\n^^^^^^^^^^^^^^^^^^^^\r\n\r\nUse the command line shell to convert data between given formats. The\r\ndefault input codec is BER and output codec is GSER (produces human\r\nreadable text).\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools shell\r\n\r\n Welcome to the asn1tools shell!\r\n\r\n $ help\r\n Commands:\r\n compile\r\n convert\r\n exit\r\n help\r\n $ compile tests/files/foo.asn\r\n $ convert Question 300e0201011609497320312b313d333f\r\n question Question ::= {\r\n id 1,\r\n question \"Is 1+1=3?\"\r\n }\r\n $ compile --output-codec xer tests/files/foo.asn\r\n $ convert Question 300e0201011609497320312b313d333f\r\n <Question>\r\n <id>1</id>\r\n <question>Is 1+1=3?</question>\r\n </Question>\r\n $ compile -o uper tests/files/foo.asn\r\n $ convert Question 300e0201011609497320312b313d333f\r\n 01010993cd03156c5eb37e\r\n $ exit\r\n >\r\n\r\nThe convert subcommand\r\n^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nConvert given encoded Question from BER to GSER (produces human\r\nreadable text).\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools convert tests/files/foo.asn Question 300e0201011609497320312b313d333f\r\n question Question ::= {\r\n id 1,\r\n question \"Is 1+1=3?\"\r\n }\r\n >\r\n\r\nConvert given encoded Question from UPER to XER (xml).\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools convert -i uper -o xer tests/files/foo.asn Question 01010993cd03156c5eb37e\r\n <Question>\r\n <id>1</id>\r\n <question>Is 1+1=3?</question>\r\n </Question>\r\n >\r\n\r\nConvert given encoded Question from UPER to JER (json).\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools convert -i uper -o jer tests/files/foo.asn Question 01010993cd03156c5eb37e\r\n {\r\n \"id\": 1,\r\n \"question\": \"Is 1+1=3?\"\r\n }\r\n >\r\n\r\nContinuously convert encoded Questions read from standard input. Any\r\nline that cannot be converted is printed as is, in this example the\r\ndates.\r\n\r\n.. code-block:: text\r\n\r\n > cat encoded.txt\r\n 2018-02-24 11:22:09\r\n 300e0201011609497320312b313d333f\r\n 2018-02-24 11:24:15\r\n 300e0201021609497320322b323d353f\r\n > cat encoded.txt | asn1tools convert tests/files/foo.asn Question -\r\n 2018-02-24 11:22:09\r\n question Question ::= {\r\n id 1,\r\n question \"Is 1+1=3?\"\r\n }\r\n 2018-02-24 11:24:15\r\n question Question ::= {\r\n id 2,\r\n question \"Is 2+2=5?\"\r\n }\r\n >\r\n\r\nThe convert subcommand with a cache\r\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nConvert given encoded PCCH-Message from UPER to GSER with the\r\n``--cache-dir`` option set to ``my_cache``. Using a cache\r\nsignificantly reduces the command execution time after the first call.\r\n\r\n.. code-block:: text\r\n\r\n > time asn1tools convert --cache-dir my_cache -i uper tests/files/3gpp/rrc_8_6_0.asn PCCH-Message 28\r\n pcch-message PCCH-Message ::= {\r\n message c1 : paging : {\r\n systemInfoModification true,\r\n nonCriticalExtension {\r\n }\r\n }\r\n }\r\n\r\n real 0m2.090s\r\n user 0m1.977s\r\n sys 0m0.032s\r\n > time asn1tools convert --cache-dir my_cache -i uper tests/files/3gpp/rrc_8_6_0.asn PCCH-Message 28\r\n pcch-message PCCH-Message ::= {\r\n message c1 : paging : {\r\n systemInfoModification true,\r\n nonCriticalExtension {\r\n }\r\n }\r\n }\r\n\r\n real 0m0.276s\r\n user 0m0.197s\r\n sys 0m0.026s\r\n >\r\n\r\nThe parse subcommand\r\n^^^^^^^^^^^^^^^^^^^^\r\n\r\nParse given ASN.1 specification and write it as a Python dictionary to\r\ngiven file. Use the created file to convert given encoded Question\r\nfrom BER to GSER (produces human readable text). The conversion is\r\nsignificantly faster than passing .asn-file(s) to the convert\r\nsubcommand, especially for larger ASN.1 specifications.\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools parse tests/files/foo.asn foo.py\r\n > asn1tools convert foo.py Question 300e0201011609497320312b313d333f\r\n question Question ::= {\r\n id 1,\r\n question \"Is 1+1=3?\"\r\n }\r\n >\r\n\r\nThe generate C source subcommand\r\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n\r\nGenerate OER or UPER C source code from an ASN.1 specification.\r\n\r\nNo dynamic memory is used in the generated code. To achieve this all\r\ntypes in the ASN.1 specification must have a known maximum size,\r\ni.e. ``INTEGER (0..7)``, ``OCTET STRING (SIZE(12))``, etc.\r\n\r\nBelow is an example generating OER C source code from\r\n`tests/files/c_source/c_source.asn`_.\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools generate_c_source --namespace oer tests/files/c_source/c_source.asn\r\n Successfully generated oer.h and oer.c.\r\n\r\nThe same as above, but generate UPER C source code instead of OER.\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools generate_c_source --codec uper --namespace uper tests/files/c_source/c_source.asn\r\n Successfully generated uper.h and uper.c.\r\n\r\nThe same as the first example, but also generate fuzz testing C source\r\ncode for `libFuzzer`_.\r\n\r\n.. code-block:: text\r\n\r\n > asn1tools generate_c_source --namespace oer --generate-fuzzer tests/files/c_source/c_source.asn\r\n Successfully generated oer.h and oer.c.\r\n Successfully generated oer_fuzzer.c and oer_fuzzer.mk.\r\n\r\n Run \"make -f oer_fuzzer.mk\" to build and run the fuzzer. Requires a\r\n recent version of clang.\r\n\r\nSee `oer.h`_, `oer.c`_, `uper.h`_, `uper.c`_, `oer_fuzzer.c`_ and\r\n`oer_fuzzer.mk`_ for the contents of the generated files.\r\n\r\nLimitations by design:\r\n\r\n- Only the types ``BOOLEAN``, ``INTEGER``, ``NULL``, ``OCTET STRING``,\r\n ``BIT STRING``, ``ENUMERATED``, ``SEQUENCE``, ``SEQUENCE OF``, and ``CHOICE``\r\n are supported. The OER generator also supports ``REAL``.\r\n\r\n- All types must have a known maximum size, i.e. ``INTEGER (0..7)``,\r\n ``OCTET STRING (SIZE(12))``.\r\n\r\n- ``INTEGER`` must be 64 bits or less.\r\n\r\n- ``REAL`` must be IEEE 754 binary32 or binary64. binary32 is\r\n generated as ``float`` and binary64 as ``double``.\r\n\r\n- Recursive types are not supported.\r\n\r\nKnown limitations:\r\n\r\n- Extension additions (``...``) are only supported in the OER generator.\r\n See `compact_extensions_uper`_ for how to make UPER ``CHOICE`` and\r\n ``SEQUENCE`` extendable without using ``...``.\r\n\r\n- Named numbers in ``ENUMERATED`` are not yet supported.\r\n\r\nOther OER and/or UPER C code generators:\r\n\r\n- https://github.com/vlm/asn1c\r\n\r\n- https://github.com/ttsiodras/asn1scc\r\n\r\nSee the `benchmark example`_ for a comparison of `asn1c`, `asn1scc`\r\nand `asn1tools`.\r\n\r\nContributing\r\n============\r\n\r\n#. Fork the repository.\r\n\r\n#. Install prerequisites.\r\n\r\n .. code-block:: text\r\n\r\n pip install -r requirements.txt\r\n\r\n#. Implement the new feature or bug fix.\r\n\r\n#. Implement test case(s) to ensure that future changes do not break\r\n legacy.\r\n\r\n#. Run the tests.\r\n\r\n .. code-block:: text\r\n\r\n make test\r\n\r\n#. Create a pull request.\r\n\r\nSpecifications\r\n==============\r\n\r\nASN.1 specifications released by ITU and IETF.\r\n\r\nGeneral\r\n-------\r\n\r\n- `X.680: Specification of basic notation\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.680-0207.pdf>`_\r\n\r\n- `X.681: Information object specification\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.681-0207.pdf>`_\r\n\r\n- `X.682: Constraint specification\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.682-0207.pdf>`_\r\n\r\n- `X.683: Parameterization of ASN.1 specifications\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.683-0207.pdf>`_\r\n\r\nEncodings\r\n---------\r\n\r\n- `X.690: Specification of Basic Encoding Rules (BER), Canonical\r\n Encoding Rules (CER) and Distinguished Encoding Rules (DER)\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf>`_\r\n\r\n- `X.691: Specification of Packed Encoding Rules (PER)\r\n <https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.691-201508-I!!PDF-E&type=items>`_\r\n\r\n- `X.693: XML Encoding Rules (XER)\r\n <https://www.itu.int/ITU-T/studygroups/com17/languages/X.693-0112.pdf>`_\r\n\r\n- `X.696: Specification of Octet Encoding Rules (OER)\r\n <https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-X.696-201508-I!!PDF-E&type=items>`_\r\n\r\n- `RFC 3641: Generic String Encoding Rules (GSER) for ASN.1\r\n <https://tools.ietf.org/html/rfc3641>`_\r\n\r\n- `Overview of the JSON Encoding Rules (JER)\r\n <http://www.oss.com/asn1/resources/asn1-papers/Overview_of_JER.pdf>`_\r\n\r\n.. |coverage| image:: https://coveralls.io/repos/github/eerimoq/asn1tools/badge.svg?branch=master\r\n.. _coverage: https://coveralls.io/github/eerimoq/asn1tools\r\n\r\n.. |codecov| image:: https://codecov.io/gh/eerimoq/asn1tools/branch/master/graph/badge.svg\r\n.. _codecov: https://codecov.io/gh/eerimoq/asn1tools\r\n\r\n.. |nala| image:: https://img.shields.io/badge/nala-test-blue.svg\r\n.. _nala: https://github.com/eerimoq/nala\r\n\r\n.. _ASN.1: https://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One\r\n\r\n.. _Compile: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compile_files\r\n.. _encode: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compiler.Specification.encode\r\n.. _decode: http://asn1tools.readthedocs.io/en/latest/#asn1tools.compiler.Specification.decode\r\n.. _examples: https://github.com/eerimoq/asn1tools/tree/master/examples\r\n\r\n.. _tests/files/c_source/c_source.asn: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/c_source.asn\r\n\r\n.. _oer.h: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer.h\r\n\r\n.. _oer.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer.c\r\n\r\n.. _uper.h: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/uper.h\r\n\r\n.. _uper.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/uper.c\r\n\r\n.. _oer_fuzzer.c: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer_fuzzer.c\r\n\r\n.. _oer_fuzzer.mk: https://github.com/eerimoq/asn1tools/blob/master/tests/files/c_source/oer_fuzzer.mk\r\n\r\n.. _libFuzzer: https://llvm.org/docs/LibFuzzer.html\r\n\r\n.. _benchmark example: https://github.com/eerimoq/asn1tools/blob/master/examples/benchmarks/c_source\r\n\r\n.. _compact_extensions_uper: https://github.com/eerimoq/asn1tools/blob/master/examples/compact_extensions_uper\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "ASN.1 parsing, encoding and decoding.",
"version": "0.167.1",
"project_urls": null,
"split_keywords": [
"asn.1",
" asn1"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6f3eabac9702a2119e11a76de92a3f75467b490348fd317ae1ec61abf37a1dfb",
"md5": "721846068613cb1c5c309f118dedcf6d",
"sha256": "46da31f7e7fa0563dde71e7dcd3003b43ec821c38c9633ff5bc344f360e2758d"
},
"downloads": -1,
"filename": "asn1tool-0.167.1.tar.gz",
"has_sig": false,
"md5_digest": "721846068613cb1c5c309f118dedcf6d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 873278,
"upload_time": "2024-11-10T21:37:33",
"upload_time_iso_8601": "2024-11-10T21:37:33.649122Z",
"url": "https://files.pythonhosted.org/packages/6f/3e/abac9702a2119e11a76de92a3f75467b490348fd317ae1ec61abf37a1dfb/asn1tool-0.167.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-10 21:37:33",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "asn1tool"
}