Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

303 rader
13 KiB

  1. Metadata-Version: 2.1
  2. Name: asn1crypto
  3. Version: 1.2.0
  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 :: Implementation :: CPython
  27. Classifier: Programming Language :: Python :: Implementation :: PyPy
  28. Classifier: Topic :: Security :: Cryptography
  29. Description-Content-Type: text/markdown
  30. # asn1crypto
  31. A fast, pure Python library for parsing and serializing ASN.1 structures.
  32. - [Features](#features)
  33. - [Why Another Python ASN.1 Library?](#why-another-python-asn1-library)
  34. - [Related Crypto Libraries](#related-crypto-libraries)
  35. - [Current Release](#current-release)
  36. - [Dependencies](#dependencies)
  37. - [Installation](#installation)
  38. - [License](#license)
  39. - [Documentation](#documentation)
  40. - [Continuous Integration](#continuous-integration)
  41. - [Testing](#testing)
  42. - [Development](#development)
  43. - [CI Tasks](#ci-tasks)
  44. [![GitHub Actions CI](https://github.com/wbond/asn1crypto/workflows/CI/badge.svg)](https://github.com/wbond/asn1crypto/actions?workflow=CI)
  45. [![Travis CI](https://api.travis-ci.org/wbond/asn1crypto.svg?branch=master)](https://travis-ci.org/wbond/asn1crypto)
  46. [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/wbond/asn1crypto?branch=master&svg=true)](https://ci.appveyor.com/project/wbond/asn1crypto)
  47. [![CircleCI](https://circleci.com/gh/wbond/asn1crypto.svg?style=shield)](https://circleci.com/gh/wbond/asn1crypto)
  48. [![Codecov](https://codecov.io/gh/wbond/asn1crypto/branch/master/graph/badge.svg)](https://codecov.io/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.2.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 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. ## Documentation
  134. The documentation for *asn1crypto* is composed of tutorials on basic usage and
  135. links to the source for the various pre-defined type classes.
  136. ### Tutorials
  137. - [Universal Types with BER/DER Decoder and DER Encoder](docs/universal_types.md)
  138. - [PEM Encoder and Decoder](docs/pem.md)
  139. ### Reference
  140. - [Universal types](asn1crypto/core.py), `asn1crypto.core`
  141. - [Digest, HMAC, signed digest and encryption algorithms](asn1crypto/algos.py), `asn1crypto.algos`
  142. - [Private and public keys](asn1crypto/keys.py), `asn1crypto.keys`
  143. - [X509 certificates](asn1crypto/x509.py), `asn1crypto.x509`
  144. - [Certificate revocation lists (CRLs)](asn1crypto/crl.py), `asn1crypto.crl`
  145. - [Online certificate status protocol (OCSP)](asn1crypto/ocsp.py), `asn1crypto.ocsp`
  146. - [Certificate signing requests (CSRs)](asn1crypto/csr.py), `asn1crypto.csr`
  147. - [Private key/certificate containers (PKCS#12)](asn1crypto/pkcs12.py), `asn1crypto.pkcs12`
  148. - [Cryptographic message syntax (CMS, PKCS#7)](asn1crypto/cms.py), `asn1crypto.cms`
  149. - [Time stamp protocol (TSP)](asn1crypto/tsp.py), `asn1crypto.tsp`
  150. - [PDF signatures](asn1crypto/pdf.py), `asn1crypto.pdf`
  151. ## Continuous Integration
  152. - [Windows](https://ci.appveyor.com/project/wbond/asn1crypto/history) via AppVeyor
  153. - [OS X](https://circleci.com/gh/wbond/asn1crypto) via CircleCI
  154. - [Linux](https://travis-ci.org/wbond/asn1crypto/builds) via Travis CI
  155. - [Test Coverage](https://codecov.io/gh/wbond/asn1crypto/commits) via Codecov
  156. ## Testing
  157. Tests are written using `unittest` and require no third-party packages.
  158. Depending on what type of source is available for the package, the following
  159. commands can be used to run the test suite.
  160. ### Git Repository
  161. When working within a Git working copy, or an archive of the Git repository,
  162. the full test suite is run via:
  163. ```bash
  164. python run.py tests
  165. ```
  166. To run only some tests, pass a regular expression as a parameter to `tests`.
  167. ```bash
  168. python run.py tests ocsp
  169. ```
  170. ### PyPi Source Distribution
  171. When working within an extracted source distribution (aka `.tar.gz`) from
  172. PyPi, the full test suite is run via:
  173. ```bash
  174. python setup.py test
  175. ```
  176. ### Package
  177. When the package has been installed via pip (or another method), the package
  178. `asn1crypto_tests` may be installed and invoked to run the full test suite:
  179. ```bash
  180. pip install asn1crypto_tests
  181. python -m asn1crypto_tests
  182. ```
  183. ## Development
  184. To install the package used for linting, execute:
  185. ```bash
  186. pip install --user -r requires/lint
  187. ```
  188. The following command will run the linter:
  189. ```bash
  190. python run.py lint
  191. ```
  192. Support for code coverage can be installed via:
  193. ```bash
  194. pip install --user -r requires/coverage
  195. ```
  196. Coverage is measured by running:
  197. ```bash
  198. python run.py coverage
  199. ```
  200. To change the version number of the package, run:
  201. ```bash
  202. python run.py version {pep440_version}
  203. ```
  204. To install the necessary packages for releasing a new version on PyPI, run:
  205. ```bash
  206. pip install --user -r requires/release
  207. ```
  208. Releases are created by:
  209. - Making a git tag in [PEP 440](https://www.python.org/dev/peps/pep-0440/#examples-of-compliant-version-schemes) format
  210. - Running the command:
  211. ```bash
  212. python run.py release
  213. ```
  214. Existing releases can be found at https://pypi.org/project/asn1crypto/.
  215. ## CI Tasks
  216. A task named `deps` exists to download and stage all necessary testing
  217. dependencies. On posix platforms, `curl` is used for downloads and on Windows
  218. PowerShell with `Net.WebClient` is used. This configuration sidesteps issues
  219. related to getting pip to work properly and messing with `site-packages` for
  220. the version of Python being used.
  221. The `ci` task runs `lint` (if flake8 is available for the version of Python) and
  222. `coverage` (or `tests` if coverage is not available for the version of Python).
  223. If the current directory is a clean git working copy, the coverage data is
  224. submitted to codecov.io.
  225. ```bash
  226. python run.py deps
  227. python run.py ci
  228. ```