From 932e6acd406e130d41dbd936fdc7268da9808fe2 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 25 Dec 2013 11:33:00 +0900 Subject: [PATCH] Support PyUSB 1.0, too --- ChangeLog | 8 ++++ NEWS | 7 +++- README | 2 +- doc/development.rst | 2 +- doc/generating-2048-RSA-key.rst | 2 +- doc/gnuk-keytocard-noremoval.rst | 1 - doc/gnuk-keytocard.rst | 1 - doc/gnuk-passphrase-setting.rst | 42 +++++++++++++------ doc/gnuk-personalization.rst | 11 ++--- doc/intro.rst | 2 +- ...using-gnuk-token-with-another-computer.rst | 1 - tool/dfuse.py | 2 +- tool/gnuk_token.py | 4 +- tool/gnuk_upgrade.py | 4 +- tool/stlinkv2.py | 2 +- 15 files changed, 58 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c2397a..4d87112 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-12-25 Niibe Yutaka + + * tool/gnuk_token.py (gnuk_token.__init__, regnual.__init__): Fix + the argument of setAltInterface. + * tool/gnuk_upgrade.py: Likewise. + * tool/dfuse.py (DFU_STM32.__init__): Likewise. + * tool/stlinkv2.py (stlinkv2.__init__): Likewise. + 2013-12-24 Niibe Yutaka * polarssl/include/polarssl/bn_mul.h (MULADDC_1024_CORE) diff --git a/NEWS b/NEWS index 42d80db..ffe1d51 100644 --- a/NEWS +++ b/NEWS @@ -4,9 +4,12 @@ Gnuk NEWS - User visible changes Released 2013-12-25, by NIIBE Yutaka +** Tools and test suite now work with PyUSB 1.0, too. +It only worked with PyUSB 0.4.3, but it works with PyUSB 1.0 too. + ** Improved RSA routine -Working memory for RSA computation is taken from stack (mostly), -instead of malloc. +Working memory for RSA computation is taken from stack instead of +malloc (mostly). * Major changes in Gnuk 1.1.0 diff --git a/README b/README index f0f2de0..ff91b2d 100644 --- a/README +++ b/README @@ -218,7 +218,7 @@ External source code Gnuk is distributed with external source code. -* chopstx/ -- Chopstx 0.04 +* chopstx/ -- Chopstx 0.03 (+ STBee support) We use Chopstx as the kernel for Gnuk. diff --git a/doc/development.rst b/doc/development.rst index 2ca33a1..9b03f9c 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -38,7 +38,7 @@ You need GNU toolchain and newlib for 'arm-none-eabi' target. There is "gcc-arm-embedded" project. See: https://launchpad.net/gcc-arm-embedded/ -It is based on GCC 4.7 (as of October, 2013). We are using "-O3 -Os" +It is based on GCC 4.8 (as of December, 2013). We are using "-O3 -Os" for compiler option. diff --git a/doc/generating-2048-RSA-key.rst b/doc/generating-2048-RSA-key.rst index b41cde6..46d3b99 100644 --- a/doc/generating-2048-RSA-key.rst +++ b/doc/generating-2048-RSA-key.rst @@ -121,7 +121,7 @@ Then, GnuPG generate keys. It takes some time. :: Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 15 more bytes) ...+++++ - gpg: key 28C0CD7C marked as ultimately trusted + gpg: key 4CA7BABE marked as ultimately trusted public and secret key created and signed. gpg: checking the trustdb diff --git a/doc/gnuk-keytocard-noremoval.rst b/doc/gnuk-keytocard-noremoval.rst index 76697ca..ec67452 100644 --- a/doc/gnuk-keytocard-noremoval.rst +++ b/doc/gnuk-keytocard-noremoval.rst @@ -44,7 +44,6 @@ and type ``1`` to say it's signature key. :: gpg> keytocard Really move the primary key? (y/N) y - gpg: detected reader `FSIJ Gnuk (0.12-38FF6A06) 00 00' Signature key ....: [none] Encryption key....: [none] Authentication key: [none] diff --git a/doc/gnuk-keytocard.rst b/doc/gnuk-keytocard.rst index 3843632..1e23271 100644 --- a/doc/gnuk-keytocard.rst +++ b/doc/gnuk-keytocard.rst @@ -56,7 +56,6 @@ and type ``1`` to say it's signature key. :: gpg> keytocard Really move the primary key? (y/N) y - gpg: detected reader `FSIJ Gnuk (0.12-38FF6A06) 00 00' Signature key ....: [none] Encryption key....: [none] Authentication key: [none] diff --git a/doc/gnuk-passphrase-setting.rst b/doc/gnuk-passphrase-setting.rst index 9ea4bdb..278d16d 100644 --- a/doc/gnuk-passphrase-setting.rst +++ b/doc/gnuk-passphrase-setting.rst @@ -28,27 +28,38 @@ Set up PW1, PW3 and reset code Invoke GnuPG with the option ``--card-edit``. :: $ gpg --card-edit - gpg: detected reader `FSIJ Gnuk (0.12-34006E06) 00 00' Application ID ...: D276000124010200F517000000010000 Version ..........: 2.0 Manufacturer .....: FSIJ Serial number ....: 00000001 - Name of cardholder: [not set] - Language prefs ...: [not set] - Sex ..............: unspecified - URL of public key : [not set] - Login data .......: [not set] - Signature PIN ....: forced + Name of cardholder: Yutaka Niibe + Language prefs ...: ja + Sex ..............: male + URL of public key : http://www.gniibe.org/gniibe.asc + Login data .......: gniibe + Signature PIN ....: not forced Key attributes ...: 2048R 2048R 2048R Max. PIN lengths .: 127 127 127 PIN retry counter : 3 3 3 Signature counter : 0 - Signature key ....: [none] - Encryption key....: [none] - Authentication key: [none] - General key info..: [none] + Signature key ....: 1241 24BD 3B48 62AF 7A0A 42F1 00B4 5EBD 4CA7 BABE + created ....: 2010-10-15 06:46:33 + Encryption key....: 42E1 E805 4E6F 1F30 26F2 DC79 79A7 9093 0842 39CF + created ....: 2010-10-15 06:46:33 + Authentication key: B4D9 7142 C42D 6802 F5F7 4E70 9C33 B6BA 5BB0 65DC + created ....: 2010-10-22 06:06:36 + General key info..: + pub 2048R/4CA7BABE 2010-10-15 NIIBE Yutaka + sec> 2048R/4CA7BABE created: 2010-10-15 expires: never + card-no: F517 00000001 + ssb> 2048R/084239CF created: 2010-10-15 expires: never + card-no: F517 00000001 + ssb> 2048R/5BB065DC created: 2010-10-22 expires: never + card-no: F517 00000001 -It shows the status of the card (as same as the output of ``gpg --card-status``). It shows token's name and its USB serial string (0.12-34006E06) from PC/SC-lite. + gpg/card> + +It shows the status of the card (as same as the output of ``gpg --card-status``). Then, GnuPG enters its own command interaction mode. The prompt is ``gpg/card>``. @@ -83,8 +94,13 @@ please change admin-password at first. Then, the token works as same as OpenPGPcard specification with regards to PW1 and PW3.) -Lastly, I setup reset code. This is optional. :: +Lastly, I setup reset code, entering admin mode. +Having reset code, you can unblock PIN when the token will be blocked +(by wrong attempt to entering PIN). This is optional step. :: + gpg/card> admin + Admin commands are allowed + gpg/card> passwd gpg: OpenPGP card no. D276000124010200F517000000010000 detected diff --git a/doc/gnuk-personalization.rst b/doc/gnuk-personalization.rst index 9da6279..73d5512 100644 --- a/doc/gnuk-personalization.rst +++ b/doc/gnuk-personalization.rst @@ -9,11 +9,10 @@ Personalize your Gnuk Token Invoke GnuPG with the option ``--card-edit``. :: $ gpg --card-edit - gpg: detected reader `FSIJ Gnuk (0.12-34006E06) 00 00' - Application ID ...: D276000124010200F517000000010000 + Application ID ...: D276000124010200FFFE330069060000 Version ..........: 2.0 - Manufacturer .....: FSIJ - Serial number ....: 00000001 + Manufacturer .....: unmanaged S/N range + Serial number ....: 33006906 Name of cardholder: [not set] Language prefs ...: [not set] Sex ..............: unspecified @@ -28,8 +27,10 @@ Invoke GnuPG with the option ``--card-edit``. :: Encryption key....: [none] Authentication key: [none] General key info..: [none] + + gpg/card> -It shows the status of the card (as same as the output of ``gpg --card-status``). It shows token's name and its USB serial string (0.12-34006E06) from PC/SC-lite. +It shows the status of the card (as same as the output of ``gpg --card-status``). Then, GnuPG enters its own command interaction mode. The prompt is ``gpg/card>``. diff --git a/doc/intro.rst b/doc/intro.rst index 474b3f9..0bae5c8 100644 --- a/doc/intro.rst +++ b/doc/intro.rst @@ -51,7 +51,7 @@ Host prerequisites for using Gnuk Token * [Optional] PC/SC lite (pcscd, libccid) -* SSH: openssh +* [Optional] SSH: openssh * [optional] Web: scute, firefox diff --git a/doc/using-gnuk-token-with-another-computer.rst b/doc/using-gnuk-token-with-another-computer.rst index 188ec1a..d33eaa4 100644 --- a/doc/using-gnuk-token-with-another-computer.rst +++ b/doc/using-gnuk-token-with-another-computer.rst @@ -18,7 +18,6 @@ key reference (to the token) in ``.gnupg``. To do that, invoke GnuPG with ``--card-edit`` option. :: $ gpg --card-edit - gpg: detected reader `FSIJ Gnuk (0.12-37006A06) 00 00' Application ID ...: D276000124010200F517000000010000 Version ..........: 2.0 Manufacturer .....: FSIJ diff --git a/tool/dfuse.py b/tool/dfuse.py index d95750e..cd0f172 100755 --- a/tool/dfuse.py +++ b/tool/dfuse.py @@ -111,7 +111,7 @@ class DFU_STM32(object): self.__devhandle = device.open() self.__devhandle.setConfiguration(configuration) self.__devhandle.claimInterface(interface) - self.__devhandle.setAltInterface(interface) + self.__devhandle.setAltInterface(0) self.__intf = interface.interfaceNumber self.__alt = interface.alternateSetting diff --git a/tool/gnuk_token.py b/tool/gnuk_token.py index a5f5761..9e0ba92 100644 --- a/tool/gnuk_token.py +++ b/tool/gnuk_token.py @@ -73,7 +73,7 @@ class gnuk_token(object): except: pass self.__devhandle.claimInterface(interface) - self.__devhandle.setAltInterface(interface) + self.__devhandle.setAltInterface(0) self.__intf = interface.interfaceNumber self.__alt = interface.alternateSetting @@ -481,7 +481,7 @@ class regnual(object): except: pass self.__devhandle.claimInterface(intf) - self.__devhandle.setAltInterface(intf) + self.__devhandle.setAltInterface(0) def mem_info(self): mem = self.__devhandle.controlMsg(requestType = 0xc0, request = 0, diff --git a/tool/gnuk_upgrade.py b/tool/gnuk_upgrade.py index ea63177..ccf5d2a 100755 --- a/tool/gnuk_upgrade.py +++ b/tool/gnuk_upgrade.py @@ -59,7 +59,7 @@ class regnual(object): except: pass self.__devhandle.claimInterface(intf) - self.__devhandle.setAltInterface(intf) + self.__devhandle.setAltInterface(0) def mem_info(self): mem = self.__devhandle.controlMsg(requestType = 0xc0, request = 0, @@ -172,7 +172,7 @@ class gnuk_token(object): except: pass self.__devhandle.claimInterface(interface) - self.__devhandle.setAltInterface(interface) + self.__devhandle.setAltInterface(0) self.__intf = interface.interfaceNumber self.__alt = interface.alternateSetting diff --git a/tool/stlinkv2.py b/tool/stlinkv2.py index 5168b07..2a2e0d3 100755 --- a/tool/stlinkv2.py +++ b/tool/stlinkv2.py @@ -146,7 +146,7 @@ class stlinkv2(object): except: pass self.__devhandle.claimInterface(intf) - # self.__devhandle.setAltInterface(intf) # This is not good for libusb-win32 + # self.__devhandle.setAltInterface(0) # This was not good for libusb-win32 with wrong arg intf, new correct value 0 would be OK def shutdown(self): self.__devhandle.releaseInterface()