single |
# asn1crypto
A fast, pure Python library for parsing and serializing ASN.1 structures.
- [Features]
- [Why Another Python ASN.1 Library?]
- [Related Crypto Libraries]
- [Current Release]
- [Dependencies]
- [Installation]
- [License]
- [Security Policy]
- [Documentation]
- [Continuous Integration]
- [Testing]
- [Development]
- [CI Tasks]
[GitHub Actions CI]
[CircleCI]
[PyPI]
## Features
In addition to an ASN.1 BER/DER decoder and DER serializer, the project
includes
a bunch of ASN.1 structures for use with various common cryptography
standards:
| Standard | Module |
Source
|
| ---------------------- | ------------------------------------------- |
----------------------------------------------------------------------------------------------------------------------
|
| X.509 | [`asn1crypto.x509`] | [RFC 5280]
|
| CRL | [`asn1crypto.crl`] | [RFC 5280]
|
| CSR | [`asn1crypto.csr`] | [RFC 2986], [RFC
2985] |
| OCSP | [`asn1crypto.ocsp`] | [RFC 6960]
|
| PKCS#12 | [`asn1crypto.pkcs12`] | [RFC 7292]
|
| PKCS#8 | [`asn1crypto.keys`] | [RFC 5208]
|
| PKCS#1 v2.1 (RSA keys) | [`asn1crypto.keys`] | [RFC 3447]
|
| DSA keys | [`asn1crypto.keys`] | [RFC 3279]
|
| Elliptic curve keys | [`asn1crypto.keys`] | [SECG SEC1 V2]
|
| PKCS#3 v1.4 | [`asn1crypto.algos`] | [PKCS#3 v1.4]
|
| PKCS#5 v2.1 | [`asn1crypto.algos`] | [PKCS#5 v2.1] |
| CMS (and PKCS#7) | [`asn1crypto.cms`] | [RFC 5652], [RFC
2315] |
| TSP | [`asn1crypto.tsp`] | [RFC 3161]
|
| PDF signatures | [`asn1crypto.pdf`] | [PDF 1.7]
|
## Why Another Python ASN.1 Library?
Python has long had the [pyasn1] and
[pyasn1_modules] available for
parsing and serializing ASN.1 structures. While the project does include a
comprehensive set of tools for parsing and serializing, the performance of
the
library can be very poor, especially when dealing with bit fields and
parsing
large structures such as CRLs.
After spending extensive time using *pyasn1*, the following issues were
identified:
1. Poor performance
2. Verbose, non-pythonic API
3. Out-dated and incomplete definitions in *pyasn1-modules*
4. No simple way to map data to native Python data structures
5. No mechanism for overridden universal ASN.1 types
The *pyasn1* API is largely method driven, and uses extensive configuration
objects and lowerCamelCase names. There were no consistent options for
converting types of native Python data structures. Since the project
supports
out-dated versions of Python, many newer language features are unavailable
for use.
Time was spent trying to profile issues with the performance, however the
architecture made it hard to pin down the primary source of the poor
performance. Attempts were made to improve performance by utilizing
unreleased
patches and delaying parsing using the `Any` type. Even with such changes,
the
performance was still unacceptably slow.
Finally, a number of structures in the cryptographic space use universal
data
|