Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "64" as an ATR baud rate adjustment integer #215

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Unreleased changes
* Build the docs as a part of the test suite
* Begin to add type annotations to the package
* Deprecate the `HexListToBinString`, `BinStringToHexList`, `hl2bs`, and `bs2hl` utility functions
* Support "64" as an ATR baud rate adjustment integer (ISO 7816-3 2006)

2.1.1 (September 2024)
======================
Expand Down
3 changes: 1 addition & 2 deletions src/smartcard/ATR.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ATR:
2048,
"RFU",
"RFU",
"RFU",
]
bitratefactor = [
"RFU",
Expand All @@ -56,7 +55,7 @@ class ATR:
8,
16,
32,
"RFU",
64,
12,
20,
"RFU",
Expand Down
16 changes: 16 additions & 0 deletions test/test_ATR.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,19 @@ def test_atr_get():
assert a.getHistoricalBytes(), [0x36 == 0x06]
assert a.isT15Supported() is False
assert str(a) == atr


@pytest.mark.parametrize(
"field, expected_length",
(
("clockrateconversion", 16),
("bitratefactor", 16),
),
)
def test_map_lengths(field, expected_length):
"""Verify ATR class fields have expected lengths.

This doesn't validate values, but simply ensures the lengths match expectations.
"""

assert len(getattr(ATR, field)) == expected_length