pkgsrc-Changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
CVS commit: pkgsrc/security/py-u2f
Module Name: pkgsrc
Committed By: riastradh
Date: Mon Aug 17 20:57:44 UTC 2020
Modified Files:
pkgsrc/security/py-u2f: Makefile PLIST distinfo
Added Files:
pkgsrc/security/py-u2f/patches: patch-pyu2f_hid_____init____.py
patch-pyu2f_hid_netbsd.py
Log Message:
security/py-u2f: Add NetBSD support.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 pkgsrc/security/py-u2f/Makefile \
pkgsrc/security/py-u2f/PLIST pkgsrc/security/py-u2f/distinfo
cvs rdiff -u -r0 -r1.1 \
pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_____init____.py \
pkgsrc/security/py-u2f/patches/patch-pyu2f_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-u2f/Makefile
diff -u pkgsrc/security/py-u2f/Makefile:1.1 pkgsrc/security/py-u2f/Makefile:1.2
--- pkgsrc/security/py-u2f/Makefile:1.1 Wed May 30 16:09:52 2018
+++ pkgsrc/security/py-u2f/Makefile Mon Aug 17 20:57:44 2020
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.1 2018/05/30 16:09:52 bsiegert Exp $
+# $NetBSD: Makefile,v 1.2 2020/08/17 20:57:44 riastradh Exp $
DISTNAME= pyu2f-0.1.4
PKGNAME= ${PYPKGPREFIX}-${DISTNAME:S/py//}
+PKGREVISION= 1
CATEGORIES= security python
MASTER_SITES= ${MASTER_SITE_PYPI:=p/pyu2f/}
Index: pkgsrc/security/py-u2f/PLIST
diff -u pkgsrc/security/py-u2f/PLIST:1.1 pkgsrc/security/py-u2f/PLIST:1.2
--- pkgsrc/security/py-u2f/PLIST:1.1 Wed May 30 16:09:52 2018
+++ pkgsrc/security/py-u2f/PLIST Mon Aug 17 20:57:44 2020
@@ -1,4 +1,4 @@
-@comment $NetBSD: PLIST,v 1.1 2018/05/30 16:09:52 bsiegert Exp $
+@comment $NetBSD: PLIST,v 1.2 2020/08/17 20:57:44 riastradh Exp $
${PYSITELIB}/${EGG_INFODIR}/PKG-INFO
${PYSITELIB}/${EGG_INFODIR}/SOURCES.txt
${PYSITELIB}/${EGG_INFODIR}/dependency_links.txt
@@ -44,6 +44,9 @@ ${PYSITELIB}/pyu2f/hid/linux.pyo
${PYSITELIB}/pyu2f/hid/macos.py
${PYSITELIB}/pyu2f/hid/macos.pyc
${PYSITELIB}/pyu2f/hid/macos.pyo
+${PYSITELIB}/pyu2f/hid/netbsd.py
+${PYSITELIB}/pyu2f/hid/netbsd.pyc
+${PYSITELIB}/pyu2f/hid/netbsd.pyo
${PYSITELIB}/pyu2f/hid/try.py
${PYSITELIB}/pyu2f/hid/try.pyc
${PYSITELIB}/pyu2f/hid/try.pyo
Index: pkgsrc/security/py-u2f/distinfo
diff -u pkgsrc/security/py-u2f/distinfo:1.1 pkgsrc/security/py-u2f/distinfo:1.2
--- pkgsrc/security/py-u2f/distinfo:1.1 Wed May 30 16:09:52 2018
+++ pkgsrc/security/py-u2f/distinfo Mon Aug 17 20:57:44 2020
@@ -1,6 +1,8 @@
-$NetBSD: distinfo,v 1.1 2018/05/30 16:09:52 bsiegert Exp $
+$NetBSD: distinfo,v 1.2 2020/08/17 20:57:44 riastradh Exp $
SHA1 (pyu2f-0.1.4.tar.gz) = 49be1741ad1c853ddfea6b82faf5113daaa8f1df
RMD160 (pyu2f-0.1.4.tar.gz) = 4cd83ad544d5d9700d4b6d9855443874d8ac053f
SHA512 (pyu2f-0.1.4.tar.gz) = 1c2a23acd3ab25f07a2800c21f556da1eee1e28269f02f4bab057e38494d5345837d1e015a323d769e594751fb0f852e00e718d6350b1a75b2596dae6cd9bdd5
Size (pyu2f-0.1.4.tar.gz) = 23261 bytes
+SHA1 (patch-pyu2f_hid_____init____.py) = 2f648792c78432776c4074e3bb2df0a195f65154
+SHA1 (patch-pyu2f_hid_netbsd.py) = d8df1b3805ad5e830548df5b6a601abf09a5dfa3
Added files:
Index: pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_____init____.py
diff -u /dev/null pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_____init____.py:1.1
--- /dev/null Mon Aug 17 20:57:44 2020
+++ pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_____init____.py Mon Aug 17 20:57:44 2020
@@ -0,0 +1,16 @@
+$NetBSD: patch-pyu2f_hid_____init____.py,v 1.1 2020/08/17 20:57:44 riastradh Exp $
+
+Add NetBSD support.
+
+--- pyu2f/hid/__init__.py.orig 2020-08-17 20:48:34.101158593 +0000
++++ pyu2f/hid/__init__.py
+@@ -41,6 +41,9 @@ def InternalPlatformSwitch(funcname, *ar
+ elif sys.platform.startswith('darwin'):
+ from pyu2f.hid import macos
+ clz = macos.MacOsHidDevice
++ elif sys.platform.startswith('netbsd'):
++ from pyu2f.hid import netbsd
++ clz = netbsd.NetBSDHidDevice
+
+ if not clz:
+ raise Exception('Unsupported platform: ' + sys.platform)
Index: pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_netbsd.py
diff -u /dev/null pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_netbsd.py:1.1
--- /dev/null Mon Aug 17 20:57:44 2020
+++ pkgsrc/security/py-u2f/patches/patch-pyu2f_hid_netbsd.py Mon Aug 17 20:57:44 2020
@@ -0,0 +1,121 @@
+$NetBSD: patch-pyu2f_hid_netbsd.py,v 1.1 2020/08/17 20:57:44 riastradh Exp $
+
+Add NetBSD support.
+
+--- pyu2f/hid/netbsd.py.orig 2020-08-17 20:43:03.167593821 +0000
++++ pyu2f/hid/netbsd.py
+@@ -0,0 +1,114 @@
++# 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 os
++import select
++import struct
++import sys
++
++from fcntl import ioctl
++
++from pyu2f.hid import base
++from pyu2f.hid import linux
++
++
++# struct usb_ctl_report_desc {
++# int ucrd_size;
++# unsigned char ucrd_data[1024];
++# };
++
++SIZEOF_USB_CTL_REPORT_DESC = 4 + 1024
++USB_GET_REPORT_DESC = 0x44045515 # _IOR('U', 21, struct usb_ctl_report_desc)
++
++SIZEOF_USB_DEVICE_INFO = 1268
++USB_DEVICE_INFO_PRODUCT = 1168
++USB_DEVICE_INFO_VENDOR = 1170
++USB_GET_DEVICE_INFO = 0x44f45570 # _IOR('U', 112, struct usb_device_info)
++
++USB_HID_SET_RAW = 0x80046802 # _IOW('h', 2, int)
++
++
++FIDO_USAGE_PAGE = 0xf1d0
++FIDO_USAGE_U2FHID = 0x01
++
++
++class NetBSDHidDevice(linux.LinuxHidDevice):
++ """Implementation of HID device for NetBSD.
++ """
++
++ @classmethod
++ def _setup(cls, fd, path):
++ devinfo = bytearray([0] * SIZEOF_USB_DEVICE_INFO)
++ ioctl(fd, USB_GET_DEVICE_INFO, devinfo, True)
++ vendor = devinfo[USB_DEVICE_INFO_VENDOR:USB_DEVICE_INFO_VENDOR + 2]
++ product = devinfo[USB_DEVICE_INFO_PRODUCT:USB_DEVICE_INFO_PRODUCT + 2]
++ descbuf = bytearray([0] * SIZEOF_USB_CTL_REPORT_DESC)
++ ioctl(fd, USB_GET_REPORT_DESC, descbuf, True)
++ descsize = struct.unpack('@i', descbuf[0:4])[0]
++ descdata = descbuf[4:4 + descsize]
++ desc = base.DeviceDescriptor()
++ desc.path = path
++ desc.vendor_id = struct.unpack('@H', vendor)[0]
++ desc.product_id = struct.unpack('@H', product)[0]
++ linux.ParseReportDescriptor(descdata, desc)
++ if desc.usage_page != FIDO_USAGE_PAGE:
++ raise Exception('usage page != fido')
++ if desc.usage != FIDO_USAGE_U2FHID:
++ raise Exception('fido usage != u2fhid')
++ ioctl(fd, USB_HID_SET_RAW, struct.pack('@i', 1))
++ ping = bytearray([0] * 64)
++ ping[0:7] = bytearray([0xff,0xff,0xff,0xff,0x81,0,1])
++ for i in range(10):
++ os.write(fd, ping)
++ poll = select.poll()
++ poll.register(fd, select.POLLIN)
++ if poll.poll(100):
++ os.read(fd, 64 + 1)
++ break
++ else:
++ raise Exception('u2f ping timeout')
++ return desc
++
++ @classmethod
++ def Enumerate(cls):
++ for i in range(100):
++ path = '/dev/uhid{}'.format(i)
++ fd = None
++ try:
++ fd = os.open(path, os.O_RDWR|os.O_CLOEXEC)
++ desc = cls._setup(fd, path)
++ except OSError as e:
++ if e.errno == errno.ENOENT:
++ break
++ continue
++ finally:
++ if fd is not None:
++ os.close(fd)
++ yield desc.ToPublicDict()
++
++ def __init__(self, path):
++ base.HidDevice.__init__(self, path)
++ self.dev = os.open(path, os.O_RDWR)
++ self.desc = self._setup(self.dev, path)
++
++ def __del__(self):
++ os.close(self.dev)
++
++ def Write(self, packet):
++ os.write(self.dev, bytearray(packet))
Home |
Main Index |
Thread Index |
Old Index