fix configure: Thanks to Sumedha Widyadharma

This commit is contained in:
NIIBE Yutaka
2013-09-25 13:21:13 +09:00
parent d222998955
commit ec195b290c
7 changed files with 40 additions and 16 deletions

View File

@@ -1,5 +1,16 @@
2013-09-25 Niibe Yutaka <gniibe@fsij.org>
* VERSION: New file.
* src/configure (SERIALNO, SERIALNO_STR_LEN_DEFINE): New.
(REVISION): Use the file VERSION if it doesn't have .git.
Thanks to Sumedha Widyadharma for the bug report.
* src/config.h.in (SERIALNO_STR_LEN_DEFINE): New.
* src/main.c (ID_OFFSET): Use SERIALNO_STR_LEN.
* src/usb_desc.c (gnukStringSerial): Remove. It's now
generated in usb-strings.c.inc.
* src/ec_p256.c (compute_kP): Fix for impossible cases.
(point_is_on_the_curve): New.
(coefficient_a, coefficient_b): New.

6
README
View File

@@ -297,8 +297,10 @@ please contact Niibe, so that it is listed to the file in the official
release of the source code.
When you are modifing Gnuk and installing the binary to device, you
should replace the vendor string to yours, so that users can see it's
not by original vendor, and it is modified version.
should replace the vendor string and serial number to yours (in the
file GNUK_USB_DEVICE_ID and SERIALNO of the script of src/configure),
so that users can see it's not by original vendor, and it is modified
version.
FSIJ allows you to use USB device ID of FSIJ (234b:0000) for devices
with Gnuk under one of following conditions:

1
VERSION Normal file
View File

@@ -0,0 +1 @@
release/1.1.0

View File

@@ -6,3 +6,4 @@
@PINPAD_DEFINE@
@PINPAD_MORE_DEFINE@
@CERTDO_DEFINE@
@SERIALNO_STR_LEN@

23
src/configure vendored
View File

@@ -200,7 +200,18 @@ else
echo "Key generation on device is NOT supported"
fi
REVISION=`git describe --dirty="-modified"`
if test -d ../.git; then
REVISION=`git describe --dirty="-modified"`
else
REVISION=`cat ../VERSION`
fi
### !!! Replace following string of "FSIJ" to yours !!! ####
SERIALNO="FSIJ-`cat ../VERSION | sed -e 's%^[^/]*/%%'`-"
SERIALNO_STR_LEN_DEFINE="#define SERIALNO_STR_LEN ${#SERIALNO}"
CONFIG="$target:dfu=$with_dfu:debug=$debug:pinpad=$pinpad:certdo=$certdo:keygen=$keygen"
if !(IFS=" "
@@ -223,6 +234,15 @@ if !(IFS=" "
echo $PRODUCT | sed -n -e "s/\(........\)/\1\n/gp" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "s/ $//p"
echo '};'
echo
echo 'const uint8_t gnukStringSerial[] = {'
echo " ${#SERIALNO}*2+2+16, /* bLength */"
echo " USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */"
echo " /* Serial number: \"$SERIALNO\" */"
echo $SERIALNO | sed -n -e "s/\(........\)/\1\n/gp" | sed -n -e "s/\(.\)/'\1', 0, /g" -e "s/^/ /" -e "s/ $//p"
echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,"
echo " 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,"
echo '};'
echo
echo '#ifdef USB_STRINGS_FOR_GNUK'
echo 'static const uint8_t gnuk_revision_detail[] = {'
echo " ${#REVISION}*2+2, /* bLength */"
@@ -278,5 +298,6 @@ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
-e "s/@PINPAD_DEFINE@/$PINPAD_DEFINE/" \
-e "s/@PINPAD_MORE_DEFINE@/$PINPAD_MORE_DEFINE/" \
-e "s/@CERTDO_DEFINE@/$CERTDO_DEFINE/" \
-e "s/@SERIALNO_STR_LEN@/$SERIALNO_STR_LEN_DEFINE/" \
< config.h.in > config.h
exit 0

View File

@@ -121,8 +121,7 @@ extern void *USBthread (void *arg);
#define LED_TIMEOUT_STOP (200*1000)
/* It has two-byte prefix and content is "FSIJ-1.0.1-" (2 + 11*2). */
#define ID_OFFSET 24
#define ID_OFFSET (2+SERIALNO_STR_LEN*2)
static void
device_initialize_once (void)
{

View File

@@ -272,17 +272,6 @@ static const uint8_t gnukStringLangID[] = {
#define USB_STRINGS_FOR_GNUK 1
#include "usb-strings.c.inc"
const uint8_t gnukStringSerial[] = {
19*2+2, /* bLength */
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
/* FSIJ-1.0.1- */
'F', 0, 'S', 0, 'I', 0, 'J', 0, '-', 0,
'1', 0, '.', 0, '0', 0, '.', 0, '2', 0, /* Version number of Gnuk */
'-', 0,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
static const struct Descriptor Device_Descriptor = {
gnukDeviceDescriptor,
sizeof (gnukDeviceDescriptor)