Compare commits
14 Commits
release/1.
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4af98308e0 | ||
|
|
baec3a1c1e | ||
|
|
4f1325794d | ||
|
|
0acf6485ae | ||
|
|
4d15700580 | ||
|
|
8822fcae77 | ||
|
|
20a2f99691 | ||
|
|
acfccb729d | ||
|
|
5283506755 | ||
|
|
c688df7c2c | ||
|
|
594896ac57 | ||
|
|
dfe046e08d | ||
|
|
c66b01e74b | ||
|
|
21a46306ae |
18
AUTHORS
18
AUTHORS
@@ -11,6 +11,16 @@ Anthony Romano:
|
||||
src/main.c
|
||||
src/mod.c
|
||||
|
||||
Bertrand Jacquin
|
||||
Modified:
|
||||
tool/add_openpgp_authkey_from_gpgssh.py
|
||||
tool/calc_precompute_table_ecc.py
|
||||
tool/dfuse.py
|
||||
tool/dump_mem.py
|
||||
tool/get_raw_public_key.py
|
||||
tool/pageant_proxy_to_gpg.py
|
||||
tool/pinpadtest.py
|
||||
|
||||
Jeremy Drake:
|
||||
Modified:
|
||||
regnual/regnual.c
|
||||
@@ -74,3 +84,11 @@ Peter Lebbing:
|
||||
src/Makefile
|
||||
Wrote:
|
||||
src/stdaln-sys.ld.in
|
||||
|
||||
Vincent Pelletier:
|
||||
Modified:
|
||||
test/features/202_setup_passphrase.feature
|
||||
test/rsa_keys.py
|
||||
tests/card_reader.py
|
||||
tests/rsa_keys.py
|
||||
tool/gnuk_token.py
|
||||
|
||||
54
ChangeLog
54
ChangeLog
@@ -1,3 +1,57 @@
|
||||
2021-02-25 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* VERSION: 1.2.17.
|
||||
|
||||
2021-02-22 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/config.h.in (@KDF_DO_REQUIRED_DEFINE@): New.
|
||||
|
||||
* src/configure (KDF_DO_REQUIRED_DEFINE): New for GNU/Linux.
|
||||
|
||||
* src/openpgp-do.c (gpg_do_kdf_check): When LEN==0, check if
|
||||
KDO data object is available.
|
||||
[KDF_DO_REQUIRED] (proc_key_import): Refuse the key import when
|
||||
KDF data object is not available.
|
||||
|
||||
* src/openpgp.c [KDF_DO_REQUIRED] (cmd_pgp_gakp): Refuse key
|
||||
generation when KDF data object is not available.
|
||||
|
||||
2021-02-19 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* tool/gnuk-emulation-setup: Remove.
|
||||
|
||||
* 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.
|
||||
|
||||
2021-02-18 Vincent Pelletier <plr.vincent@gmail.com>
|
||||
|
||||
* test/features/202_setup_passphrase.feature: Fix.
|
||||
* test/rsa_keys.py: Fix escape.
|
||||
* tests/card_reader.py: Extend the timeout.
|
||||
Handle no card.
|
||||
* tests/rsa_keys.py: Fix escape.
|
||||
* tool/gnuk_token.py: Avoid hard-coding the endpoints.
|
||||
Longer timeout.
|
||||
|
||||
2021-02-18 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* src/configure [GNU_LINUX_EMULATION] (def_mhz): Define.
|
||||
(output_vendor_product_serial_strings): Output ARCH.
|
||||
|
||||
* GNUK_USB_DEVICE_ID: Use "Gnuk Token" for emulation, too.
|
||||
|
||||
* src/main.c [GNU_LINUX_EMULATION] (main): Add initialization of
|
||||
the .gnuk-flash-image file.
|
||||
(gnuk_sbrk): Rename from sbrk.
|
||||
|
||||
2020-09-10 NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
* VERSION: 1.2.16.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# VID:PID bcdDev Product_STRING Vendor_STRING
|
||||
0000:0000 0200 Gnuk Emulation Free Software Initiative of Japan
|
||||
0000:0000 0200 Gnuk Token Free Software Initiative of Japan
|
||||
234b:0000 0200 Gnuk Token Free Software Initiative of Japan
|
||||
20a0:4211 0200 Nitrokey Start Nitrokey
|
||||
1209:2440 0200 Gnuk Token GnuPG e.V.
|
||||
|
||||
22
NEWS
22
NEWS
@@ -1,6 +1,28 @@
|
||||
Gnuk NEWS - User visible changes
|
||||
|
||||
|
||||
* Major changes in Gnuk 1.2.17
|
||||
|
||||
Released 2021-02-25, by NIIBE Yutaka
|
||||
|
||||
** GNU/Linux: KDF Data Object is required before keygen and key import
|
||||
For GNU/Linux emulation, KDF Data Object is required before keygen and
|
||||
key import.
|
||||
|
||||
** GNU/Linux emulation
|
||||
Since 1.2.10, it was not build-able because of MHZ definition. It is
|
||||
build-able again, and its USB product string is now "Gnuk Token". It
|
||||
has ACK button support using terminal. It now has start-up message,
|
||||
and its driver show useful information to setup USBIP. When no file
|
||||
for the .gnuk-flash-image file, it is automatically created.
|
||||
|
||||
** Removal of tool/gnuk-emulation-setup
|
||||
Because it is automatically created, the tool is not needed any more.
|
||||
|
||||
** Upgrade of Chopstx
|
||||
We use Chopstx 1.19.
|
||||
|
||||
|
||||
* Major changes in Gnuk 1.2.16
|
||||
|
||||
Released 2020-09-10, by NIIBE Yutaka
|
||||
|
||||
23
README
23
README
@@ -1,14 +1,14 @@
|
||||
Gnuk - An Implementation of USB Cryptographic Token for GnuPG
|
||||
|
||||
Version 1.2.16
|
||||
2020-09-10
|
||||
Version 1.2.17
|
||||
2021-02-25
|
||||
Niibe Yutaka
|
||||
Free Software Initiative of Japan
|
||||
|
||||
Release Notes
|
||||
=============
|
||||
|
||||
This is the release of Gnuk, version 1.2.16, which has major
|
||||
This is the release of Gnuk, version 1.2.17, which has major
|
||||
incompatible changes to Gnuk 1.0.x. Specifically, it now supports
|
||||
overriding key import, but importing keys (or generating keys) results
|
||||
password reset. Also, you need to import private keys before changing
|
||||
@@ -28,7 +28,8 @@ experimental. To use the feature, you need to use newer GnuPG (2.2.6
|
||||
or later). You need to prepare the KDF-DO on your token by the
|
||||
card-edit/kdf-setup command.
|
||||
|
||||
With FST-01SZ, experimental ack button support is available for test.
|
||||
With FST-01SZ and GNU/Linux emulation, experimental ack button support
|
||||
is available for test.
|
||||
|
||||
|
||||
What's Gnuk?
|
||||
@@ -242,7 +243,7 @@ External source code
|
||||
|
||||
Gnuk is distributed with external source code.
|
||||
|
||||
* chopstx/ -- Chopstx 1.18
|
||||
* chopstx/ -- Chopstx 1.19
|
||||
|
||||
We use Chopstx as the kernel for Gnuk.
|
||||
|
||||
@@ -361,13 +362,13 @@ How to compile
|
||||
|
||||
You need GNU toolchain and newlib for 'arm-none-eabi' target.
|
||||
|
||||
On Debian we can install the packages of gcc-arm-none-eabi,
|
||||
gdb-arm-none-eabi and its friends. I'm using:
|
||||
On Debian we can install the packages of gcc-arm-none-eabi
|
||||
and its friends. I'm using:
|
||||
|
||||
binutils-arm-none-eabi 2.31.1-12+11
|
||||
gcc-arm-none-eabi 15:7-2018-q2-6
|
||||
gdb-multiarch 8.2.1-1
|
||||
libnewlib-arm-none-eabi 3.1.0.20181231-1
|
||||
binutils-arm-none-eabi 2.35.1-7+14+b1
|
||||
gcc-arm-none-eabi 15:8-2019-q3-1+b1
|
||||
libnewlib-arm-none-eabi 3.3.0-1
|
||||
gdb-multiarch 10.1-1.7
|
||||
|
||||
Or else, see https://launchpad.net/gcc-arm-embedded for preparation of
|
||||
GNU Toolchain for 'arm-none-eabi' target.
|
||||
|
||||
1
THANKS
1
THANKS
@@ -41,5 +41,6 @@ Shane Coughlan scoughlan@openinventionnetwork.com
|
||||
Stanislas Bach sbach@0g.re
|
||||
Szczepan Zalega szczepan@nitrokey.com
|
||||
Vasily Evseenko
|
||||
Vincent Pelletier plr.vincent@gmail.com
|
||||
Werner Koch wk@gnupg.org
|
||||
Yuji Imai ug@xcast.jp
|
||||
|
||||
2
chopstx
2
chopstx
Submodule chopstx updated: cc49f4ef23...71cc5a8f32
@@ -12,3 +12,4 @@
|
||||
@LIFE_CYCLE_MANAGEMENT_DEFINE@
|
||||
@ACKBTN_DEFINE@
|
||||
@SERIALNO_STR_LEN_DEFINE@
|
||||
@KDF_DO_REQUIRED_DEFINE@
|
||||
|
||||
19
src/configure
vendored
19
src/configure
vendored
@@ -6,7 +6,7 @@ nl=$'\n'
|
||||
#
|
||||
# This file is *NOT* generated by GNU Autoconf, but written by NIIBE Yutaka
|
||||
#
|
||||
# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
|
||||
# Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2021
|
||||
# Free Software Initiative of Japan
|
||||
#
|
||||
# This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
@@ -46,6 +46,7 @@ hid_card_change=no
|
||||
factory_reset=no
|
||||
ackbtn_support=yes
|
||||
flash_override=""
|
||||
kdf_do_required=no
|
||||
# For emulation
|
||||
prefix=/usr/local
|
||||
exec_prefix='${prefix}'
|
||||
@@ -210,26 +211,28 @@ FST_01SZ)
|
||||
;;
|
||||
esac
|
||||
|
||||
def_mhz="-DMHZ=$MHZ"
|
||||
if test "$target" = "GNU_LINUX"; then
|
||||
ldscript=""
|
||||
chip="gnu-linux"
|
||||
arch="gnu-linux"
|
||||
emulation="yes"
|
||||
cross=""
|
||||
mcu="none"
|
||||
kdf_do_require=yes
|
||||
def_emulation="-DGNU_LINUX_EMULATION"
|
||||
def_memory_size="-DMEMORY_SIZE=1024"
|
||||
def_mhz=""
|
||||
enable_hexoutput=""
|
||||
libs="-lpthread"
|
||||
else
|
||||
ldscript="gnuk.ld"
|
||||
chip="stm32f103"
|
||||
arch="cortex-m"
|
||||
emulation=""
|
||||
cross="arm-none-eabi-"
|
||||
mcu="cortex-m3"
|
||||
def_emulation=""
|
||||
def_memory_size="-DMEMORY_SIZE=$MEMORY_SIZE"
|
||||
def_mhz="-DMHZ=$MHZ"
|
||||
enable_hexoutput=yes
|
||||
libs=""
|
||||
fi
|
||||
@@ -337,6 +340,14 @@ else
|
||||
echo "Acknowledge button is not supported"
|
||||
fi
|
||||
|
||||
# KDF Data Object is always required for GNU/Linux emulation
|
||||
if test "$kdf_do_required" = "yes"; then
|
||||
KDF_DO_REQUIRED_DEFINE="#define KDF_DO_REQUIRED 1"
|
||||
echo "KDF DO is required before key import/generation"
|
||||
else
|
||||
KDF_DO_REQUIRED_DEFINE="#undef KDF_DO_REQUIRED"
|
||||
fi
|
||||
|
||||
### !!! Replace following string of "FSIJ" to yours !!! ####
|
||||
SERIALNO="FSIJ-$(sed -e 's%^[^/]*/%%' <../VERSION)-"
|
||||
|
||||
@@ -470,6 +481,7 @@ fi
|
||||
|
||||
|
||||
(echo "CHIP=$chip";
|
||||
echo "ARCH=$arch";
|
||||
echo "EMULATION=$emulation";
|
||||
echo "CROSS=$cross";
|
||||
echo "MCU=$mcu";
|
||||
@@ -519,5 +531,6 @@ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
|
||||
-e "s/@LIFE_CYCLE_MANAGEMENT_DEFINE@/$LIFE_CYCLE_MANAGEMENT_DEFINE/" \
|
||||
-e "s/@ACKBTN_DEFINE@/$ACKBTN_DEFINE/" \
|
||||
-e "s/@SERIALNO_STR_LEN_DEFINE@/$SERIALNO_STR_LEN_DEFINE/" \
|
||||
-e "s/@KDF_DO_REQUIRED_DEFINE@/$KDF_DO_REQUIRED_DEFINE/" \
|
||||
< config.h.in > config.h
|
||||
exit 0
|
||||
|
||||
41
src/main.c
41
src/main.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* main.c - main routine of Gnuk
|
||||
*
|
||||
* Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018
|
||||
* Copyright (C) 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018, 2021
|
||||
* Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
@@ -36,6 +36,11 @@
|
||||
#include "usb-cdc.h"
|
||||
#include "random.h"
|
||||
#ifdef GNU_LINUX_EMULATION
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define main emulated_main
|
||||
@@ -372,6 +377,34 @@ main (int argc, const char *argv[])
|
||||
else
|
||||
flash_image_path = argv[1];
|
||||
|
||||
if (access (flash_image_path, F_OK) < 0)
|
||||
{
|
||||
int fd;
|
||||
char buf[8192];
|
||||
|
||||
memset (buf, 0xff, sizeof buf);
|
||||
memset (buf+4*1024, 0, 2);
|
||||
fd = open (flash_image_path, O_CREAT|O_WRONLY, S_IRUSR|S_IWUSR);
|
||||
if (fd < 0)
|
||||
{
|
||||
perror ("creating flash file");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (write (fd, buf, sizeof buf) != sizeof buf)
|
||||
{
|
||||
perror ("initializing flash file");
|
||||
close (fd);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
close (fd);
|
||||
}
|
||||
|
||||
puts ("Gnuk (emulation with USBIP), a GnuPG USB Token implementation");
|
||||
puts ("Copyright (C) 2021 Free Software Initiative of Japan");
|
||||
puts ("This is free software under GPLv3+.");
|
||||
|
||||
flash_addr = flash_init (flash_image_path);
|
||||
flash_addr_key_storage_start = (uint8_t *)flash_addr;
|
||||
flash_addr_data_storage_start = (uint8_t *)flash_addr + 4096;
|
||||
@@ -563,11 +596,11 @@ gnuk_malloc_init (void)
|
||||
}
|
||||
|
||||
static void *
|
||||
sbrk (size_t size)
|
||||
gnuk_sbrk (intptr_t size)
|
||||
{
|
||||
void *p = (void *)heap_p;
|
||||
|
||||
if ((size_t)(HEAP_END - heap_p) < size)
|
||||
if ((HEAP_END - heap_p) < size)
|
||||
return NULL;
|
||||
|
||||
heap_p += size;
|
||||
@@ -603,7 +636,7 @@ gnuk_malloc (size_t size)
|
||||
{
|
||||
if (m == NULL)
|
||||
{
|
||||
m = (struct mem_head *)sbrk (size);
|
||||
m = (struct mem_head *)gnuk_sbrk (size);
|
||||
if (m)
|
||||
m->size = size;
|
||||
break;
|
||||
|
||||
@@ -986,11 +986,25 @@ rw_kdf (uint16_t tag, int with_tag, const uint8_t *data, int len, int is_write)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check LEN is valid for HOW_MANY of passphrase string.
|
||||
*
|
||||
* HOW_MANY = 1: LEN is valid for a single passphrase string.
|
||||
* HOW_MANY = 2: LEN is valid for two single passphrase strings.
|
||||
* This is used to change passphrase.
|
||||
* The second passphrase may be nothing.
|
||||
*
|
||||
* LEN = 0: Check if KDF-DO is available.
|
||||
*/
|
||||
int
|
||||
gpg_do_kdf_check (int len, int how_many)
|
||||
{
|
||||
const uint8_t *kdf_do = do_ptr[NR_DO_KDF];
|
||||
|
||||
if (len == 0)
|
||||
return kdf_do != NULL;
|
||||
|
||||
if (kdf_do)
|
||||
{
|
||||
const uint8_t *kdf_spec = kdf_do+1;
|
||||
@@ -1598,6 +1612,13 @@ proc_key_import (const uint8_t *data, int len)
|
||||
const uint8_t *p = data;
|
||||
uint8_t pubkey[512];
|
||||
|
||||
#ifdef KDF_DO_REQUIRED
|
||||
const uint8_t *kdf_do = do_ptr[NR_DO_KDF];
|
||||
|
||||
if (kdf_do == NULL)
|
||||
return 0; /* Error. */
|
||||
#endif
|
||||
|
||||
if (admin_authorized == BY_ADMIN)
|
||||
keystring_admin = keystring_md_pw3;
|
||||
else
|
||||
|
||||
@@ -738,6 +738,12 @@ cmd_pgp_gakp (struct eventflag *ccid_comm)
|
||||
{
|
||||
if (!ac_check_status (AC_ADMIN_AUTHORIZED))
|
||||
GPG_SECURITY_FAILURE ();
|
||||
#ifdef KDF_DO_REQUIRED
|
||||
else if (!gpg_do_kdf_check (0, 0))
|
||||
GPG_CONDITION_NOT_SATISFIED ();
|
||||
#endif
|
||||
else
|
||||
gpg_do_keygen (&apdu.cmd_apdu_data[0]);
|
||||
gpg_do_keygen (&apdu.cmd_apdu_data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ Feature: setup pass phrase
|
||||
A token should support pass phrase: PW1, PW3 and reset code
|
||||
|
||||
Scenario: setup PW1 (admin-full mode)
|
||||
Given cmd_change_reference_data with 1 and "123456user pass phrase"
|
||||
Given cmd_change_reference_data with 1 and "another user pass phraseuser pass phrase"
|
||||
Then it should get success
|
||||
|
||||
Scenario: verify PW1 (1)
|
||||
|
||||
@@ -70,11 +70,11 @@ def build_privkey_template_for_remove(openpgp_keyno):
|
||||
keyspec = b'\xb8'
|
||||
else:
|
||||
keyspec = b'\xa4'
|
||||
return b'\x4d\02' + keyspec + b'\0x00'
|
||||
return b'\x4d\x02' + keyspec + b'\x00'
|
||||
|
||||
def compute_digestinfo(msg):
|
||||
digest = sha256(msg).digest()
|
||||
prefix = b'\x30\31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20'
|
||||
prefix = b'\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20'
|
||||
return prefix + digest
|
||||
|
||||
# egcd and modinv are from wikibooks
|
||||
|
||||
@@ -126,9 +126,12 @@ class CardReader(object):
|
||||
# intf.extra_descriptors[41]
|
||||
|
||||
self.__dev = dev
|
||||
self.__timeout = 10000
|
||||
self.__timeout = 100000
|
||||
self.__seq = 0
|
||||
|
||||
if self.ccid_get_status() & 0x03 not in (0, 1):
|
||||
raise ValueError("Card absent")
|
||||
|
||||
def get_string(self, num):
|
||||
return get_string(self.__dev, num)
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ def build_privkey_template_for_remove(openpgp_keyno):
|
||||
keyspec = b'\xb8'
|
||||
else:
|
||||
keyspec = b'\xa4'
|
||||
return b'\x4d\02' + keyspec + b'\0x00'
|
||||
return b'\x4d\x02' + keyspec + b'\x00'
|
||||
|
||||
def compute_digestinfo(msg):
|
||||
digest = sha256(msg).digest()
|
||||
prefix = b'\x30\31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20'
|
||||
prefix = b'\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20'
|
||||
return prefix + digest
|
||||
|
||||
# egcd and modinv are from wikibooks
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# gnuk-emulation-setup - Generate flash image for Gnuk
|
||||
#
|
||||
# Copyright (C) 2017 Free Software Initiative of Japan
|
||||
# Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
#
|
||||
# This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
#
|
||||
# Gnuk is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Gnuk is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
# License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if test "$1" = "--help"; then
|
||||
echo "Usage:"
|
||||
echo " $0 [output-file]"
|
||||
echo " Generate Gnuk flash image"
|
||||
echo " $0 --help"
|
||||
echo " Show this message"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OUTPUT_FILE=${1:-$HOME/.gnuk-flash-image}
|
||||
|
||||
# Generate 8192-byte flash data into OUTPUT_FILE
|
||||
|
||||
exec > $OUTPUT_FILE
|
||||
|
||||
for i in $(seq 512); do
|
||||
/bin/echo -n -e '\xff\xff\xff\xff\xff\xff\xff\xff'
|
||||
done
|
||||
|
||||
/bin/echo -n -e '\x00\x00\xff\xff\xff\xff\xff\xff'
|
||||
|
||||
for i in $(seq 511); do
|
||||
/bin/echo -n -e '\xff\xff\xff\xff\xff\xff\xff\xff'
|
||||
done
|
||||
|
||||
chmod og-rw $OUTPUT_FILE
|
||||
@@ -11,7 +11,7 @@ if __name__ == '__main__':
|
||||
looping = (len(sys.argv) > 1)
|
||||
while True:
|
||||
try:
|
||||
challenge = gnuk.cmd_get_challenge().tostring()
|
||||
challenge = gnuk.cmd_get_challenge().tobytes()
|
||||
except Exception as e:
|
||||
print(count)
|
||||
raise e
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#! /usr/bin/python
|
||||
#! /usr/bin/python3
|
||||
|
||||
"""
|
||||
gnuk_put_binary.py - a tool to put binary to Gnuk Token
|
||||
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>
|
||||
|
||||
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:
|
||||
data_in_device = gnuk.cmd_get_data(0x00, 0x4f)
|
||||
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:
|
||||
data_in_device = gnuk.cmd_read_binary(fileid)
|
||||
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
|
||||
|
||||
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>
|
||||
|
||||
This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
@@ -51,7 +51,7 @@ def main(passwd):
|
||||
gnuk.icc_power_on()
|
||||
gnuk.cmd_select_openpgp()
|
||||
# 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"":
|
||||
passwd_data = passwd.encode('UTF-8')
|
||||
else:
|
||||
|
||||
@@ -88,11 +88,17 @@ class gnuk_token(object):
|
||||
alt.interfaceSubClass == HID_SUBCLASS_NO_BOOT and \
|
||||
alt.interfaceProtocol == HID_PROTOCOL_0:
|
||||
self.__hid_intf = alt.interfaceNumber
|
||||
elif alt.interfaceClass == CCID_CLASS and \
|
||||
alt.interfaceSubClass == CCID_SUBCLASS and \
|
||||
alt.interfaceProtocol == CCID_PROTOCOL_0:
|
||||
for endpoint in alt.endpoints:
|
||||
if endpoint.type == usb.ENDPOINT_TYPE_BULK:
|
||||
if endpoint.address & usb.ENDPOINT_DIR_MASK == usb.ENDPOINT_IN:
|
||||
self.__bulkin = endpoint.address
|
||||
else:
|
||||
self.__bulkout = endpoint.address
|
||||
|
||||
self.__bulkout = 1
|
||||
self.__bulkin = 0x81
|
||||
|
||||
self.__timeout = 10000
|
||||
self.__timeout = 100000
|
||||
self.__seq = 0
|
||||
|
||||
def get_string(self, num):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#! /usr/bin/python
|
||||
#! /usr/bin/python3
|
||||
|
||||
"""
|
||||
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>
|
||||
|
||||
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))
|
||||
return signed
|
||||
|
||||
def main(keyno,keygrip, data_regnual, data_upgrade):
|
||||
def main(keyno, keygrip, data_regnual, data_upgrade):
|
||||
l = len(data_regnual)
|
||||
if (l & 0x03) != 0:
|
||||
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:
|
||||
icc.icc_power_on()
|
||||
icc.cmd_select_openpgp()
|
||||
challenge = icc.cmd_get_challenge().tostring()
|
||||
challenge = icc.cmd_get_challenge().tobytes()
|
||||
signed = gpg_sign(keygrip, binascii.hexlify(challenge))
|
||||
icc.cmd_external_authenticate(keyno, signed)
|
||||
icc.stop_gnuk()
|
||||
@@ -107,17 +107,19 @@ def main(keyno,keygrip, data_regnual, data_upgrade):
|
||||
del icc
|
||||
icc = None
|
||||
#
|
||||
print("Wait 3 seconds...")
|
||||
time.sleep(3)
|
||||
# Then, send upgrade program...
|
||||
reg = None
|
||||
for dev in gnuk_devices_by_vidpid():
|
||||
try:
|
||||
reg = regnual(dev)
|
||||
print("Device: %d" % dev.filename)
|
||||
break
|
||||
except:
|
||||
pass
|
||||
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():
|
||||
try:
|
||||
reg = regnual(dev)
|
||||
print("Device: %s" % dev.filename)
|
||||
break
|
||||
except:
|
||||
pass
|
||||
# Then, send upgrade program...
|
||||
mem_info = reg.mem_info()
|
||||
print("%08x:%08x" % mem_info)
|
||||
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
|
||||
which is just shipped from factory
|
||||
|
||||
Copyright (C) 2012, 2013, 2015, 2018
|
||||
Copyright (C) 2012, 2013, 2015, 2018, 2021
|
||||
Free Software Initiative of Japan
|
||||
Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
|
||||
@@ -52,7 +52,7 @@ def main(wait_e, keyno, passwd, data_regnual, data_upgrade):
|
||||
gnuk.cmd_select_openpgp()
|
||||
# Compute passwd data
|
||||
try:
|
||||
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tostring()
|
||||
kdf_data = gnuk.cmd_get_data(0x00, 0xf9).tobytes()
|
||||
except:
|
||||
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_select_openpgp()
|
||||
challenge = gnuk.cmd_get_challenge().tostring()
|
||||
challenge = gnuk.cmd_get_challenge().tobytes()
|
||||
digestinfo = binascii.unhexlify(SHA256_OID_PREFIX) + challenge
|
||||
signed = rsa.compute_signature(rsa_key, digestinfo)
|
||||
signed_bytes = rsa.integer_to_bytes_256(signed)
|
||||
|
||||
Reference in New Issue
Block a user