Skip to content

Commit

Permalink
Python < 3.11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Aug 6, 2024
1 parent 334ac5e commit 1677915
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion yubikit/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,17 @@ def from_bytes(cls, value: bytes) -> "Chuid":
data = Tlv.parse_dict(value)
buffer_length = data.get(0xEE)
lrc = data.get(TAG_LRC)
# From Python 3.11: date.fromisoformat(data[0x35])
d = data[0x35]
expiration_date = date(int(d[:4]), int(d[4:6]), int(d[6:8]))
return cls(
buffer_length=bytes2int(buffer_length) if buffer_length else None,
fasc_n=FascN.from_bytes(data[0x30]),
agency_code=data.get(0x31),
organizational_identifier=data.get(0x32),
duns=data.get(0x33),
guid=data[0x34],
expiration_date=date.fromisoformat(data[0x35].decode()),
expiration_date=expiration_date,
authentication_key_map=data.get(0x3D),
asymmetric_signature=data[0x3E],
lrc=lrc[0] if lrc else None,
Expand Down

0 comments on commit 1677915

Please sign in to comment.