@@ -1,5 +1,14 @@
|
|||||||
2021-02-19 NIIBE Yutaka <gniibe@fsij.org>
|
2021-02-19 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* tool/upgrade_by_passwd.py (main): Use tobytes.
|
||||||
|
* tool/gnuk_get_random.py: Likewise.
|
||||||
|
* tool/gnuk_remove_keys_libusb.py (main): Likewise.
|
||||||
|
Switch to Python3.
|
||||||
|
* tool/gnuk_put_binary_libusb.py (main): Use tobytes.
|
||||||
|
Switch to Python3.
|
||||||
|
* tool/gnuk_upgrade.py (main): Use tobytes.
|
||||||
|
Switch to Python3.
|
||||||
|
|
||||||
* chopstx: Update to 1.19.
|
* chopstx: Update to 1.19.
|
||||||
|
|
||||||
2021-02-18 Vincent Pelletier <plr.vincent@gmail.com>
|
2021-02-18 Vincent Pelletier <plr.vincent@gmail.com>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if __name__ == '__main__':
|
|||||||
looping = (len(sys.argv) > 1)
|
looping = (len(sys.argv) > 1)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
challenge = gnuk.cmd_get_challenge().tostring()
|
challenge = gnuk.cmd_get_challenge().tobytes()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(count)
|
print(count)
|
||||||
raise e
|
raise e
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gnuk_put_binary.py - a tool to put binary to Gnuk Token
|
gnuk_put_binary.py - a tool to put binary to Gnuk Token
|
||||||
This tool is for importing certificate, writing serial number, etc.
|
This tool is for importing certificate, writing serial number, etc.
|
||||||
|
|
||||||
Copyright (C) 2011, 2012 Free Software Initiative of Japan
|
Copyright (C) 2011, 2012, 2021 Free Software Initiative of Japan
|
||||||
Author: NIIBE Yutaka <gniibe@fsij.org>
|
Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||||
@@ -56,7 +56,7 @@ def main(fileid, is_update, data, passwd):
|
|||||||
if fileid == 0:
|
if fileid == 0:
|
||||||
data_in_device = gnuk.cmd_get_data(0x00, 0x4f)
|
data_in_device = gnuk.cmd_get_data(0x00, 0x4f)
|
||||||
print(' '.join([ "%02x" % d for d in data_in_device ]))
|
print(' '.join([ "%02x" % d for d in data_in_device ]))
|
||||||
compare(data + b'\x00\x00', data_in_device[8:].tostring())
|
compare(data + b'\x00\x00', data_in_device[8:].tobytes())
|
||||||
elif fileid >= 1 and fileid <= 4:
|
elif fileid >= 1 and fileid <= 4:
|
||||||
data_in_device = gnuk.cmd_read_binary(fileid)
|
data_in_device = gnuk.cmd_read_binary(fileid)
|
||||||
compare(data, data_in_device)
|
compare(data, data_in_device)
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gnuk_remove_keys_libusb.py - a tool to remove keys in Gnuk Token
|
gnuk_remove_keys_libusb.py - a tool to remove keys in Gnuk Token
|
||||||
|
|
||||||
Copyright (C) 2012, 2018 Free Software Initiative of Japan
|
Copyright (C) 2012, 2018, 2021 Free Software Initiative of Japan
|
||||||
Author: NIIBE Yutaka <gniibe@fsij.org>
|
Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||||
@@ -51,7 +51,7 @@ def main(passwd):
|
|||||||
gnuk.icc_power_on()
|
gnuk.icc_power_on()
|
||||||
gnuk.cmd_select_openpgp()
|
gnuk.cmd_select_openpgp()
|
||||||
# Compute passwd data
|
# Compute passwd data
|
||||||
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tostring()
|
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tobytes()
|
||||||
if kdf_data == b"":
|
if kdf_data == b"":
|
||||||
passwd_data = passwd.encode('UTF-8')
|
passwd_data = passwd.encode('UTF-8')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
gnuk_upgrade.py - a tool to upgrade firmware of Gnuk Token
|
gnuk_upgrade.py - a tool to upgrade firmware of Gnuk Token
|
||||||
|
|
||||||
Copyright (C) 2012, 2015 Free Software Initiative of Japan
|
Copyright (C) 2012, 2015, 2021 Free Software Initiative of Japan
|
||||||
Author: NIIBE Yutaka <gniibe@fsij.org>
|
Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||||
@@ -70,7 +70,7 @@ def gpg_sign(keygrip, hash):
|
|||||||
raise ValueError(binascii.hexlify(signed))
|
raise ValueError(binascii.hexlify(signed))
|
||||||
return signed
|
return signed
|
||||||
|
|
||||||
def main(keyno,keygrip, data_regnual, data_upgrade):
|
def main(keyno, keygrip, data_regnual, data_upgrade):
|
||||||
l = len(data_regnual)
|
l = len(data_regnual)
|
||||||
if (l & 0x03) != 0:
|
if (l & 0x03) != 0:
|
||||||
data_regnual = data_regnual.ljust(l + 4 - (l & 0x03), b'\x00')
|
data_regnual = data_regnual.ljust(l + 4 - (l & 0x03), b'\x00')
|
||||||
@@ -91,7 +91,7 @@ def main(keyno,keygrip, data_regnual, data_upgrade):
|
|||||||
elif icc.icc_get_status() == 1:
|
elif icc.icc_get_status() == 1:
|
||||||
icc.icc_power_on()
|
icc.icc_power_on()
|
||||||
icc.cmd_select_openpgp()
|
icc.cmd_select_openpgp()
|
||||||
challenge = icc.cmd_get_challenge().tostring()
|
challenge = icc.cmd_get_challenge().tobytes()
|
||||||
signed = gpg_sign(keygrip, binascii.hexlify(challenge))
|
signed = gpg_sign(keygrip, binascii.hexlify(challenge))
|
||||||
icc.cmd_external_authenticate(keyno, signed)
|
icc.cmd_external_authenticate(keyno, signed)
|
||||||
icc.stop_gnuk()
|
icc.stop_gnuk()
|
||||||
@@ -107,17 +107,19 @@ def main(keyno,keygrip, data_regnual, data_upgrade):
|
|||||||
del icc
|
del icc
|
||||||
icc = None
|
icc = None
|
||||||
#
|
#
|
||||||
print("Wait 3 seconds...")
|
|
||||||
time.sleep(3)
|
|
||||||
# Then, send upgrade program...
|
|
||||||
reg = None
|
reg = None
|
||||||
|
print("Waiting for device to appear:")
|
||||||
|
while reg == None:
|
||||||
|
print(" Wait {} second{}...".format(wait_e, 's' if wait_e > 1 else ''))
|
||||||
|
time.sleep(wait_e)
|
||||||
for dev in gnuk_devices_by_vidpid():
|
for dev in gnuk_devices_by_vidpid():
|
||||||
try:
|
try:
|
||||||
reg = regnual(dev)
|
reg = regnual(dev)
|
||||||
print("Device: %d" % dev.filename)
|
print("Device: %s" % dev.filename)
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
# Then, send upgrade program...
|
||||||
mem_info = reg.mem_info()
|
mem_info = reg.mem_info()
|
||||||
print("%08x:%08x" % mem_info)
|
print("%08x:%08x" % mem_info)
|
||||||
print("Downloading the program")
|
print("Downloading the program")
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#! /usr/bin/python
|
#! /usr/bin/python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
upgrade_by_passwd.py - a tool to install another firmware for Gnuk Token
|
upgrade_by_passwd.py - a tool to install another firmware for Gnuk Token
|
||||||
which is just shipped from factory
|
which is just shipped from factory
|
||||||
|
|
||||||
Copyright (C) 2012, 2013, 2015, 2018
|
Copyright (C) 2012, 2013, 2015, 2018, 2021
|
||||||
Free Software Initiative of Japan
|
Free Software Initiative of Japan
|
||||||
Author: NIIBE Yutaka <gniibe@fsij.org>
|
Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ def main(wait_e, keyno, passwd, data_regnual, data_upgrade):
|
|||||||
gnuk.cmd_select_openpgp()
|
gnuk.cmd_select_openpgp()
|
||||||
# Compute passwd data
|
# Compute passwd data
|
||||||
try:
|
try:
|
||||||
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tostring()
|
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tobytes()
|
||||||
except:
|
except:
|
||||||
kdf_data = b""
|
kdf_data = b""
|
||||||
if kdf_data == b"":
|
if kdf_data == b"":
|
||||||
@@ -70,7 +70,7 @@ def main(wait_e, keyno, passwd, data_regnual, data_upgrade):
|
|||||||
gnuk.cmd_write_binary(1+keyno, rsa_raw_pubkey, False)
|
gnuk.cmd_write_binary(1+keyno, rsa_raw_pubkey, False)
|
||||||
|
|
||||||
gnuk.cmd_select_openpgp()
|
gnuk.cmd_select_openpgp()
|
||||||
challenge = gnuk.cmd_get_challenge().tostring()
|
challenge = gnuk.cmd_get_challenge().tobytes()
|
||||||
digestinfo = binascii.unhexlify(SHA256_OID_PREFIX) + challenge
|
digestinfo = binascii.unhexlify(SHA256_OID_PREFIX) + challenge
|
||||||
signed = rsa.compute_signature(rsa_key, digestinfo)
|
signed = rsa.compute_signature(rsa_key, digestinfo)
|
||||||
signed_bytes = rsa.integer_to_bytes_256(signed)
|
signed_bytes = rsa.integer_to_bytes_256(signed)
|
||||||
|
|||||||
Reference in New Issue
Block a user