| 1 |
[](https://gitlab.com/coroner/cryptoparser/-/pipelines/master/latest) |
| 2 |
[](https://coveralls.io/gitlab/coroner/cryptoparser/) |
| 3 |
[](https://cryptoparser.readthedocs.io) |
| 4 |
|
| 5 |
<!-- documentation-summary-start --> |
| 6 |
**CryptoParser** is a cryptographic protocol |
| 7 |
([IKE](https://en.wikipedia.org/wiki/Internet_Key_Exchange), |
| 8 |
[SSL](https://en.wikipedia.org/wiki/Transport_Layer_Security#SSL_1.0,_2.0,_and_3.0), |
| 9 |
[TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security), |
| 10 |
[SSH](https://en.wikipedia.org/wiki/Secure_Shell), |
| 11 |
[DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions)) and security-related protocol piece |
| 12 |
([HTTP headers](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields)) parser and generator. It is neither a |
| 13 |
comprehensive nor a secure implementation of any cryptographic protocol. The goal is to support testing cryptographic |
| 14 |
libraries or analysing cryptography-related settings of application servers such as |
| 15 |
[CryptoLyzer](https://cryptolyzer.readthedocs.io/) does. |
| 16 |
|
| 17 |
**Use CryptoParser when you need to parse handshake messages** — it implements the wire format of ISAKMP, IKEv1, IKEv2, |
| 18 |
SSL 2.0, SSL 3.0, TLS 1.0 to TLS 1.3, and SSH 2.0, so a message can be read field by field instead of being handed to a |
| 19 |
connection-oriented library. |
| 20 |
|
| 21 |
**Use CryptoParser when you need to generate messages a library refuses to send** — analysis means triggering special |
| 22 |
and corner cases, so messages can be composed with deprecated, experimental, or plainly invalid values that an |
| 23 |
implementation aiming for secure connections would reject. |
| 24 |
|
| 25 |
**Use CryptoParser when you need parsed HTTP security headers** — beyond wire format parsing it parses individual |
| 26 |
headers, so directives are available as typed values rather than as strings. |
| 27 |
|
| 28 |
**Use CryptoParser when you need DNSSEC record parsing** — DNSSEC records are parsed into the same kind of typed |
| 29 |
structures as the protocol messages. |
| 30 |
<!-- documentation-summary-end --> |
| 31 |
|
| 32 |
<!-- documentation-strength-start --> |
| 33 |
The strength of CryptoParser is that it is backed by the most comprehensive algorithm identifier database available |
| 34 |
([CryptoDataHub](https://cryptodatahub.readthedocs.io)). This makes it possible to recognize rarely used, deprecated, |
| 35 |
non-standard, or experimental algorithms that are not supported by any version of OpenSSL, GnuTLS, LibreSSL, or |
| 36 |
wolfSSL. |
| 37 |
<!-- documentation-strength-end --> |
| 38 |
|
| 39 |
## Why CryptoParser? |
| 40 |
|
| 41 |
<!-- documentation-comparison-start --> |
| 42 |
- **Analysis oriented** — the library implements only the parts of a protocol that analysis needs, and deliberately |
| 43 |
keeps the parts that make a message invalid. |
| 44 |
- **No OpenSSL dependency** — the protocol implementation is its own, so what can be parsed or generated is not limited |
| 45 |
by what a cryptographic library is willing to do. |
| 46 |
- **Typed values, not byte offsets** — algorithm identifiers, protocol versions, and header directives are parsed into |
| 47 |
enumerations and attribute classes. |
| 48 |
- **Symmetric parsing and composing** — every parsable piece can also be composed back to its wire format. |
| 49 |
<!-- documentation-comparison-end --> |
| 50 |
|
| 51 |
## Usage |
| 52 |
|
| 53 |
### uv |
| 54 |
|
| 55 |
```shell |
| 56 |
uv add cryptoparser |
| 57 |
``` |
| 58 |
|
| 59 |
```python |
| 60 |
from cryptoparser.tls.version import TlsProtocolVersion |
| 61 |
|
| 62 |
# parse a protocol version from its wire format |
| 63 |
TlsProtocolVersion.parse_exact_size(b'\x03\x03') |
| 64 |
# TLS 1.2 |
| 65 |
|
| 66 |
# compose a protocol version back to its wire format |
| 67 |
TlsProtocolVersion.parse_exact_size(b'\x03\x04').compose() |
| 68 |
# bytearray(b'\x03\x04') |
| 69 |
``` |
| 70 |
|
| 71 |
## Support |
| 72 |
|
| 73 |
**Python implementations** |
| 74 |
|
| 75 |
- CPython 3.9+ |
| 76 |
- PyPy 3.9+ |
| 77 |
|
| 78 |
**Operating systems** |
| 79 |
|
| 80 |
- Linux |
| 81 |
- macOS |
| 82 |
- Windows |
| 83 |
|
| 84 |
## Documentation |
| 85 |
|
| 86 |
Detailed [documentation](https://cryptoparser.readthedocs.io) is available on the project's |
| 87 |
[Read the Docs](https://readthedocs.com) site. |
| 88 |
|
| 89 |
## License |
| 90 |
|
| 91 |
The [code](https://gitlab.com/coroner/cryptoparser) is available under the terms of |
| 92 |
[Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/) (MPL 2.0). |
| 93 |
|
| 94 |
A non-comprehensive but straightforward description of MPL 2.0 can be found at the |
| 95 |
[Choose an open source license](https://choosealicense.com/licenses#mpl-2.0) website. |
| 96 |
|
| 97 |
## Credits |
| 98 |
|
| 99 |
- [NLnet Foundation](https://nlnet.nl) and [NGI Assure](https://www.assure.ngi.eu), supports the project part of the |
| 100 |
[Next Generation Internet](https://ngi.eu) initiative. |