progressd

This commit is contained in:
EggMan 2024-04-26 21:08:06 -04:00
parent e3e0b3853b
commit 594aaa18d6
3 changed files with 52 additions and 17 deletions

View File

@ -5,7 +5,7 @@
<excludeFolder url="file://$MODULE_DIR$/.venv" /> <excludeFolder url="file://$MODULE_DIR$/.venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" /> <excludeFolder url="file://$MODULE_DIR$/venv" />
</content> </content>
<orderEntry type="jdk" jdkName="Python 3.12 (CNSA-276-FP)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.11 (CNSA-276-FP)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -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.12 (CNSA-276-FP)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CNSA-276-FP)" project-jdk-type="Python SDK" />
</project> </project>

65
tet.py
View File

@ -1,21 +1,56 @@
from fido2.server import Fido2Server from fido2.server import Fido2Server
from fido2.webauthn import PublicKeyCredentialRpEntity from fido2.webauthn import (PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity,
PublicKeyCredentialParameters, PublicKeyCredentialCreationOptions)
rp = PublicKeyCredentialRpEntity("example.com", "Example RP")
server = Fido2Server(rp)
registration_data, state = server.register_begin({
"91974": b"user_id", # user ID as bytes
"Cyrus": "cyrus@eggtech.net",
"displayName": "Admin"
})
from fido2.client import Fido2Client from fido2.client import Fido2Client
from fido2.hid import CtapHidDevice from fido2.hid import CtapHidDevice
import os
# List FIDO devices on the system # Setup the relying party (RP) entity
devices = list(CtapHidDevice.list_devices()) rp = PublicKeyCredentialRpEntity("10.1.1.245", "Example RP")
if not devices:
# Setup the user entity
user = PublicKeyCredentialUserEntity(
id=b'user_id', # User ID as bytes
name="user@example.com",
display_name="User Display Name"
)
# Define the public key credential parameters
cred_params = [
PublicKeyCredentialParameters("public-key", -7), # ES256
PublicKeyCredentialParameters("public-key", -257) # RS256
]
# FIDO2 Server setup
server = Fido2Server(rp)
# Generate a random challenge
challenge = os.urandom(32)
# Manually create the PublicKeyCredentialCreationOptions
options = PublicKeyCredentialCreationOptions(
rp=rp,
user=user,
challenge=challenge,
pub_key_cred_params=cred_params
)
# Start the registration process (adjust this method if needed)
registration_data, state = server.register_begin(
user=user,
challenge=challenge
)
# Assuming the device is the first one connected
device = next(CtapHidDevice.list_devices(), None)
if device is None:
raise ValueError("No FIDO device found") raise ValueError("No FIDO device found")
device = devices[0]
client = Fido2Client(device, "https://example.com") # Client instance for the device
attestation_object, client_data = client.make_credential(registration_data) client = Fido2Client(device, "10.1.1.245")
# Use the manual options we created for make_credential
attestation_object, client_data = client.make_credential(options)
# Finalize the registration to validate the response and store the credentials
auth_data = server.register_complete(state, client_data, attestation_object)