Skip to content

Commit

Permalink
Support "64" as an ATR baud rate adjustment integer
Browse files Browse the repository at this point in the history
Closes #214

Changed
-------

* Support "64" as an ATR baud rate adjustment integer (ISO 7816-3 2006).

Removed
-------

* Remove a trailing `"RFU"` value in the ATR clock rate mapping.

  Clock rates are mapped using only 4 bits,
  meaning there are only 16 possible values.
  The trailing `"RFU"` value was the 17th value in the list.

Added
-----

* Add a single test that trivially checks the ATR mapping lengths.
  • Loading branch information
kurtmckee committed Oct 17, 2024
1 parent 927d79f commit 362afdf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit 362afdf

Please sign in to comment.