Skip to main content

asn1vnparser

https://img.shields.io/pypi/v/asn1vnparser.svg https://img.shields.io/travis/mtannaan/asn1vnparser.svg Documentation Status

Parses ASN.1 value notation into a Python object or JSON without requiring its ASN.1 schema.

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 Type Translations section.

  • Some ASN.1 types and grammars are not supported; see grammar.py.

Type 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.2.1 (2021-11-14)

  • Disable pyparsing v3, which breaks tests

  • Update license to ISC

0.2.0 (2019-10-02)

New Features

  • Partial parsing of a value or a value assignment (parse_all option)

>>> parse_asn1_value(
...     "alt1: enum1\n---this is remaining string---",
...     as_json=True,
...     parse_all=False)  # as_json
('{"alt1": "enum1"}', '\n---this is remaining string---')
  • Parsing multiple value assignments

>>> parse_asn1_value_assignments(
...     'value1 INTEGER ::= 1\nvalue2 Type2 ::= the-value')
[
    {'value_name': 'value1', 'type_name': 'INTEGER', 'value': 1},
    {'value_name': 'value2', 'type_name': 'Type2', 'value': 'the-value'}
]

Bug Fixes

  • CLI no longer crashes when given --json option.

0.1.0 (2019-09-29)

  • First release on PyPI.

Metadata

Release files for asn1vnparser 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asn1vnparser 0.2.3
File Size Uploaded Provenance Actions
asn1vnparser-0.2.3.tar.gz 19.1 kB Without provenance Details for asn1vnparser-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for asn1vnparser 0.2.3
File Interpreter ABI Platform Actions
asn1vnparser-0.2.3-py2.py3-none-any.whl Python 3, Python 2 none any Details for asn1vnparser-0.2.3-py2.py3-none-any.whl

Total release size: 29.9 kB

Release files / asn1vnparser-0.2.3.tar.gz

Download URL asn1vnparser-0.2.3.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c81847ef0bf570807672516aeb6d7b18e62db3058d845097ae3b33b9e52d557d
BLAKE2b-256 checksum
How to use checksums
bbde3e935aa40172f631794d451082caa2145ee413e68be5a6b0f9fc0defd74a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

Release files / asn1vnparser-0.2.3-py2.py3-none-any.whl

Download URL asn1vnparser-0.2.3-py2.py3-none-any.whl
Size 10.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f0dfb60d0605c3649c9200f055a45ae47c590b06fbdfc4d4071e0a4560313379
BLAKE2b-256 checksum
How to use checksums
2493230009086aa75ad8e57c26d4f2a034ad744def362492468801466e207d16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.1

Security for asn1vnparser 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page