Skip to content

Commit

Permalink
update to fido2 0.9.1 & remove solov2
Browse files Browse the repository at this point in the history
  • Loading branch information
conorpp committed Apr 25, 2021
1 parent f78eef6 commit b8be457
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 503 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ venv:
update-venv: venv
venv/bin/pip install -U pip
venv/bin/pip install -U -r dev-requirements.txt
venv/bin/poetry run pip install bincopy
venv/bin/poetry install
venv/bin/flit install --symlink
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

black
flake8
poetry
flit_core==2.3.0
flit==2.3.0
ipython
isort

45 changes: 22 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@

[build-system]
requires = ["flit"]
build-backend = "flit.buildapi"

[tool.poetry]
name = "solo"
version = "0.0.27"
description = ""
authors = ["SoloKeys <hello@solokeys.com>"]
readme = "README.md"
homepage = "https://github.com/solokeys/solo-python"
[tool.flit.metadata]
module = "solo"
dist-name = "solo-python" # Unfortunately, `solo` is in use on PyPI
author = "SoloKeys"
author-email = "hello@solokeys.com"
home-page = "https://github.com/solokeys/solo-python"
requires-python = ">=3.6"
description-file = "README.md"
requires = [
"click >= 7.1",
"cryptography",
"ecdsa",
"fido2 >= 0.9.1",
"intelhex",
"pyserial",
"pyusb",
"requests",
]
classifiers=[
"License :: OSI Approved :: MIT License",
"License :: OSI Approved :: Apache Software License",
Expand All @@ -17,20 +31,5 @@ classifiers=[
"Programming Language :: Python :: 3.7",
]

[tool.poetry.dependencies]
python = ">=3.6.0"
click = '>=7.0'
cryptography= '*'
ecdsa="*"
fido2 =">=0.8.1"
intelhex ="*"
pyserial ="*"
pyusb ="*"
requests ="*"
pyscard="*"
mboot2 = ">=0.3.5"



[tool.poetry.scripts]
[tool.flit.scripts]
solo = "solo.cli:solo_cli"
2 changes: 1 addition & 1 deletion solo/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.26
0.0.27
10 changes: 6 additions & 4 deletions solo/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from solo.cli.monitor import monitor
from solo.cli.program import program

from . import _patches # noqa (since otherwise "unused")
from ._checks import init_checks

init_checks()
Expand Down Expand Up @@ -137,10 +136,13 @@ def ls(all):
print(":: Solos")
for c in solos:
descriptor = c.dev.descriptor
if "serial_number" in descriptor:
print(f"{descriptor['serial_number']}: {descriptor['product_string']}")
if hasattr(descriptor, "serial_number") and descriptor.serial_number:
print(f"{descriptor.serial_number}: {descriptor.product_string}")
else:
print(f"{descriptor['path']}: {descriptor['product_string']}")
if c.is_solo_bootloader():
print(f"{descriptor.path}: Solo Bootloader device")
else:
print(f"{descriptor.path}: FIDO2 device")

if all:
print(":: Potential Solos in DFU mode")
Expand Down
123 changes: 0 additions & 123 deletions solo/cli/_patches.py

This file was deleted.

2 changes: 1 addition & 1 deletion solo/cli/key.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def feedkernel(count, serial):

p = solo.client.find(serial)

import struct
import fcntl
import struct

RNDADDENTROPY = 0x40085203

Expand Down
2 changes: 1 addition & 1 deletion solo/cli/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def dfu(serial, connect_attempts, detach, dry_run, firmware):

import time

from intelhex import IntelHex
import usb.core
from intelhex import IntelHex

dfu = solo.dfu.find(serial, attempts=connect_attempts)

Expand Down
23 changes: 6 additions & 17 deletions solo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,16 @@

import solo.exceptions

from .devices import solo_v1, solo_v2
from .devices import solo_v1


def find(solo_serial=None, retries=5, raw_device=None, udp=False):

if udp:
solo.fido2.force_udp_backend()
print("UDP is not supported in latest version of solo-python.")
print("Please install version solo-python==0.0.12 and fido2==8.1 to do that.")

# First try looking for V2 device.
p = solo_v2.Client()
for i in range(retries):
try:
p.find_device(dev=raw_device, solo_serial=solo_serial)
print("Got a V2 device")
return p
except RuntimeError:
time.sleep(0.2)

# Then try looking for V1 device.
# Try looking for V1 device.
p = solo_v1.Client()

# This... is not the right way to do it yet
Expand All @@ -40,8 +31,6 @@ def find(solo_serial=None, retries=5, raw_device=None, udp=False):
for i in range(retries):
try:
p.find_device(dev=raw_device, solo_serial=solo_serial)
print("Got a V1 device")
print(p.dev)
return p
except RuntimeError:
time.sleep(0.2)
Expand All @@ -57,8 +46,8 @@ def find_all():
for d in hid_devices
if all(
(
d.descriptor["vendor_id"] == 1155,
d.descriptor["product_id"] == 41674,
d.descriptor.vid == 1155,
d.descriptor.pid == 41674,
# "Solo" in d.descriptor["product_string"],
)
)
Expand Down
24 changes: 13 additions & 11 deletions solo/devices/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(
self.do_reboot = True

def set_reboot(self, val):
""" option to reboot after programming """
"""option to reboot after programming"""
self.do_reboot = val

def reboot(
Expand All @@ -37,13 +37,13 @@ def find_device(self, dev=None, solo_serial=None):
def get_current_hid_device(
self,
):
""" Return current device class for CTAPHID interface if available. """
"""Return current device class for CTAPHID interface if available."""
pass

def get_current_fido_client(
self,
):
""" Return current fido2 client if available. """
"""Return current fido2 client if available."""
pass

def send_data_hid(self, cmd, data):
Expand Down Expand Up @@ -80,11 +80,11 @@ def reset(

def change_pin(self, old_pin, new_pin):
client = self.get_current_fido_client()
client.pin_protocol.change_pin(old_pin, new_pin)
client.client_pin.change_pin(old_pin, new_pin)

def set_pin(self, new_pin):
client = self.get_current_fido_client()
client.pin_protocol.set_pin(new_pin)
client.client_pin.set_pin(new_pin)

def make_credential(self, pin=None):
client = self.get_current_fido_client()
Expand All @@ -97,7 +97,9 @@ def make_credential(self, pin=None):
challenge,
[{"type": "public-key", "alg": -8}, {"type": "public-key", "alg": -7}],
)
attest, data = client.make_credential(options, pin=pin)
result = client.make_credential(options, pin=pin)
attest = result.attestation_object
data = result.client_data
try:
attest.verify(data.hash)
except AttributeError:
Expand All @@ -110,10 +112,10 @@ def make_credential(self, pin=None):
return cert

def cred_mgmt(self, pin):
token = self.pin_protocol.get_pin_token(pin)
pin_protocol = 1
client = self.get_current_fido_client()
token = client.client_pin.get_pin_token(pin)
ctap2 = CTAP2(self.get_current_hid_device())
return CredentialManagement(ctap2, pin_protocol, token)
return CredentialManagement(ctap2, client.client_pin.protocol, token)

def enter_solo_bootloader(
self,
Expand All @@ -131,7 +133,7 @@ def enter_bootloader_or_die(self):
def is_solo_bootloader(
self,
):
""" For now, solo bootloader could be the NXP bootrom on Solo v2. """
"""For now, solo bootloader could be the NXP bootrom on Solo v2."""
pass

def program_kbd(self, cmd):
Expand All @@ -142,7 +144,7 @@ def sign_hash(self, credential_id, dgst, pin):
ctap2 = CTAP2(self.get_current_hid_device())
client = self.get_current_fido_client()
if pin:
pin_token = client.pin_protocol.get_pin_token(pin)
pin_token = client.client_pin.get_pin_token(pin)
pin_auth = hmac_sha256(pin_token, dgst)[:16]
return ctap2.send_cbor(
0x50,
Expand Down
Loading

0 comments on commit b8be457

Please sign in to comment.