METADATA 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. Metadata-Version: 2.1
  2. Name: asn1crypto
  3. Version: 1.5.1
  4. Summary: Fast ASN.1 parser and serializer with definitions for private keys, public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7, PKCS#8, PKCS#12, PKCS#5, X.509 and TSP
  5. Home-page: https://github.com/wbond/asn1crypto
  6. Author: wbond
  7. Author-email: will@wbond.net
  8. License: MIT
  9. Keywords: asn1 crypto pki x509 certificate rsa dsa ec dh
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved :: MIT License
  14. Classifier: Programming Language :: Python
  15. Classifier: Programming Language :: Python :: 2
  16. Classifier: Programming Language :: Python :: 2.6
  17. Classifier: Programming Language :: Python :: 2.7
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.2
  20. Classifier: Programming Language :: Python :: 3.3
  21. Classifier: Programming Language :: Python :: 3.4
  22. Classifier: Programming Language :: Python :: 3.5
  23. Classifier: Programming Language :: Python :: 3.6
  24. Classifier: Programming Language :: Python :: 3.7
  25. Classifier: Programming Language :: Python :: 3.8
  26. Classifier: Programming Language :: Python :: 3.9
  27. Classifier: Programming Language :: Python :: 3.10
  28. Classifier: Programming Language :: Python :: Implementation :: CPython
  29. Classifier: Programming Language :: Python :: Implementation :: PyPy
  30. Classifier: Topic :: Security :: Cryptography
  31. Description-Content-Type: text/markdown
  32. # asn1crypto
  33. A fast, pure Python library for parsing and serializing ASN.1 structures.
  34. - [Features](#features)
  35. - [Why Another Python ASN.1 Library?](#why-another-python-asn1-library)
  36. - [Related Crypto Libraries](#related-crypto-libraries)
  37. - [Current Release](#current-release)
  38. - [Dependencies](#dependencies)
  39. - [Installation](#installation)
  40. - [License](#license)
  41. - [Security Policy](#security-policy)
  42. - [Documentation](#documentation)
  43. - [Continuous Integration](#continuous-integration)
  44. - [Testing](#testing)
  45. - [Development](#development)
  46. - [CI Tasks](#ci-tasks)
  47. [![GitHub Actions CI](https://github.com/wbond/asn1crypto/workflows/CI/badge.svg)](https://github.com/wbond/asn1crypto/actions?workflow=CI)
  48. [![CircleCI](https://circleci.com/gh/wbond/asn1crypto.svg?style=shield)](https://circleci.com/gh/wbond/asn1crypto)
  49. [![PyPI](https://img.shields.io/pypi/v/asn1crypto.svg)](https://pypi.org/project/asn1crypto/)
  50. ## Features
  51. In addition to an ASN.1 BER/DER decoder and DER serializer, the project includes
  52. a bunch of ASN.1 structures for use with various common cryptography standards:
  53. | Standard | Module | Source |
  54. | ---------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
  55. | X.509 | [`asn1crypto.x509`](asn1crypto/x509.py) | [RFC 5280](https://tools.ietf.org/html/rfc5280) |
  56. | CRL | [`asn1crypto.crl`](asn1crypto/crl.py) | [RFC 5280](https://tools.ietf.org/html/rfc5280) |
  57. | CSR | [`asn1crypto.csr`](asn1crypto/csr.py) | [RFC 2986](https://tools.ietf.org/html/rfc2986), [RFC 2985](https://tools.ietf.org/html/rfc2985) |
  58. | OCSP | [`asn1crypto.ocsp`](asn1crypto/ocsp.py) | [RFC 6960](https://tools.ietf.org/html/rfc6960) |
  59. | PKCS#12 | [`asn1crypto.pkcs12`](asn1crypto/pkcs12.py) | [RFC 7292](https://tools.ietf.org/html/rfc7292) |
  60. | PKCS#8 | [`asn1crypto.keys`](asn1crypto/keys.py) | [RFC 5208](https://tools.ietf.org/html/rfc5208) |
  61. | PKCS#1 v2.1 (RSA keys) | [`asn1crypto.keys`](asn1crypto/keys.py) | [RFC 3447](https://tools.ietf.org/html/rfc3447) |
  62. | DSA keys | [`asn1crypto.keys`](asn1crypto/keys.py) | [RFC 3279](https://tools.ietf.org/html/rfc3279) |
  63. | Elliptic curve keys | [`asn1crypto.keys`](asn1crypto/keys.py) | [SECG SEC1 V2](http://www.secg.org/sec1-v2.pdf) |
  64. | PKCS#3 v1.4 | [`asn1crypto.algos`](asn1crypto/algos.py) | [PKCS#3 v1.4](ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-3.asc) |
  65. | PKCS#5 v2.1 | [`asn1crypto.algos`](asn1crypto/algos.py) | [PKCS#5 v2.1](http://www.emc.com/collateral/white-papers/h11302-pkcs5v2-1-password-based-cryptography-standard-wp.pdf) |
  66. | CMS (and PKCS#7) | [`asn1crypto.cms`](asn1crypto/cms.py) | [RFC 5652](https://tools.ietf.org/html/rfc5652), [RFC 2315](https://tools.ietf.org/html/rfc2315) |
  67. | TSP | [`asn1crypto.tsp`](asn1crypto/tsp.py) | [RFC 3161](https://tools.ietf.org/html/rfc3161) |
  68. | PDF signatures | [`asn1crypto.pdf`](asn1crypto/pdf.py) | [PDF 1.7](http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf) |
  69. ## Why Another Python ASN.1 Library?
  70. Python has long had the [pyasn1](https://pypi.org/project/pyasn1/) and
  71. [pyasn1_modules](https://pypi.org/project/pyasn1-modules/) available for
  72. parsing and serializing ASN.1 structures. While the project does include a
  73. comprehensive set of tools for parsing and serializing, the performance of the
  74. library can be very poor, especially when dealing with bit fields and parsing
  75. large structures such as CRLs.
  76. After spending extensive time using *pyasn1*, the following issues were
  77. identified:
  78. 1. Poor performance
  79. 2. Verbose, non-pythonic API
  80. 3. Out-dated and incomplete definitions in *pyasn1-modules*
  81. 4. No simple way to map data to native Python data structures
  82. 5. No mechanism for overridden universal ASN.1 types
  83. The *pyasn1* API is largely method driven, and uses extensive configuration
  84. objects and lowerCamelCase names. There were no consistent options for
  85. converting types of native Python data structures. Since the project supports
  86. out-dated versions of Python, many newer language features are unavailable
  87. for use.
  88. Time was spent trying to profile issues with the performance, however the
  89. architecture made it hard to pin down the primary source of the poor
  90. performance. Attempts were made to improve performance by utilizing unreleased
  91. patches and delaying parsing using the `Any` type. Even with such changes, the
  92. performance was still unacceptably slow.
  93. Finally, a number of structures in the cryptographic space use universal data
  94. types such as `BitString` and `OctetString`, but interpret the data as other
  95. types. For instance, signatures are really byte strings, but are encoded as
  96. `BitString`. Elliptic curve keys use both `BitString` and `OctetString` to
  97. represent integers. Parsing these structures as the base universal types and
  98. then re-interpreting them wastes computation.
  99. *asn1crypto* uses the following techniques to improve performance, especially
  100. when extracting one or two fields from large, complex structures:
  101. - Delayed parsing of byte string values
  102. - Persistence of original ASN.1 encoded data until a value is changed
  103. - Lazy loading of child fields
  104. - Utilization of high-level Python stdlib modules
  105. While there is no extensive performance test suite, the
  106. `CRLTests.test_parse_crl` test case was used to parse a 21MB CRL file on a
  107. late 2013 rMBP. *asn1crypto* parsed the certificate serial numbers in just
  108. under 8 seconds. With *pyasn1*, using definitions from *pyasn1-modules*, the
  109. same parsing took over 4,100 seconds.
  110. For smaller structures the performance difference can range from a few times
  111. faster to an order of magnitude or more.
  112. ## Related Crypto Libraries
  113. *asn1crypto* is part of the modularcrypto family of Python packages:
  114. - [asn1crypto](https://github.com/wbond/asn1crypto)
  115. - [oscrypto](https://github.com/wbond/oscrypto)
  116. - [csrbuilder](https://github.com/wbond/csrbuilder)
  117. - [certbuilder](https://github.com/wbond/certbuilder)
  118. - [crlbuilder](https://github.com/wbond/crlbuilder)
  119. - [ocspbuilder](https://github.com/wbond/ocspbuilder)
  120. - [certvalidator](https://github.com/wbond/certvalidator)
  121. ## Current Release
  122. 1.5.0 - [changelog](changelog.md)
  123. ## Dependencies
  124. Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10 or pypy. *No third-party
  125. packages required.*
  126. ## Installation
  127. ```bash
  128. pip install asn1crypto
  129. ```
  130. ## License
  131. *asn1crypto* is licensed under the terms of the MIT license. See the
  132. [LICENSE](LICENSE) file for the exact license text.
  133. ## Security Policy
  134. The security policies for this project are covered in
  135. [SECURITY.md](https://github.com/wbond/asn1crypto/blob/master/SECURITY.md).
  136. ## Documentation
  137. The documentation for *asn1crypto* is composed of tutorials on basic usage and
  138. links to the source for the various pre-defined type classes.
  139. ### Tutorials
  140. - [Universal Types with BER/DER Decoder and DER Encoder](docs/universal_types.md)
  141. - [PEM Encoder and Decoder](docs/pem.md)
  142. ### Reference
  143. - [Universal types](asn1crypto/core.py), `asn1crypto.core`
  144. - [Digest, HMAC, signed digest and encryption algorithms](asn1crypto/algos.py), `asn1crypto.algos`
  145. - [Private and public keys](asn1crypto/keys.py), `asn1crypto.keys`
  146. - [X509 certificates](asn1crypto/x509.py), `asn1crypto.x509`
  147. - [Certificate revocation lists (CRLs)](asn1crypto/crl.py), `asn1crypto.crl`
  148. - [Online certificate status protocol (OCSP)](asn1crypto/ocsp.py), `asn1crypto.ocsp`
  149. - [Certificate signing requests (CSRs)](asn1crypto/csr.py), `asn1crypto.csr`
  150. - [Private key/certificate containers (PKCS#12)](asn1crypto/pkcs12.py), `asn1crypto.pkcs12`
  151. - [Cryptographic message syntax (CMS, PKCS#7)](asn1crypto/cms.py), `asn1crypto.cms`
  152. - [Time stamp protocol (TSP)](asn1crypto/tsp.py), `asn1crypto.tsp`
  153. - [PDF signatures](asn1crypto/pdf.py), `asn1crypto.pdf`
  154. ## Continuous Integration
  155. Various combinations of platforms and versions of Python are tested via:
  156. - [macOS, Linux, Windows](https://github.com/wbond/asn1crypto/actions/workflows/ci.yml) via GitHub Actions
  157. - [arm64](https://circleci.com/gh/wbond/asn1crypto) via CircleCI
  158. ## Testing
  159. Tests are written using `unittest` and require no third-party packages.
  160. Depending on what type of source is available for the package, the following
  161. commands can be used to run the test suite.
  162. ### Git Repository
  163. When working within a Git working copy, or an archive of the Git repository,
  164. the full test suite is run via:
  165. ```bash
  166. python run.py tests
  167. ```
  168. To run only some tests, pass a regular expression as a parameter to `tests`.
  169. ```bash
  170. python run.py tests ocsp
  171. ```
  172. ### PyPi Source Distribution
  173. When working within an extracted source distribution (aka `.tar.gz`) from
  174. PyPi, the full test suite is run via:
  175. ```bash
  176. python setup.py test
  177. ```
  178. ### Package
  179. When the package has been installed via pip (or another method), the package
  180. `asn1crypto_tests` may be installed and invoked to run the full test suite:
  181. ```bash
  182. pip install asn1crypto_tests
  183. python -m asn1crypto_tests
  184. ```
  185. ## Development
  186. To install the package used for linting, execute:
  187. ```bash
  188. pip install --user -r requires/lint
  189. ```
  190. The following command will run the linter:
  191. ```bash
  192. python run.py lint
  193. ```
  194. Support for code coverage can be installed via:
  195. ```bash
  196. pip install --user -r requires/coverage
  197. ```
  198. Coverage is measured by running:
  199. ```bash
  200. python run.py coverage
  201. ```
  202. To change the version number of the package, run:
  203. ```bash
  204. python run.py version {pep440_version}
  205. ```
  206. To install the necessary packages for releasing a new version on PyPI, run:
  207. ```bash
  208. pip install --user -r requires/release
  209. ```
  210. Releases are created by:
  211. - Making a git tag in [PEP 440](https://www.python.org/dev/peps/pep-0440/#examples-of-compliant-version-schemes) format
  212. - Running the command:
  213. ```bash
  214. python run.py release
  215. ```
  216. Existing releases can be found at https://pypi.org/project/asn1crypto/.
  217. ## CI Tasks
  218. A task named `deps` exists to download and stage all necessary testing
  219. dependencies. On posix platforms, `curl` is used for downloads and on Windows
  220. PowerShell with `Net.WebClient` is used. This configuration sidesteps issues
  221. related to getting pip to work properly and messing with `site-packages` for
  222. the version of Python being used.
  223. The `ci` task runs `lint` (if flake8 is available for the version of Python) and
  224. `coverage` (or `tests` if coverage is not available for the version of Python).
  225. If the current directory is a clean git working copy, the coverage data is
  226. submitted to codecov.io.
  227. ```bash
  228. python run.py deps
  229. python run.py ci
  230. ```