Parses ASN.1 value notation into a Python object or JSON without requiring its ASN.1 schema.
Project description
asn1vnparser
Parses ASN.1 value notation into a Python object or JSON without requiring its ASN.1 schema.
Free software: MIT license
Documentation: https://asn1vnparser.readthedocs.io.
Features
Parsing ASN.1 value notation into a Python object, or a JSON string
No ASN.1 Schema Required
Limitations
Since Knowledge of schema is not used, misdetection of ASN.1 types can occur; see Translations section.
Some ASN.1 types and grammars are not supported; see grammar.py.
Translations
asn1vnparser performs the following type translations:
ASN.1 Type |
Python Type |
JSON Type |
Example (ASN.1 -> Python) |
---|---|---|---|
NULL |
None |
null |
NULL -> None |
BOOLEAN |
bool |
True/False |
TRUE -> True |
INTEGER |
int |
number (int) |
3 -> 3 |
REAL |
float |
number (real) |
0.1 -> 0.1 |
BIT STRING (^1) |
bitarray.bitarray |
string (e.g. “010101”) |
‘010101’B -> bitarray.bitarray(‘010101’) |
OCTET STRING (^1) |
bytes |
string (e.g. “0123ab”) |
‘0123AB’H -> b’x01x23xab’ |
cstring (PrintableString, etc.) |
str |
string |
“foobar” -> ‘foobar’ |
ENUMERATED |
str |
string |
any-identifier -> ‘any-identifier’ |
CHOICE |
Dict[str, Any] |
{“string”: (any JSON object)} |
alt1 : 123 -> {‘alt1’: 123} |
Open Type (e.g. type field) |
Dict[str, Any] |
{“String”: (any JSON object)} |
Type1 : 123 -> {‘Type1’: 123} |
empty SEQUENCE or SEQUENCE OF |
{} (empty dict) |
{} (empty object) |
{} -> {}, [] -> {} |
SEQUENCE |
dict |
object |
{f1 val, f2 1} -> {‘f1’: ‘val’, ‘f2’: 1} |
SEQUENCE OF |
list |
array |
[1, 2, 3] -> [1, 2, 3] |
OBJECT IDENTIFIER |
List[int] |
array of number (int) |
{1 2 3} -> [1, 2, 3] |
(^1) CONTAINING (some_value) is interpreted as simply (some_value), e.g.:
{ field1 123, field2 CONTAINING { field2-1 TRUE, field2-2 FALSE } }
is parsed into following Python object:
{ "field1": 123, "field2": { "field2-1": True, "field2-2": False } }
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.1.0 (2019-09-29)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asn1vnparser-0.1.0.tar.gz
.
File metadata
- Download URL: asn1vnparser-0.1.0.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e1f2ed0e0e40f495fd67a6aa3196db23db916e9430cfccb4cb6f3d432ed6d99 |
|
MD5 | acf00925c7a223ad63270d995582f494 |
|
BLAKE2b-256 | 0568b68b71ca8295295bd90f340bab55977dd72cfbd2111b94145107088aacee |
File details
Details for the file asn1vnparser-0.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: asn1vnparser-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c618d4c8ad7dabf7d64eed51595ed6284b9be20a6096e1cce9f02fd4a3ac2e47 |
|
MD5 | 2ffebc0b199292ecef3de86aa69a11c6 |
|
BLAKE2b-256 | 50a062e9c34c4bdef4eb767591c69184f871c040f7901058243b909c87a7572a |