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. BER and PER codecs are also under development.
Project homepage: https://github.com/eerimoq/asn1tools
Documentation: http://asn1tools.readthedocs.org/en/latest
Installation
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).
Foo DEFINITIONS ::= BEGIN
Question ::= SEQUENCE {
id INTEGER,
question IA5String
}
Answer ::= SEQUENCE {
id INTEGER,
answer BOOLEAN
}
END
Compile the ASN.1 specification, and encode and decode a question using the default codec (BER).
>>> import asn1tools
>>> foo = asn1tools.compile_file('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.
>>> import asn1tools
>>> foo = asn1tools.compile_file('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
Contributing
Fork the repository.
Implement the new feature or bug fix.
Implement test case(s) to ensure that future changes do not break legacy.
Run the tests.
make testCreate a pull request.
Metadata
Release files for asn1tools 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| asn1tools-0.9.0.tar.gz | 103.6 kB | Without provenance | Details for asn1tools-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asn1tools-0.9.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for asn1tools-0.9.0-py2.py3-none-any.whl |
Total release size: 121.5 kB
Release files / asn1tools-0.9.0.tar.gz
| Download URL | asn1tools-0.9.0.tar.gz |
|---|---|
| Size | 103.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa7fae40e890868ec1cec3329609d0fd4dd9c38e45f49559f30e3f60a1b085ef
|
|
BLAKE2b-256 checksum How to use checksums |
e9096ab03748d3839ebf584abc2d32791dc01802de76717bd002131eeb7927b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / asn1tools-0.9.0-py2.py3-none-any.whl
| Download URL | asn1tools-0.9.0-py2.py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
790fd80e6b8245223c4f471dbb0cba841e81d82e0dd2f572426a15f61e3570ac
|
|
BLAKE2b-256 checksum How to use checksums |
925a1b53329020eaef2335014a1f875177acefb93d6f90ae0e9ef7468c2b834c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for asn1tools 0.9.0
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.