From ee5b6a2a822dd8fe1d4f2ffaa9122d34d273e140 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 12 Dec 2012 15:30:40 +0900 Subject: [PATCH] fix tool/gnuk_remove_keys* --- ChangeLog | 9 +++++++++ doc/development.rst | 2 +- doc/gnuk-keytocard-noremoval.rst | 2 +- doc/gnuk-keytocard.rst | 2 +- tool/gnuk_remove_keys.py | 8 ++++---- tool/gnuk_remove_keys_libusb.py | 8 ++++---- tool/gnuk_token.py | 3 +++ 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 151f1c9..75feef4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-12-12 Niibe Yutaka + + * tool/gnuk_token.py: Add module imports. + + * tool/gnuk_remove_keys.py (main): Fix data object number + for KGTIME_SIG, KGTIME_DEC and KGTIME_AUT. + + * tool/gnuk_remove_keys_libusb.py (main): Likewise. + 2012-12-05 Niibe Yutaka * tool/gnuk_remove_keys_libusb.py: New. diff --git a/doc/development.rst b/doc/development.rst index cb0c259..2e67a5a 100644 --- a/doc/development.rst +++ b/doc/development.rst @@ -56,7 +56,7 @@ Recently, there is "gcc-arm-embedded" project. See: https://launchpad.net/gcc-arm-embedded/ It is based on GCC 4.6. For version 4.6-2012-q2-update, you'd -need "-O3 -s" instead of "-O2" and it will be slightly better. +need "-O3 -Os" instead of "-O2" and it will be slightly better. diff --git a/doc/gnuk-keytocard-noremoval.rst b/doc/gnuk-keytocard-noremoval.rst index 0e3abb9..f350376 100644 --- a/doc/gnuk-keytocard-noremoval.rst +++ b/doc/gnuk-keytocard-noremoval.rst @@ -126,7 +126,7 @@ I type ``key 1`` to deselect key number '1'. :: ssb 2048R/5BB065DC created: 2010-10-22 expires: never (1) NIIBE Yutaka -Thirdly, I select sub key of suthentication which has key number '2'. :: +Thirdly, I select sub key of authentication which has key number '2'. :: gpg> key 2 diff --git a/doc/gnuk-keytocard.rst b/doc/gnuk-keytocard.rst index e223c16..2c49292 100644 --- a/doc/gnuk-keytocard.rst +++ b/doc/gnuk-keytocard.rst @@ -134,7 +134,7 @@ I type ``key 1`` to deselect key number '1'. :: ssb 2048R/5BB065DC created: 2010-10-22 expires: never (1) NIIBE Yutaka -Thirdly, I select sub key of suthentication which has key number '2'. :: +Thirdly, I select sub key of authentication which has key number '2'. :: gpg> key 2 diff --git a/tool/gnuk_remove_keys.py b/tool/gnuk_remove_keys.py index dfdd07c..b8e0690 100755 --- a/tool/gnuk_remove_keys.py +++ b/tool/gnuk_remove_keys.py @@ -90,13 +90,13 @@ def main(passwd): gnuk.cmd_verify(BY_ADMIN, passwd) gnuk.cmd_select_openpgp() gnuk.cmd_put_data_remove(0x00, 0xc7) # FP_SIG - gnuk.cmd_put_data_remove(0x00, 0xcd) # KGTIME_SIG + gnuk.cmd_put_data_remove(0x00, 0xce) # KGTIME_SIG gnuk.cmd_put_data_key_import_remove(1) gnuk.cmd_put_data_remove(0x00, 0xc8) # FP_DEC - gnuk.cmd_put_data_remove(0x00, 0xce) # KGTIME_DEC + gnuk.cmd_put_data_remove(0x00, 0xcf) # KGTIME_DEC gnuk.cmd_put_data_key_import_remove(2) gnuk.cmd_put_data_remove(0x00, 0xc9) # FP_AUT - gnuk.cmd_put_data_remove(0x00, 0xcf) # KGTIME_AUT + gnuk.cmd_put_data_remove(0x00, 0xd0) # KGTIME_AUT gnuk.cmd_put_data_key_import_remove(3) gnuk.connection.disconnect() @@ -105,7 +105,7 @@ def main(passwd): if __name__ == '__main__': passwd = DEFAULT_PW3 - if sys.argv[1] == '-p': + if len(sys.argv) > 1 and sys.argv[1] == '-p': from getpass import getpass passwd = getpass("Admin password: ") sys.argv.pop(1) diff --git a/tool/gnuk_remove_keys_libusb.py b/tool/gnuk_remove_keys_libusb.py index 5692670..d04b432 100755 --- a/tool/gnuk_remove_keys_libusb.py +++ b/tool/gnuk_remove_keys_libusb.py @@ -49,13 +49,13 @@ def main(passwd): gnuk.cmd_verify(BY_ADMIN, passwd) gnuk.cmd_select_openpgp() gnuk.cmd_put_data_remove(0x00, 0xc7) # FP_SIG - gnuk.cmd_put_data_remove(0x00, 0xcd) # KGTIME_SIG + gnuk.cmd_put_data_remove(0x00, 0xce) # KGTIME_SIG gnuk.cmd_put_data_key_import_remove(1) gnuk.cmd_put_data_remove(0x00, 0xc8) # FP_DEC - gnuk.cmd_put_data_remove(0x00, 0xce) # KGTIME_DEC + gnuk.cmd_put_data_remove(0x00, 0xcf) # KGTIME_DEC gnuk.cmd_put_data_key_import_remove(2) gnuk.cmd_put_data_remove(0x00, 0xc9) # FP_AUT - gnuk.cmd_put_data_remove(0x00, 0xcf) # KGTIME_AUT + gnuk.cmd_put_data_remove(0x00, 0xd0) # KGTIME_AUT gnuk.cmd_put_data_key_import_remove(3) gnuk.icc_power_off() return 0 @@ -63,7 +63,7 @@ def main(passwd): if __name__ == '__main__': passwd = DEFAULT_PW3 - if sys.argv[1] == '-p': + if len(sys.argv) > 1 and sys.argv[1] == '-p': from getpass import getpass passwd = getpass("Admin password: ") sys.argv.pop(1) diff --git a/tool/gnuk_token.py b/tool/gnuk_token.py index 5dedefd..95541e5 100644 --- a/tool/gnuk_token.py +++ b/tool/gnuk_token.py @@ -20,6 +20,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ +from struct import * +import usb + # USB class, subclass, protocol CCID_CLASS = 0x0B CCID_SUBCLASS = 0x00