2D-Doc toolsuite
Project description
2D-Doc parser library
This is a 2D-DOC parser library. It is able to decode and pretty-print a 2D-Doc as defined by French ANTS, and is also able to verify signature.
Usage
Dumper
There is a built-in dumper tool that can be called through command line with:
$ python -m tddoc.dump --test-ca tests/spec_samples/3.1.3/15.2.2/17.txt
tests/spec_samples/3.1.3/15.2.2/17.txt:
Version: 3
Country: FR
CA: FR00
Cert: 0001
Emit date: 2179-06-06
Sign date: 2017-06-18
Emitter doc type: Carte T3P
User doc type: Justificatif d'activité
Identifiants de données relatives aux véhicules
Numéro de la carte: 12345678901
Date d’expiration initiale: 2019-11-30
Sign: a06b0fb1979c3a526d797a019c78f969a09d9973553d3e353d79a4a29041a4100792ccce10821f328046a36a024a2f47366c2df0cc627344d2070aa987c8e047
Signature OK
API
A basic parsing sessions boils down to:
>>> from tddoc.doc import TwoDDoc
>>> c = TwoDDoc.from_code(open('tests/spec_samples/3.1.3/15.2.2/17.txt', 'r').read().strip())
>>> c.header.doc_type().user_type
"Justificatif d'activité"
>>> c.header.doc_type().emitter_type
'Carte T3P'
>>> c.message.dataset
[<tddoc.message.FixedData object at 0x10ab320a0>, <tddoc.message.FixedData object at 0x10ab32310>]
>>> c.message.dataset[0].definition.name
'Numéro de la carte'
>>> c.message.dataset[0].value
'12345678901'
>>> from tddoc.keychain import internal
>>> chain = internal()
>>> c.header.ca_id
'FR00'
>>> c.header.cert_id
'0001'
>>> c.signature_is_valid(chain)
True
Certificate Chains
The library ships with bundled certificate chains from the French ANTS Trust Service List (TSL). These are loaded automatically by keychain.internal(). Test CA "FR00" is not loaded automatically unless explicitly asked for.
To download additional or updated chains, install the fetch extras and run:
$ pip install tddoc[fetch]
$ python -m tddoc.fetch_chains
This downloads chains to ~/.config/tddoc/chains/, which are automatically loaded after the bundled ones.
To update the bundled chains shipped with the package (for maintainers):
$ python -m tddoc.fetch_chains
TODO
- Documentation
- Full API documentation, better pydoc strings.
- Support for "binary" V4 messages
- And support for V4 ancillary data
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tddoc-0.3.0.tar.gz.
File metadata
- Download URL: tddoc-0.3.0.tar.gz
- Upload date:
- Size: 236.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
678a405aa42abc8df09c972ea23c442c77e618ebd5e8de1964e432fff369fbf2
|
|
| MD5 |
57e6b4feb6237ce6731c04d94c30c1ec
|
|
| BLAKE2b-256 |
1561134f3d4a6b5650b2428155274f7f215897b770e9c7a3bcaeda5646a580a6
|
Provenance
The following attestation bundles were made for tddoc-0.3.0.tar.gz:
Publisher:
publish.yml on sylvainpelissier/tddoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tddoc-0.3.0.tar.gz -
Subject digest:
678a405aa42abc8df09c972ea23c442c77e618ebd5e8de1964e432fff369fbf2 - Sigstore transparency entry: 2231881858
- Sigstore integration time:
-
Permalink:
sylvainpelissier/tddoc@d09b53f468921611e68171f2a11adbaa250cf37b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sylvainpelissier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d09b53f468921611e68171f2a11adbaa250cf37b -
Trigger Event:
release
-
Statement type:
File details
Details for the file tddoc-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tddoc-0.3.0-py3-none-any.whl
- Upload date:
- Size: 357.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f94c1a2efcbef5994bb31b51333bd8926a852ba0714dedcaa42cf480c5b1a0a
|
|
| MD5 |
7dd1ad6e92de6aa9ac967a564b5ec83b
|
|
| BLAKE2b-256 |
01f95a74a0d7d0a13a13910fb732314cb78008fae14d91f067e0f4332deadc59
|
Provenance
The following attestation bundles were made for tddoc-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on sylvainpelissier/tddoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tddoc-0.3.0-py3-none-any.whl -
Subject digest:
4f94c1a2efcbef5994bb31b51333bd8926a852ba0714dedcaa42cf480c5b1a0a - Sigstore transparency entry: 2231882205
- Sigstore integration time:
-
Permalink:
sylvainpelissier/tddoc@d09b53f468921611e68171f2a11adbaa250cf37b -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/sylvainpelissier
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d09b53f468921611e68171f2a11adbaa250cf37b -
Trigger Event:
release
-
Statement type: