Compare commits
10 Commits
7e3b6678d6
...
Alpha
Author | SHA1 | Date | |
---|---|---|---|
5affbb0043 | |||
|
cfb618134e | ||
cfea64d258 | |||
e86a794582 | |||
|
bb9f650edd | ||
|
54eeebdb0f | ||
|
f63cb0f92a | ||
|
165df2de5a | ||
|
40df6174a9 | ||
|
bd6903b7a2 |
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.12 (CNSA-276-FP)" />
|
<option name="sdkName" value="Python 3.12 (CNSA-276-FP)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CNSA-276-FP) (2)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (CNSA-276-FP)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
9
main.py
9
main.py
@@ -33,7 +33,7 @@ On Windows, the native WebAuthn API will be used.
|
|||||||
"""
|
"""
|
||||||
import time
|
import time
|
||||||
import configparser
|
import configparser
|
||||||
gpie = False
|
gpie = True
|
||||||
if gpie:
|
if gpie:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import pickle
|
import pickle
|
||||||
@@ -47,11 +47,12 @@ import sys
|
|||||||
import ctypes
|
import ctypes
|
||||||
from fido2.ctap2 import Ctap2
|
from fido2.ctap2 import Ctap2
|
||||||
from fido2 import cbor
|
from fido2 import cbor
|
||||||
|
# from fido2 import CtapNfcDevice
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
|
|
||||||
config.read('config.ini')
|
config.read('config.ini')
|
||||||
|
# test
|
||||||
dbusername = config.get('Setup', 'dbusername')
|
dbusername = config.get('Setup', 'dbusername')
|
||||||
dbpassword = config.get('Setup', 'dbpassword')
|
dbpassword = config.get('Setup', 'dbpassword')
|
||||||
dbname = config.get('Setup', 'dbname')
|
dbname = config.get('Setup', 'dbname')
|
||||||
@@ -105,7 +106,7 @@ class CliInteraction(UserInteraction):
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
isNfc = False
|
# isNfc = False
|
||||||
if gpie:
|
if gpie:
|
||||||
GPIO.output(door, GPIO.LOW)
|
GPIO.output(door, GPIO.LOW)
|
||||||
|
|
||||||
@@ -326,7 +327,7 @@ while True:
|
|||||||
|
|
||||||
GPIO.output(greenLed, GPIO.HIGH)
|
GPIO.output(greenLed, GPIO.HIGH)
|
||||||
GPIO.output(door, GPIO.HIGH)
|
GPIO.output(door, GPIO.HIGH)
|
||||||
time.sleep(5)
|
time.sleep(3)
|
||||||
GPIO.output(greenLed, GPIO.LOW)
|
GPIO.output(greenLed, GPIO.LOW)
|
||||||
|
|
||||||
|
|
||||||
|
56
test.py
56
test.py
@@ -1,26 +1,38 @@
|
|||||||
import nfc
|
from fido2.pcsc import CtapPcscDevice
|
||||||
import time
|
from fido2.utils import sha256
|
||||||
|
from fido2.ctap1 import Ctap1
|
||||||
|
import sys
|
||||||
|
|
||||||
def connected(tag):
|
|
||||||
print("Tag detected:", tag)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def read_nfc():
|
dev = next(CtapPcscDevice.list_devices(), None)
|
||||||
try:
|
if not dev:
|
||||||
clf = nfc.ContactlessFrontend('usb') # Ensure this matches your connection
|
print("No NFC u2f device found")
|
||||||
print("NFC reader initialized.")
|
sys.exit(1)
|
||||||
except Exception as e:
|
|
||||||
print("Failed to initialize NFC reader:", e)
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
chal = sha256(b"AAA")
|
||||||
while True:
|
appid = sha256(b"BBB")
|
||||||
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()
|
|
||||||
|
|
||||||
read_nfc()
|
ctap1 = Ctap1(dev)
|
||||||
|
|
||||||
|
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")
|
Reference in New Issue
Block a user