]> Cypherpunks.ru repositories - pyderasn.git/blob - doc/features.rst
Grammar fix
[pyderasn.git] / doc / features.rst
1 Features
2 ========
3
4 * Basic ASN.1 data types (X.208): BOOLEAN, INTEGER, BIT STRING, OCTET
5   STRING, NULL, OBJECT IDENTIFIER, ENUMERATED, all strings, UTCTime,
6   GeneralizedTime, CHOICE, ANY, SEQUENCE (OF), SET (OF)
7 * Size constraints checking
8 * Working with sequences as high level data objects with ability to
9   (un)marshall them
10 * Python 2.7/3.5 compatibility
11
12 Why yet another library? `pyasn1 <https://github.com/etingof/pyasn1>`__
13 had all of this a long time ago. PyDERASN resembles it in many ways. In
14 practice it should be relatively easy to convert ``pyasn1``'s code to
15 ``pyderasn``'s one. But additionally it offers:
16
17 * Small, simple and trying to be reviewable code. Just a single file
18 * ``__slots__`` friendliness
19 * Ability to know exact decoded objects offsets and lengths in the binary
20 * Pretty printer and command-line decoder, that could conveniently
21   replace utilities like either ``dumpasn1`` or ``openssl asn1parse``
22 * Some kind of strong typing: SEQUENCEs require the exact **type** of
23   settable values, even when they are inherited
24 * However they do not require tags matching: IMPLICIT/EXPLICIT tags will
25   be set automatically in the given sequence
26 * Could be significantly faster. For example parsing of CACert.org's CRL
27   under Python 3.5.2:
28
29     :``python -mpyderasn revoke.crl``:
30      ~2 min
31     :``python -mpyderasn --schema path.to.CertificateList revoke.crl``:
32      ~38 sec
33     :``pyasn1.decode(asn1Spec=pyasn1.CertificateList())``:
34      ~22 min (``pyasn1 == 0.2.3``)
35
36 There are drawbacks:
37
38 * No old Python versions support
39 * No BER/CER support
40 * PyDERASN does **not** have object recreation capable ``repr``-s::
41
42     pyderasn>>> repr(algo_id)
43     AlgorithmIdentifier SEQUENCE[OBJECT IDENTIFIER 1.3.14.3.2.26, [UNIV 5] ANY 0500 OPTIONAL]
44
45     pyasn1>>> repr(algo_id)
46     AlgorithmIdentifier().setComponents(ObjectIdentifier('1.3.14.3.2.26'), Any(hexValue='0500'))
47
48 * Strings are not validated in any way, except just trying to be decoded
49   in ``ascii``, ``iso-8859-1``, ``utf-8/16/32`` correspondingly
50 * No REAL, RELATIVE OID, EXTERNAL, INSTANCE OF, EMBEDDED PDV, CHARACTER STRING