pythonbeid 0.3.0__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. pythonbeid-1.0.1/CHANGELOG.md +111 -0
  2. pythonbeid-1.0.1/CONTRIBUTING.md +45 -0
  3. pythonbeid-1.0.1/MANIFEST.in +3 -0
  4. pythonbeid-1.0.1/PKG-INFO +294 -0
  5. pythonbeid-1.0.1/README.md +247 -0
  6. pythonbeid-1.0.1/SECURITY.md +21 -0
  7. pythonbeid-1.0.1/pyproject.toml +133 -0
  8. pythonbeid-1.0.1/pythonbeid/__init__.py +85 -0
  9. pythonbeid-1.0.1/pythonbeid/__main__.py +3 -0
  10. pythonbeid-1.0.1/pythonbeid/card_reader.py +882 -0
  11. pythonbeid-1.0.1/pythonbeid/cli.py +176 -0
  12. pythonbeid-1.0.1/pythonbeid/exceptions.py +82 -0
  13. pythonbeid-1.0.1/pythonbeid/integrity.py +455 -0
  14. pythonbeid-1.0.1/pythonbeid/models.py +593 -0
  15. pythonbeid-1.0.1/pythonbeid/parser.py +472 -0
  16. pythonbeid-1.0.1/pythonbeid/py.typed +0 -0
  17. pythonbeid-1.0.1/pythonbeid/trust/belgium_root_ca2.pem +22 -0
  18. pythonbeid-1.0.1/pythonbeid/trust/belgium_root_ca3.pem +32 -0
  19. pythonbeid-1.0.1/pythonbeid/trust/belgium_root_ca4.pem +32 -0
  20. pythonbeid-1.0.1/pythonbeid/trust/belgium_root_ca6.pem +21 -0
  21. pythonbeid-1.0.1/pythonbeid.egg-info/PKG-INFO +294 -0
  22. pythonbeid-1.0.1/pythonbeid.egg-info/SOURCES.txt +36 -0
  23. pythonbeid-1.0.1/pythonbeid.egg-info/entry_points.txt +2 -0
  24. pythonbeid-1.0.1/pythonbeid.egg-info/requires.txt +15 -0
  25. pythonbeid-1.0.1/tests/__init__.py +0 -0
  26. pythonbeid-1.0.1/tests/builders.py +249 -0
  27. pythonbeid-1.0.1/tests/conftest.py +108 -0
  28. pythonbeid-1.0.1/tests/fake_card.py +227 -0
  29. pythonbeid-1.0.1/tests/test_card_reader.py +1089 -0
  30. pythonbeid-1.0.1/tests/test_cli.py +194 -0
  31. pythonbeid-1.0.1/tests/test_hardware.py +92 -0
  32. pythonbeid-1.0.1/tests/test_integrity.py +476 -0
  33. pythonbeid-1.0.1/tests/test_models.py +198 -0
  34. pythonbeid-1.0.1/tests/test_parser.py +484 -0
  35. pythonbeid-0.3.0/PKG-INFO +0 -104
  36. pythonbeid-0.3.0/README.md +0 -81
  37. pythonbeid-0.3.0/pyproject.toml +0 -29
  38. pythonbeid-0.3.0/pythonbeid/__init__.py +0 -13
  39. pythonbeid-0.3.0/pythonbeid/card_reader.py +0 -258
  40. pythonbeid-0.3.0/pythonbeid/exceptions.py +0 -27
  41. pythonbeid-0.3.0/pythonbeid/parser.py +0 -80
  42. pythonbeid-0.3.0/pythonbeid.egg-info/PKG-INFO +0 -104
  43. pythonbeid-0.3.0/pythonbeid.egg-info/SOURCES.txt +0 -14
  44. pythonbeid-0.3.0/pythonbeid.egg-info/requires.txt +0 -7
  45. pythonbeid-0.3.0/tests/test_card_reader.py +0 -258
  46. pythonbeid-0.3.0/tests/test_parser.py +0 -103
  47. {pythonbeid-0.3.0 → pythonbeid-1.0.1}/LICENSE +0 -0
  48. {pythonbeid-0.3.0 → pythonbeid-1.0.1}/pythonbeid.egg-info/dependency_links.txt +0 -0
  49. {pythonbeid-0.3.0 → pythonbeid-1.0.1}/pythonbeid.egg-info/top_level.txt +0 -0
  50. {pythonbeid-0.3.0 → pythonbeid-1.0.1}/setup.cfg +0 -0
@@ -0,0 +1,111 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
+ [Semantic Versioning](https://semver.org/).
6
+
7
+ ## [1.0.1] - 2026-11-25
8
+
9
+ ### Fixed
10
+
11
+ - A card held exclusively by another application (for instance the eID
12
+ middleware during a browser authentication) was reported as missing.
13
+ The connection is now retried for one second, then fails with the new
14
+ `CardInUseError`, which says so.
15
+
16
+ ## [1.0.0] - 2026-11-25
17
+
18
+ ### Added
19
+
20
+ - Typed API: `CardReader.read()` returns an immutable `EidData` with
21
+ `Identity`, `Address` and `CardInfo` dataclasses; `read_identity()`,
22
+ `read_address()`, `read_photo()`, `read_file()`, `read_certificate()`,
23
+ `read_card_info()`.
24
+ - Every field of the identity file defined by the specification v5.0
25
+ (tags `0x00` to `0x1F`), including noble condition, document type, special
26
+ status, photo and basic key digests and the fields of residence cards.
27
+ - `PartialDate` for incomplete birth dates, `Sex`, `DocumentType` and
28
+ `SpecialStatus` enums, `is_valid_national_number()`.
29
+ - Authenticity checks (`pip install "pythonbeid[verify]"`): photo digest,
30
+ identity and address signatures (RSA and ECDSA), RRN certificate chain to
31
+ the bundled Belgian roots CA2, CA3, CA4 and CA6 (end-entity signing
32
+ certificate only), consistency of the decoded data with the signed files,
33
+ basic key and chip challenge on applet 1.8 cards. `CardReader.verify()`,
34
+ `CardReader.authenticate_chip()`, `verify_eid()`, `verify_photo()`,
35
+ `basic_key_matches()`.
36
+ - `EidData.from_files()` to decode and verify raw files received from
37
+ elsewhere (e.g. on a server).
38
+ - Reader selection by index, name or substring; automatic selection of the
39
+ reader holding a Belgian eID card; `timeout` to wait for a card.
40
+ - Command line: `pythonbeid readers | info | read | verify` and
41
+ `python -m pythonbeid`.
42
+ - `py.typed` marker, `__version__`, `CardFile` enum of the card files.
43
+ - `BeidError` base exception, `PCSCServiceError`, `UnsupportedCardError`,
44
+ `CardDataError`; `APDUError.sw`.
45
+ - Card values (names, dates...) never appear in log or exception messages.
46
+
47
+ ### Fixed
48
+
49
+ - Birth dates written in Dutch or German: most months were silently read as
50
+ January, and German dates (`22.DEZ. 1997`) raised an error.
51
+ - Reading a file whose size is a multiple of the block size raised
52
+ `APDUError` (`6B00` at end of file).
53
+ - `61xx` answers were accepted without GET RESPONSE, silently returning
54
+ truncated data.
55
+ - TLV parsing ignored tags: fields were taken by position, which breaks when
56
+ a tag is absent or when the version tag `0x00` is present. Lengths of 255
57
+ bytes and more are now decoded as specified.
58
+ - Values kept their padding spaces and zero bytes.
59
+ - The field read as `suffix` is the first letter of the third given name.
60
+ - pyscard exceptions leaked out of the library; they are now wrapped.
61
+ - Closing the connection powered the card down for other applications.
62
+ - Negative reader indexes silently selected the last reader.
63
+
64
+ ### Changed
65
+
66
+ - Commands run inside PC/SC transactions; the connection recovers when
67
+ another application resets the card.
68
+ - Files are read in 252-byte blocks, like the official middleware.
69
+ - Requires Python 3.11 or later and pyscard 2.0.8 or later.
70
+ - Unknown month names raise `CardDataError` instead of defaulting to January.
71
+
72
+ ### Deprecated
73
+
74
+ - `CardReader.read_informations()` (use `read()`), `reader_index` (pass the
75
+ index as `reader`), `parse_tlv()` (use `decode_tlv()`),
76
+ `parse_french_date()` (use `parse_birth_date()`). They keep their 0.x
77
+ output and will be removed in 2.0.
78
+
79
+ ## [0.3.0] - 2026-06-10
80
+
81
+ ### Added
82
+
83
+ - `list_readers()` public function.
84
+ - Publication to PyPI with Trusted Publishing on version tags.
85
+
86
+ ## [0.2.0] - 2026-03-03
87
+
88
+ ### Changed
89
+
90
+ - Package restructured (`card_reader`, `parser`, `exceptions`), English
91
+ dictionary keys, context manager, dedicated exceptions, `pyproject.toml`,
92
+ test suite.
93
+
94
+ ## [0.1.1] - 2024-06-22
95
+
96
+ ### Fixed
97
+
98
+ - Packaging metadata.
99
+
100
+ ## [0.1.0] - 2024-06-22
101
+
102
+ ### Added
103
+
104
+ - First release on PyPI: identity, address and photo reading.
105
+
106
+ [1.0.1]: https://github.com/Lapin-Blanc/pythonbeid/compare/v1.0.0...v1.0.1
107
+ [1.0.0]: https://github.com/Lapin-Blanc/pythonbeid/compare/v0.3.0...v1.0.0
108
+ [0.3.0]: https://github.com/Lapin-Blanc/pythonbeid/releases/tag/v0.3.0
109
+ [0.2.0]: https://pypi.org/project/pythonbeid/0.2.0/
110
+ [0.1.1]: https://pypi.org/project/pythonbeid/0.1.1/
111
+ [0.1.0]: https://pypi.org/project/pythonbeid/0.1.0/
@@ -0,0 +1,45 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome. Please open an issue first for significant changes.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ python -m venv .venv
9
+ . .venv/bin/activate # .venv\Scripts\activate on Windows
10
+ pip install -e ".[dev]"
11
+ pre-commit install
12
+ ```
13
+
14
+ On Linux, install `pcscd` and `libpcsclite-dev` first.
15
+
16
+ ## Checks
17
+
18
+ ```bash
19
+ pytest # simulated card, coverage must stay at or above 95 %
20
+ pytest --hardware # real card tests (they never print card data)
21
+ ruff check pythonbeid tests
22
+ black pythonbeid tests
23
+ mypy
24
+ ```
25
+
26
+ The CI runs the same checks on Linux, Windows and macOS for every supported
27
+ Python version.
28
+
29
+ ## Conventions
30
+
31
+ - Code, comments, docstrings (Google style) and commit messages in English.
32
+ - Type hints everywhere; `mypy --strict` must pass.
33
+ - [Conventional Commits](https://www.conventionalcommits.org/): `feat:`,
34
+ `fix:`, `docs:`, `refactor:`, `test:`, `chore:`, `ci:`.
35
+ - Work on a branch and open a pull request against `master`.
36
+ - **Never commit data read from a real card.** Tests use the synthetic
37
+ builders in `tests/builders.py` and the simulated card in
38
+ `tests/fake_card.py`.
39
+
40
+ ## Releasing
41
+
42
+ 1. Update the version in `pyproject.toml` and add a section to `CHANGELOG.md`.
43
+ 2. Merge to `master`, then push a `vX.Y.Z` tag.
44
+ 3. The *Publish to PyPI* workflow runs the CI, publishes with Trusted
45
+ Publishing and creates the GitHub release from the changelog.
@@ -0,0 +1,3 @@
1
+ graft tests
2
+ include CHANGELOG.md CONTRIBUTING.md SECURITY.md
3
+ global-exclude *.py[cod] __pycache__
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.4
2
+ Name: pythonbeid
3
+ Version: 1.0.1
4
+ Summary: Read and verify Belgian eID cards (identity, address, photo) through PC/SC
5
+ Author-email: Fabien Toune <fabien.toune@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Lapin-Blanc/pythonbeid
8
+ Project-URL: Repository, https://github.com/Lapin-Blanc/pythonbeid
9
+ Project-URL: Issues, https://github.com/Lapin-Blanc/pythonbeid/issues
10
+ Project-URL: Changelog, https://github.com/Lapin-Blanc/pythonbeid/blob/master/CHANGELOG.md
11
+ Keywords: belgium,eid,beid,belpic,smartcard,pcsc,identity card
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Natural Language :: English
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX :: Linux
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Programming Language :: Python :: 3.15
25
+ Classifier: Topic :: Security
26
+ Classifier: Topic :: Security :: Cryptography
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: System :: Hardware
29
+ Classifier: Typing :: Typed
30
+ Requires-Python: >=3.11
31
+ Description-Content-Type: text/markdown
32
+ License-File: LICENSE
33
+ Requires-Dist: pyscard>=2.0.8
34
+ Provides-Extra: verify
35
+ Requires-Dist: cryptography>=42; extra == "verify"
36
+ Provides-Extra: dev
37
+ Requires-Dist: black>=25; extra == "dev"
38
+ Requires-Dist: build>=1.2; extra == "dev"
39
+ Requires-Dist: cryptography>=42; extra == "dev"
40
+ Requires-Dist: mypy>=1.13; extra == "dev"
41
+ Requires-Dist: pre-commit>=4; extra == "dev"
42
+ Requires-Dist: pytest>=8; extra == "dev"
43
+ Requires-Dist: pytest-cov>=6; extra == "dev"
44
+ Requires-Dist: ruff>=0.8; extra == "dev"
45
+ Requires-Dist: twine>=6; extra == "dev"
46
+ Dynamic: license-file
47
+
48
+ # pythonbeid
49
+
50
+ [![PyPI](https://img.shields.io/pypi/v/pythonbeid)](https://pypi.org/project/pythonbeid/)
51
+ [![Python](https://img.shields.io/pypi/pyversions/pythonbeid)](https://pypi.org/project/pythonbeid/)
52
+ [![CI](https://github.com/Lapin-Blanc/pythonbeid/actions/workflows/ci.yml/badge.svg)](https://github.com/Lapin-Blanc/pythonbeid/actions/workflows/ci.yml)
53
+ [![License: MIT](https://img.shields.io/pypi/l/pythonbeid)](LICENSE)
54
+
55
+ Read and verify **Belgian electronic identity cards** (eID, Kids-ID, residence
56
+ cards for foreign nationals) from Python, with any PC/SC smart card reader.
57
+
58
+ ```python
59
+ from pythonbeid import CardReader
60
+
61
+ with CardReader() as reader:
62
+ eid = reader.read()
63
+ print(eid.identity.last_name, eid.identity.birth_date)
64
+ print(eid.address.street, eid.address.postal_code, eid.address.municipality)
65
+ ```
66
+
67
+ ## Features
68
+
69
+ - **Complete card content**: every field of the identity and address files
70
+ (applet 1.7 and 1.8 layouts), the photo, chip information and certificates.
71
+ - **Correct in every language**: birth dates written in French, Dutch or
72
+ German, incomplete birth dates, `M`/`F`/`V`/`W` sex letters, document types
73
+ and special statuses.
74
+ - **Authenticity checks**: photo digest, National Register signatures of the
75
+ identity and address files, certificate chain up to the Belgian root CAs and,
76
+ on applet 1.8 cards, the chip challenge that detects cloned data.
77
+ - **Robust transport**: follows the official middleware (block size, `6Cxx`,
78
+ `61xx`, end of file), runs inside PC/SC transactions so other applications
79
+ cannot interfere, recovers when another application resets the card, and
80
+ leaves the card powered for them.
81
+ - **Typed API**: immutable dataclasses, enums and `datetime.date`, shipped
82
+ with `py.typed`; strict mypy clean.
83
+ - **Command line**: `pythonbeid read`, `pythonbeid verify`...
84
+ - No PIN is ever sent: only public card content is read.
85
+
86
+ ## Installation
87
+
88
+ ```bash
89
+ pip install pythonbeid # reading
90
+ pip install "pythonbeid[verify]" # reading + signature verification
91
+ ```
92
+
93
+ Requirements: Python 3.11 or later and a PC/SC reader.
94
+
95
+ - **Windows, macOS**: nothing else to install.
96
+ - **Linux**: the PC/SC daemon must run, and [pyscard](https://pypi.org/project/pyscard/)
97
+ is compiled at install time:
98
+
99
+ ```bash
100
+ sudo apt install pcscd libpcsclite-dev # Debian, Ubuntu, Mint, MX Linux...
101
+ ```
102
+
103
+ ## Reading a card
104
+
105
+ `CardReader()` picks the first reader that holds a Belgian eID card. You can
106
+ also choose the reader and wait for the card to be inserted:
107
+
108
+ ```python
109
+ from pythonbeid import CardReader, list_readers
110
+
111
+ print(list_readers()) # ['ACS ACR38U 0', ...]
112
+
113
+ with CardReader("ACR38U", timeout=30) as reader: # index, name or part of it
114
+ identity = reader.read_identity()
115
+ address = reader.read_address()
116
+ photo = reader.read_photo() # JPEG bytes
117
+ print(reader.card_info.applet_version_string) # "1.7" or "1.8"
118
+ ```
119
+
120
+ `reader.read()` reads everything in a single transaction and returns an
121
+ `EidData` object (`card`, `identity`, `address`, `photo`, raw `files`). Pass
122
+ `photo=False` or `integrity=False` to skip the photo or the files used by the
123
+ verification. All models offer `to_dict()` for JSON serialisation.
124
+
125
+ Reading speed depends on the reader: `read()` takes about 9 s on an old
126
+ 9600-baud ACS ACR38U and proportionally less on faster readers. The photo
127
+ (3 KB) is the largest file; skip it when you do not need it.
128
+
129
+ ### Identity fields
130
+
131
+ | Field | Type | Notes |
132
+ |---|---|---|
133
+ | `card_number`, `chip_number` | `str` | chip number in hexadecimal |
134
+ | `validity_start`, `validity_end` | `date` | `is_valid_on(day)` helper |
135
+ | `issuing_municipality` | `str` | |
136
+ | `national_number` | `str` | `national_number_valid` checks the modulo-97 checksum |
137
+ | `last_name` | `str` | |
138
+ | `first_names` | `str` | the first two given names only |
139
+ | `third_given_name_initial` | `str` | `given_names` joins both |
140
+ | `nationality`, `birth_place` | `str` | in the language of the card |
141
+ | `birth_date` | `PartialDate \| None` | `.to_date()`; year or month may be unknown; `None` for an unknown format (raw value in `raw[0x0C]`) |
142
+ | `sex` | `Sex \| None` | `Sex.MALE` / `Sex.FEMALE` |
143
+ | `noble_condition` | `str` | |
144
+ | `document_type` | `DocumentType \| None` | `.description`, `.is_kids_card`, `.is_foreigner_card` |
145
+ | `special_status` | `SpecialStatus` | `.white_cane`, `.yellow_cane`, `.extended_minority` |
146
+ | `photo_hash`, `basic_key_hash` | `bytes` | used by the verification |
147
+ | foreign nationals | | `duplicate`, `special_organization`, `member_of_family`, `date_and_country_of_protection`, `work_permit`, `employer_vat_1/2`, `regional_file_number`, `brexit_mention_1/2`, `card_a_mention_1/2`, `eu_registration_date` |
148
+ | `raw` | `Mapping[int, bytes]` | every TLV record, for future tags |
149
+
150
+ The address has `street` (street and house number), `postal_code` and
151
+ `municipality`.
152
+
153
+ ## Verifying authenticity
154
+
155
+ Requires the `verify` extra.
156
+
157
+ ```python
158
+ with CardReader() as reader:
159
+ report = reader.verify()
160
+ print(report.is_valid)
161
+ for error in report.errors:
162
+ print(error)
163
+ ```
164
+
165
+ | Check | Meaning |
166
+ |---|---|
167
+ | `photo_hash_valid` | the photo matches the digest in the identity file |
168
+ | `identity_signature_valid` | the identity file is signed by the National Register (RRN) |
169
+ | `address_signature_valid` | the address file is signed by the RRN (and bound to the identity signature) |
170
+ | `rrn_certificate_trusted` | the RRN certificate is an end-entity signing certificate issued by a bundled Belgian root CA |
171
+ | `rrn_certificate_period_valid` | the RRN certificate validity overlaps the card validity |
172
+ | `content_matches_files` | the decoded identity, address and photo are those of the signed files |
173
+ | `basic_key_valid` | applet 1.8: the chip public key is the one signed by the RRN |
174
+ | `chip_authenticated` | applet 1.8: the chip signed a random challenge with its private key |
175
+
176
+ A check that does not apply is `None`. The RRN certificate is not required to
177
+ be valid today: certificates of valid cards may have expired since, and cards
178
+ re-signed after issuance carry a newer one. Whether a card has a basic key is
179
+ decided by the signed identity file, never by the unsigned chip information,
180
+ so a clone cannot avoid the chip challenge by claiming an older applet.
181
+
182
+ Raw files can be checked offline, for instance on a server receiving them
183
+ from a client:
184
+
185
+ ```python
186
+ from pythonbeid import EidData, verify_eid
187
+
188
+ eid = EidData.from_files(files) # {CardFile: bytes}
189
+ report = verify_eid(eid) # everything is checked on the raw files
190
+ ```
191
+
192
+ The chip challenge needs the live card: `reader.authenticate_chip(identity)`
193
+ checks the chip against an identity file whose signature you verified.
194
+
195
+ Bundled trust anchors, downloaded from `certs.eid.belgium.be` and
196
+ `crt.eidpki.belgium.be` (SHA-256):
197
+
198
+ | Root | Fingerprint |
199
+ |---|---|
200
+ | Belgium Root CA2 | `9f9744463be13714754e1a3becf98c08cc205e4ab32028f4e2830c4a1b2775b8` |
201
+ | Belgium Root CA3 | `a8d14e945e3e5156bcae5e39737cf6a1b1f51028bbbf982f50ce5f4c05568b4d` |
202
+ | Belgium Root CA4 | `702dd5c1a093cf0a9d71fadd9bf9a7c5857d89fb73b716e867228b3c2beb968f` |
203
+ | Belgium Root CA6 | `9c872bc979a7c09a58d4a274c199e5cb16cfa9b9618d98bc9a9988e984b8495c` |
204
+
205
+ Pass `trusted_roots=[...]` (PEM or DER) to use your own.
206
+
207
+ ## Command line
208
+
209
+ ```console
210
+ $ pythonbeid readers
211
+ 0: ACS ACR38U 0
212
+ $ pythonbeid info # reader, ATR, applet version
213
+ $ pythonbeid read --json # identity and address
214
+ $ pythonbeid read --photo me.jpg
215
+ $ pythonbeid verify # exit status 3 when a check fails
216
+ ```
217
+
218
+ `python -m pythonbeid` works too. Options: `--reader`, `--timeout`, `--json`,
219
+ `-v` / `-vv` (APDU trace, without card data).
220
+
221
+ ## Errors
222
+
223
+ All exceptions derive from `pythonbeid.BeidError`:
224
+
225
+ | Exception | Raised when |
226
+ |---|---|
227
+ | `NoReaderError` | no reader, or none matches the requested one |
228
+ | `PCSCServiceError` | the PC/SC service is not running (subclass of `NoReaderError`) |
229
+ | `NoCardError` | no card in the reader, or the card was removed |
230
+ | `UnsupportedCardError` | the card is not a Belgian eID card, or lacks a feature |
231
+ | `CardInUseError` | another application holds the card exclusively (subclass of `CardCommunicationError`) |
232
+ | `CardCommunicationError` | transport failure |
233
+ | `APDUError` | the card refused a command (`.sw` holds the status word) |
234
+ | `CardDataError` | card content cannot be decoded (also a `ValueError`) |
235
+
236
+ ## Migrating from 0.x
237
+
238
+ The 0.x API still works and emits a `DeprecationWarning`:
239
+
240
+ | 0.x | 1.0 |
241
+ |---|---|
242
+ | `cr.read_informations(photo=True)` | `reader.read()` returning typed `EidData` |
243
+ | `CardReader(reader_index=1)` | `CardReader(1)` or `CardReader("name")` |
244
+ | `info["birth_date"]` (`datetime`) | `identity.birth_date` (`PartialDate`) |
245
+ | `info["suffix"]` | `identity.third_given_name_initial` |
246
+ | `info["address"]`, `info["city"]` | `address.street`, `address.municipality` |
247
+ | `info["photo"]` (base-64 `str`) | `eid.photo` (`bytes`) |
248
+ | `parse_tlv`, `parse_french_date` | `decode_tlv`, `parse_birth_date` |
249
+
250
+ Behaviour fixes that may be visible: birth dates written in Dutch or German
251
+ are now parsed correctly (0.x silently returned January for most months, and
252
+ failed on German cards); values are stripped of padding spaces; unknown month
253
+ names raise instead of defaulting to January.
254
+
255
+ ## Compatibility
256
+
257
+ - Applet 1.7 cards (RSA keys): validated on real cards.
258
+ - Applet 1.8 cards (elliptic-curve keys, current generation): implemented
259
+ after the official specification and middleware, and covered by simulated
260
+ tests. Reports from 1.8 card holders are welcome (see the issue template;
261
+ never share personal data).
262
+ - Python 3.11 to 3.15 on Windows, macOS and Linux.
263
+
264
+ ## Privacy
265
+
266
+ Card content is personal data (GDPR). pythonbeid never logs it: debug logs
267
+ only contain command headers, status words and lengths. Ask for consent and
268
+ keep only what you need.
269
+
270
+ ## Development
271
+
272
+ ```bash
273
+ git clone https://github.com/Lapin-Blanc/pythonbeid && cd pythonbeid
274
+ python -m venv .venv && . .venv/bin/activate # .venv\Scripts\activate on Windows
275
+ pip install -e ".[dev]" && pre-commit install
276
+ pytest # simulated card, no hardware needed
277
+ pytest --hardware # also runs the tests on a real card (no data is printed)
278
+ ```
279
+
280
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
281
+
282
+ ## References
283
+
284
+ Official documentation, in the
285
+ [Fedict/eid-mw](https://github.com/Fedict/eid-mw/tree/master/doc/sdk/documentation)
286
+ repository:
287
+
288
+ - *ID and Address file contents*, applet 1.8, v5.0 (2023)
289
+ - *Belgian Electronic Identity Card content*, v5.4
290
+ - *Reference manual Belpic V1.8 eID card* and *V1.7*
291
+
292
+ ## License
293
+
294
+ MIT, see [LICENSE](LICENSE).