Compare commits

..

No commits in common. "40df6174a90972266e0b115a5ee13d6ad407860d" and "7e3b6678d609ea2e027230197a2eaf84226b9c3f" have entirely different histories.

56
test.py
View File

@ -1,38 +1,26 @@
from fido2.pcsc import CtapPcscDevice import nfc
from fido2.utils import sha256 import time
from fido2.ctap1 import Ctap1
import sys
def connected(tag):
print("Tag detected:", tag)
return True
dev = next(CtapPcscDevice.list_devices(), None) def read_nfc():
if not dev: try:
print("No NFC u2f device found") clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection
sys.exit(1) print("NFC reader initialized.")
except Exception as e:
print("Failed to initialize NFC reader:", e)
return
chal = sha256(b"AAA") try:
appid = sha256(b"BBB") while True:
print("Waiting for NFC tag...")
clf.connect(rdwr={'on-connect': connected})
time.sleep(1)
except Exception as e:
print("Error reading NFC tag:", e)
finally:
clf.close()
ctap1 = Ctap1(dev) read_nfc()
print("version:", ctap1.get_version())
# True - make extended APDU and send it to key
# ISO 7816-3:2006. page 33, 12.1.3 Decoding conventions for command APDUs
# ISO 7816-3:2006. page 34, 12.2 Command-response pair transmission by T=0
# False - make group of short (less than 255 bytes length) APDU
# and send them to key. ISO 7816-3:2005, page 9, 5.1.1.1 Command chaining
dev.use_ext_apdu = False
reg = ctap1.register(chal, appid)
print("register:", reg)
reg.verify(appid, chal)
print("Register message verify OK")
auth = ctap1.authenticate(chal, appid, reg.key_handle)
print("authenticate result: ", auth)
res = auth.verify(appid, chal, reg.public_key)
print("Authenticate message verify OK")