pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/security/py-fido2



Module Name:    pkgsrc
Committed By:   wiz
Date:           Sun Mar 12 14:01:04 UTC 2023

Modified Files:
        pkgsrc/security/py-fido2: Makefile PLIST distinfo
Added Files:
        pkgsrc/security/py-fido2/patches: patch-fido2_hid_____init____.py
            patch-fido2_hid_netbsd.py
Removed Files:
        pkgsrc/security/py-fido2/patches: patch-fido2___pyu2f_____init____.py
            patch-fido2___pyu2f_netbsd.py

Log Message:
py-fido2: update to 1.1.0.

NetBSD support by riastradh@, thanks!

Version 1.1.0 (released 2022-10-17)

    Bugfix: Fix name of "crossOrigin" in CollectedClientData.create().
    Bugfix: Some incorrect type hints in the MDS3 classes were fixed.
    Stricter checking of dataclass field types.
    Add support for JSON-serialization of WebAuthn data classes.
    This changes the objects dict representation to align with new additions in the
    WebAuthn specification. As this may break compatibility, the new behavior
    requires explicit opt-in until python-fido2 2.0 is released.
    Update server example to use JSON serialization.
    Server: Add support for passing RegistrationResponse/AuthenticationResponse (or
    their deserialized JSON data) to register_complete/authenticate_complete.
    Add new "hybrid" AuthenticatorTransport.
    Add new AuthenticatorData flags, and use 2-letter names as in the WebAuthn spec
    (long names are still available as aliases).

Version 1.0.0 (released 2022-06-08)

    First stable release.

Version 1.0.0rc1 (released 2022-05-02)

    Release Candidate 1 of first stable release.
    Require Python 3.7 or later.
    APIs have updated to align with WebAuthn level 2.
    Several CTAP 2.1 features have been implemented.

Version 0.9.3 (released 2021-11-09)

    Bugfix: Linux - Don't fail device discovery when hidraw doesn't support HIDIOCGRAWUNIQ (Linux kernels before 5.6).

Version 0.9.2 (released 2021-10-14)

    Support the latest Windows webauthn.h API (included in Windows 11).
    Add product name and serial number to HidDescriptors.
    Remove the need for the uhid-freebsd dependency on FreeBSD.

Version 0.9.1 (released 2021-02-03)

    Add new CTAP error codes and improve handling of unknown codes.

Version 0.9.0 (released 2021-01-20)

WARNING: Backwards-incompatible changes!

    Server: Attestation is now done in two parts (to align better with the spec):
    First, type-specific validation is done to provide a trust chain.
    Second, validation of the trust chain is done.
    Client: API changes to better support extensions.
        Fido2Client can be configured with Ctap2Extensions to support.
        Client.make_credential now returns a AuthenticatorAttestationResponse,
        which holds the AttestationObject and ClientData, as well as any client
        extension results for the credential.
        Client.get_assertion now returns an AssertionSelection object, which is
        used to select between multiple assertions, resulting in an
        AuthenticatorAssertionResponse, which holds the ClientData, assertion
        values, as well as any client extension results for the assertion.
    Renames: The CTAP1 and CTAP2 classes have been renamed to Ctap1 and Ctap2,
    respectively. The old names currently work, but will be removed in the
    future.
    ClientPin: The ClientPin API has been restructured to support multiple PIN
    protocols, UV tokens, and token permissions.
    CTAP 2.1 PRE: Several new features have been added for CTAP 2.1, including
    Credential Management, Bio Enrollment, Large Blobs, and Authenticator Config.
    HID: The platform specific HID code has been revamped and cleaned up.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 pkgsrc/security/py-fido2/Makefile \
    pkgsrc/security/py-fido2/distinfo
cvs rdiff -u -r1.1 -r1.2 pkgsrc/security/py-fido2/PLIST
cvs rdiff -u -r1.1 -r0 \
    pkgsrc/security/py-fido2/patches/patch-fido2___pyu2f_____init____.py
cvs rdiff -u -r1.2 -r0 \
    pkgsrc/security/py-fido2/patches/patch-fido2___pyu2f_netbsd.py
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/security/py-fido2/patches/patch-fido2_hid_____init____.py \
    pkgsrc/security/py-fido2/patches/patch-fido2_hid_netbsd.py

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/security/py-fido2/Makefile
diff -u pkgsrc/security/py-fido2/Makefile:1.4 pkgsrc/security/py-fido2/Makefile:1.5
--- pkgsrc/security/py-fido2/Makefile:1.4       Thu Apr 21 11:00:01 2022
+++ pkgsrc/security/py-fido2/Makefile   Sun Mar 12 14:01:04 2023
@@ -1,8 +1,7 @@
-#      $NetBSD: Makefile,v 1.4 2022/04/21 11:00:01 wiz Exp $
+#      $NetBSD: Makefile,v 1.5 2023/03/12 14:01:04 wiz Exp $
 
-DISTNAME=      fido2-0.8.1
+DISTNAME=      fido2-1.1.0
 PKGNAME=       ${PYPKGPREFIX}-${DISTNAME}
-PKGREVISION=   2
 CATEGORIES=    security
 MASTER_SITES=  ${MASTER_SITE_GITHUB:=Yubico/}
 GITHUB_PROJECT=        python-fido2
@@ -13,10 +12,18 @@ HOMEPAGE=   https://developers.yubico.com/
 COMMENT=       Yubico FIDO U2F and FIDO 2.0 USB Python library
 LICENSE=       2-clause-bsd AND apache-2.0 AND mpl-2.0
 
-DEPENDS+=      ${PYPKGPREFIX}-six>=0:../../lang/py-six
+DEPENDS+=      ${PYPKGPREFIX}-scard>=0:../../devel/py-scard
+DEPENDS+=      ${PYPKGPREFIX}-cryptography>=0:../../security/py-cryptography
+TEST_DEPENDS+= ${PYPKGPREFIX}-test>=2:../../devel/py-test
+TOOL_DEPENDS+= ${PYPKGPREFIX}-poetry-core>=1:../../devel/py-poetry-core
 
-PYTHON_VERSIONED_DEPENDENCIES+=        cryptography
+PYTHON_VERSIONS_INCOMPATIBLE=  27
 
-.include "../../lang/python/egg.mk"
-.include "../../lang/python/versioned_dependencies.mk"
+post-install:
+       ${RM} -f ${DESTDIR}${PREFIX}/${PYSITELIB}/fido2/hid/*.orig
+
+do-test:
+       cd ${WRKSRC} && ${SETENV} ${TEST_ENV} pytest-${PYVERSSUFFIX}
+
+.include "../../lang/python/wheel.mk"
 .include "../../mk/bsd.pkg.mk"
Index: pkgsrc/security/py-fido2/distinfo
diff -u pkgsrc/security/py-fido2/distinfo:1.4 pkgsrc/security/py-fido2/distinfo:1.5
--- pkgsrc/security/py-fido2/distinfo:1.4       Tue Oct 26 11:17:45 2021
+++ pkgsrc/security/py-fido2/distinfo   Sun Mar 12 14:01:04 2023
@@ -1,7 +1,7 @@
-$NetBSD: distinfo,v 1.4 2021/10/26 11:17:45 nia Exp $
+$NetBSD: distinfo,v 1.5 2023/03/12 14:01:04 wiz Exp $
 
-BLAKE2s (fido2-0.8.1.tar.gz) = a6faecdd174133b2f73d5e4e5567fe8d2e08355ec63d5cf57cd189e5f0ffadea
-SHA512 (fido2-0.8.1.tar.gz) = 510c4fa11ff4f431d88171156fbbaf4326c7b7a24586eb1c566e075bb673adf542d07c7b1e2163fb3972d59799ca7d4ddc22f3e79a8f05e2ea1f8bcfe63cc5bc
-Size (fido2-0.8.1.tar.gz) = 208300 bytes
-SHA1 (patch-fido2___pyu2f_____init____.py) = 1a42c219a20a1b98f78c9ca73d419f782d77ff8a
-SHA1 (patch-fido2___pyu2f_netbsd.py) = b7d7a2158dac1d3ae126f542a63a61372f031e31
+BLAKE2s (fido2-1.1.0.tar.gz) = 92d590ca5ca32758eb40559447844a9eb53c1b22603cc91d5abddb940bfceb5a
+SHA512 (fido2-1.1.0.tar.gz) = 28446710cd2bf1d82ecc52a779cb535943c9ddf020958c6549167091cd8da72f8cd1ab2fd3a0aee0a6f34d61059bcd72ecc2f4504c9086b5c5815b63faaf5d17
+Size (fido2-1.1.0.tar.gz) = 243692 bytes
+SHA1 (patch-fido2_hid_____init____.py) = cdc96645c972d5b7ad14b2fbc3b13ad607b6d1ca
+SHA1 (patch-fido2_hid_netbsd.py) = 330afb08ed955ddd739594a23155280d7967f59b

Index: pkgsrc/security/py-fido2/PLIST
diff -u pkgsrc/security/py-fido2/PLIST:1.1 pkgsrc/security/py-fido2/PLIST:1.2
--- pkgsrc/security/py-fido2/PLIST:1.1  Mon Aug 17 07:01:33 2020
+++ pkgsrc/security/py-fido2/PLIST      Sun Mar 12 14:01:04 2023
@@ -1,85 +1,86 @@
-@comment $NetBSD: PLIST,v 1.1 2020/08/17 07:01:33 riastradh Exp $
-${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
-${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
-${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
-${PYSITELIB}/${EGG_INFODIR}/requires.txt
-${PYSITELIB}/${EGG_INFODIR}/top_level.txt
+@comment $NetBSD: PLIST,v 1.2 2023/03/12 14:01:04 wiz Exp $
+${PYSITELIB}/${WHEEL_INFODIR}/COPYING
+${PYSITELIB}/${WHEEL_INFODIR}/COPYING.APLv2
+${PYSITELIB}/${WHEEL_INFODIR}/COPYING.MPLv2
+${PYSITELIB}/${WHEEL_INFODIR}/INSTALLER
+${PYSITELIB}/${WHEEL_INFODIR}/METADATA
+${PYSITELIB}/${WHEEL_INFODIR}/RECORD
+${PYSITELIB}/${WHEEL_INFODIR}/REQUESTED
+${PYSITELIB}/${WHEEL_INFODIR}/WHEEL
+${PYSITELIB}/${WHEEL_INFODIR}/direct_url.json
 ${PYSITELIB}/fido2/__init__.py
 ${PYSITELIB}/fido2/__init__.pyc
-${PYSITELIB}/fido2/__init__.pyo
-${PYSITELIB}/fido2/_pyu2f/__init__.py
-${PYSITELIB}/fido2/_pyu2f/__init__.pyc
-${PYSITELIB}/fido2/_pyu2f/__init__.pyo
-${PYSITELIB}/fido2/_pyu2f/base.py
-${PYSITELIB}/fido2/_pyu2f/base.pyc
-${PYSITELIB}/fido2/_pyu2f/base.pyo
-${PYSITELIB}/fido2/_pyu2f/freebsd.py
-${PYSITELIB}/fido2/_pyu2f/freebsd.pyc
-${PYSITELIB}/fido2/_pyu2f/freebsd.pyo
-${PYSITELIB}/fido2/_pyu2f/hidtransport.py
-${PYSITELIB}/fido2/_pyu2f/hidtransport.pyc
-${PYSITELIB}/fido2/_pyu2f/hidtransport.pyo
-${PYSITELIB}/fido2/_pyu2f/linux.py
-${PYSITELIB}/fido2/_pyu2f/linux.pyc
-${PYSITELIB}/fido2/_pyu2f/linux.pyo
-${PYSITELIB}/fido2/_pyu2f/macos.py
-${PYSITELIB}/fido2/_pyu2f/macos.pyc
-${PYSITELIB}/fido2/_pyu2f/macos.pyo
-${PYSITELIB}/fido2/_pyu2f/netbsd.py
-${PYSITELIB}/fido2/_pyu2f/netbsd.pyc
-${PYSITELIB}/fido2/_pyu2f/netbsd.pyo
-${PYSITELIB}/fido2/_pyu2f/windows.py
-${PYSITELIB}/fido2/_pyu2f/windows.pyc
-${PYSITELIB}/fido2/_pyu2f/windows.pyo
-${PYSITELIB}/fido2/_tpm.py
-${PYSITELIB}/fido2/_tpm.pyc
-${PYSITELIB}/fido2/_tpm.pyo
-${PYSITELIB}/fido2/attestation.py
-${PYSITELIB}/fido2/attestation.pyc
-${PYSITELIB}/fido2/attestation.pyo
+${PYSITELIB}/fido2/attestation/__init__.py
+${PYSITELIB}/fido2/attestation/__init__.pyc
+${PYSITELIB}/fido2/attestation/android.py
+${PYSITELIB}/fido2/attestation/android.pyc
+${PYSITELIB}/fido2/attestation/apple.py
+${PYSITELIB}/fido2/attestation/apple.pyc
+${PYSITELIB}/fido2/attestation/base.py
+${PYSITELIB}/fido2/attestation/base.pyc
+${PYSITELIB}/fido2/attestation/packed.py
+${PYSITELIB}/fido2/attestation/packed.pyc
+${PYSITELIB}/fido2/attestation/tpm.py
+${PYSITELIB}/fido2/attestation/tpm.pyc
+${PYSITELIB}/fido2/attestation/u2f.py
+${PYSITELIB}/fido2/attestation/u2f.pyc
 ${PYSITELIB}/fido2/cbor.py
 ${PYSITELIB}/fido2/cbor.pyc
-${PYSITELIB}/fido2/cbor.pyo
 ${PYSITELIB}/fido2/client.py
 ${PYSITELIB}/fido2/client.pyc
-${PYSITELIB}/fido2/client.pyo
 ${PYSITELIB}/fido2/cose.py
 ${PYSITELIB}/fido2/cose.pyc
-${PYSITELIB}/fido2/cose.pyo
 ${PYSITELIB}/fido2/ctap.py
 ${PYSITELIB}/fido2/ctap.pyc
-${PYSITELIB}/fido2/ctap.pyo
 ${PYSITELIB}/fido2/ctap1.py
 ${PYSITELIB}/fido2/ctap1.pyc
-${PYSITELIB}/fido2/ctap1.pyo
-${PYSITELIB}/fido2/ctap2.py
-${PYSITELIB}/fido2/ctap2.pyc
-${PYSITELIB}/fido2/ctap2.pyo
-${PYSITELIB}/fido2/extensions.py
-${PYSITELIB}/fido2/extensions.pyc
-${PYSITELIB}/fido2/extensions.pyo
-${PYSITELIB}/fido2/hid.py
-${PYSITELIB}/fido2/hid.pyc
-${PYSITELIB}/fido2/hid.pyo
-${PYSITELIB}/fido2/nfc.py
-${PYSITELIB}/fido2/nfc.pyc
-${PYSITELIB}/fido2/nfc.pyo
+${PYSITELIB}/fido2/ctap2/__init__.py
+${PYSITELIB}/fido2/ctap2/__init__.pyc
+${PYSITELIB}/fido2/ctap2/base.py
+${PYSITELIB}/fido2/ctap2/base.pyc
+${PYSITELIB}/fido2/ctap2/bio.py
+${PYSITELIB}/fido2/ctap2/bio.pyc
+${PYSITELIB}/fido2/ctap2/blob.py
+${PYSITELIB}/fido2/ctap2/blob.pyc
+${PYSITELIB}/fido2/ctap2/config.py
+${PYSITELIB}/fido2/ctap2/config.pyc
+${PYSITELIB}/fido2/ctap2/credman.py
+${PYSITELIB}/fido2/ctap2/credman.pyc
+${PYSITELIB}/fido2/ctap2/extensions.py
+${PYSITELIB}/fido2/ctap2/extensions.pyc
+${PYSITELIB}/fido2/ctap2/pin.py
+${PYSITELIB}/fido2/ctap2/pin.pyc
+${PYSITELIB}/fido2/features.py
+${PYSITELIB}/fido2/features.pyc
+${PYSITELIB}/fido2/hid/__init__.py
+${PYSITELIB}/fido2/hid/__init__.pyc
+${PYSITELIB}/fido2/hid/base.py
+${PYSITELIB}/fido2/hid/base.pyc
+${PYSITELIB}/fido2/hid/freebsd.py
+${PYSITELIB}/fido2/hid/freebsd.pyc
+${PYSITELIB}/fido2/hid/linux.py
+${PYSITELIB}/fido2/hid/linux.pyc
+${PYSITELIB}/fido2/hid/macos.py
+${PYSITELIB}/fido2/hid/macos.pyc
+${PYSITELIB}/fido2/hid/netbsd.py
+${PYSITELIB}/fido2/hid/netbsd.pyc
+${PYSITELIB}/fido2/hid/openbsd.py
+${PYSITELIB}/fido2/hid/openbsd.pyc
+${PYSITELIB}/fido2/hid/windows.py
+${PYSITELIB}/fido2/hid/windows.pyc
+${PYSITELIB}/fido2/mds3.py
+${PYSITELIB}/fido2/mds3.pyc
 ${PYSITELIB}/fido2/pcsc.py
 ${PYSITELIB}/fido2/pcsc.pyc
-${PYSITELIB}/fido2/pcsc.pyo
 ${PYSITELIB}/fido2/public_suffix_list.dat
+${PYSITELIB}/fido2/py.typed
 ${PYSITELIB}/fido2/rpid.py
 ${PYSITELIB}/fido2/rpid.pyc
-${PYSITELIB}/fido2/rpid.pyo
 ${PYSITELIB}/fido2/server.py
 ${PYSITELIB}/fido2/server.pyc
-${PYSITELIB}/fido2/server.pyo
 ${PYSITELIB}/fido2/utils.py
 ${PYSITELIB}/fido2/utils.pyc
-${PYSITELIB}/fido2/utils.pyo
 ${PYSITELIB}/fido2/webauthn.py
 ${PYSITELIB}/fido2/webauthn.pyc
-${PYSITELIB}/fido2/webauthn.pyo
 ${PYSITELIB}/fido2/win_api.py
 ${PYSITELIB}/fido2/win_api.pyc
-${PYSITELIB}/fido2/win_api.pyo

Added files:

Index: pkgsrc/security/py-fido2/patches/patch-fido2_hid_____init____.py
diff -u /dev/null pkgsrc/security/py-fido2/patches/patch-fido2_hid_____init____.py:1.1
--- /dev/null   Sun Mar 12 14:01:04 2023
+++ pkgsrc/security/py-fido2/patches/patch-fido2_hid_____init____.py    Sun Mar 12 14:01:04 2023
@@ -0,0 +1,16 @@
+$NetBSD: patch-fido2_hid_____init____.py,v 1.1 2023/03/12 14:01:04 wiz Exp $
+
+Add NetBSD support.
+https://github.com/Yubico/python-fido2/pull/174
+
+--- fido2/hid/__init__.py.orig 2022-10-17 13:36:35.000000000 +0000
++++ fido2/hid/__init__.py
+@@ -49,6 +49,8 @@ elif sys.platform.startswith("darwin"):
+     from . import macos as backend
+ elif sys.platform.startswith("freebsd"):
+     from . import freebsd as backend
++elif sys.platform.startswith('netbsd'):
++    from . import netbsd as backend
+ elif sys.platform.startswith("openbsd"):
+     from . import openbsd as backend
+ else:
Index: pkgsrc/security/py-fido2/patches/patch-fido2_hid_netbsd.py
diff -u /dev/null pkgsrc/security/py-fido2/patches/patch-fido2_hid_netbsd.py:1.1
--- /dev/null   Sun Mar 12 14:01:04 2023
+++ pkgsrc/security/py-fido2/patches/patch-fido2_hid_netbsd.py  Sun Mar 12 14:01:04 2023
@@ -0,0 +1,178 @@
+$NetBSD: patch-fido2_hid_netbsd.py,v 1.1 2023/03/12 14:01:04 wiz Exp $
+
+Add NetBSD support.
+https://github.com/Yubico/python-fido2/pull/174
+
+--- fido2/hid/netbsd.py.orig   2023-03-11 13:39:42.733028371 +0000
++++ fido2/hid/netbsd.py
+@@ -0,0 +1,170 @@
++# Copyright 2016 Google Inc. All Rights Reserved.
++#
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++#    http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
++
++"""Implements raw HID interface on NetBSD."""
++
++from __future__ import absolute_import
++
++import errno
++import logging
++import os
++import select
++import struct
++
++from ctypes import Structure
++from ctypes import c_char
++from ctypes import c_int
++from ctypes import c_ubyte
++from ctypes import c_uint16
++from ctypes import c_uint32
++from ctypes import c_uint8
++from ctypes import sizeof
++from fcntl import ioctl
++from typing import Set
++
++from . import base
++
++
++logger = logging.getLogger(__name__)
++
++
++USB_MAX_DEVNAMELEN = 16
++USB_MAX_DEVNAMES = 4
++USB_MAX_STRING_LEN = 128
++USB_MAX_ENCODED_STRING_LEN = USB_MAX_STRING_LEN * 3
++
++
++class usb_ctl_report_desc(Structure):
++    _fields_ = [
++        ('ucrd_size', c_int),
++        ('ucrd_data', c_ubyte * 1024),
++    ]
++
++
++class usb_device_info(Structure):
++    _fields_ = [
++        ('udi_bus', c_uint8),
++        ('udi_addr', c_uint8),
++        ('udi_pad0', c_uint8 * 2),
++        ('udi_cookie', c_uint32),
++        ('udi_product', c_char * USB_MAX_ENCODED_STRING_LEN),
++        ('udi_vendor', c_char * USB_MAX_ENCODED_STRING_LEN),
++        ('udi_release', c_char * 8),
++        ('udi_serial', c_char * USB_MAX_ENCODED_STRING_LEN),
++        ('udi_productNo', c_uint16),
++        ('udi_vendorNo', c_uint16),
++        ('udi_releaseNo', c_uint16),
++        ('udi_class', c_uint8),
++        ('udi_subclass', c_uint8),
++        ('udi_protocol', c_uint8),
++        ('udi_config', c_uint8),
++        ('udi_speed', c_uint8),
++        ('udi_pad1', c_uint8),
++        ('udi_power', c_int),
++        ('udi_nports', c_int),
++        ('udi_devnames', c_char * USB_MAX_DEVNAMES * USB_MAX_DEVNAMELEN),
++        ('udi_ports', c_uint8 * 16),
++    ]
++
++
++USB_GET_DEVICE_INFO = 0x44f45570  # _IOR('U', 112, struct usb_device_info)
++USB_GET_REPORT_DESC = 0x44045515  # _IOR('U', 21, struct usb_ctl_report_desc)
++USB_HID_SET_RAW = 0x80046802      # _IOW('h', 2, int)
++
++
++# Cache for continuously failing devices
++# XXX not thread-safe
++_failed_cache: Set[str] = set()
++
++
++def list_descriptors():
++    stale = set(_failed_cache)
++    descriptors = []
++
++    for i in range(100):
++        path = '/dev/uhid%d' % (i,)
++        stale.discard(path)
++        try:
++            desc = get_descriptor(path)
++        except OSError as e:
++            if e.errno == errno.ENOENT:
++                break
++            if path not in _failed_cache:
++                logger.debug("Failed opening FIDO device %s", path,
++                    exc_info=True)
++                _failed_cache.add(path)
++            continue
++        except Exception:
++            if path not in _failed_cache:
++                logger.debug("Failed opening FIDO device %s", path,
++                    exc_info=True)
++                _failed_cache.add(path)
++            continue
++        descriptors.append(desc)
++
++    _failed_cache.difference_update(stale)
++    return descriptors
++
++
++def get_descriptor(path):
++    fd = None
++    try:
++        fd = os.open(path, os.O_RDONLY|os.O_CLOEXEC)
++        devinfo = usb_device_info()
++        ioctl(fd, USB_GET_DEVICE_INFO, devinfo)
++        ucrd = usb_ctl_report_desc()
++        ioctl(fd, USB_GET_REPORT_DESC, ucrd)
++        report_desc = bytearray(ucrd.ucrd_data[:ucrd.ucrd_size])
++        maxin, maxout = base.parse_report_descriptor(report_desc)
++        vid = devinfo.udi_vendorNo
++        pid = devinfo.udi_productNo
++        try:
++            name = devinfo.udi_product.decode('utf-8')
++        except UnicodeDecodeError:
++            name = None
++        try:
++            serial = devinfo.udi_serial.decode('utf-8')
++        except UnicodeDecodeError:
++            serial = None
++        return base.HidDescriptor(path, vid, pid, maxin, maxout, name, serial)
++    finally:
++        if fd is not None:
++            os.close(fd)
++
++
++def open_connection(descriptor):
++    return NetBSDCtapHidConnection(descriptor);
++
++
++class NetBSDCtapHidConnection(base.FileCtapHidConnection):
++    def __init__(self, descriptor):
++        # XXX racy -- device can change identity now that it has been
++        # closed
++        super().__init__(descriptor)
++        try:
++            ioctl(self.handle, USB_HID_SET_RAW, struct.pack('@i', 1))
++            ping = bytearray(64)
++            ping[0:7] = bytearray([0xff,0xff,0xff,0xff,0x81,0,1])
++            for i in range(10):
++                self.write_packet(ping)
++                poll = select.poll()
++                poll.register(self.handle, select.POLLIN)
++                if poll.poll(100):
++                    self.read_packet()
++                    break
++            else:
++                raise Exception('u2f ping timeout')
++        except Exception:
++            self.close()
++            raise



Home | Main Index | Thread Index | Old Index