feat(pm3py): HF core + ISO14443A commands

This commit is contained in:
michael
2026-03-15 22:16:54 -07:00
parent 95133843a4
commit 2f88fabde6
5 changed files with 213 additions and 0 deletions

13
tests/test_hf.py Normal file
View File

@@ -0,0 +1,13 @@
import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.hf import HFCommands
def test_hf_tune():
t = AsyncMock()
hf = HFCommands(t)
t.send_ng.return_value = PM3Response(cmd=Cmd.MEASURE_ANTENNA_TUNING_HF, status=0,
reason=0, ng=True, data=b"\x00" * 4)
result = asyncio.get_event_loop().run_until_complete(hf.tune())
assert "voltage_mV" in result

25
tests/test_hf_14a.py Normal file
View File

@@ -0,0 +1,25 @@
import struct
import asyncio
from unittest.mock import AsyncMock
from pm3py.protocol import Cmd
from pm3py.transport import PM3Response
from pm3py.hf_14a import HF14ACommands
def test_14a_scan():
t = AsyncMock()
hf14a = HF14ACommands(t)
# Build iso14a_card_select_t response
uid = b"\x04\x01\x02\x03\x04\x05\x06"
card = uid + b"\x00" * 3 # uid[10]
card += bytes([7]) # uidlen
card += b"\x44\x00" # atqa
card += bytes([0x08]) # sak
card += bytes([0]) # ats_len
card += b"\x00" * 256 # ats
resp = PM3Response(cmd=Cmd.ACK, status=0, reason=0, ng=False,
data=card, oldarg=[1, 0, 0])
t.send_mix.return_value = resp
result = asyncio.get_event_loop().run_until_complete(hf14a.scan())
assert result["uid"] == "04010203040506"
assert result["uid_len"] == 7
assert result["sak"] == 0x08