serial number by chip unique ID

This commit is contained in:
NIIBE Yutaka
2011-01-07 16:18:47 +09:00
parent 57859fb417
commit 3ad45f036e
10 changed files with 134 additions and 67 deletions

32
src/configure vendored
View File

@@ -3,7 +3,7 @@
#
# This file is *NOT* generated by GNU Autoconf, but written by NIIBE Yutaka
#
# Copyright (C) 2010 Free Software Initiative of Japan
# Copyright (C) 2010, 2011 Free Software Initiative of Japan
#
# This file is a part of Gnuk, a GnuPG USB Token implementation.
# Gnuk is free software: you can redistribute it and/or modify it
@@ -24,7 +24,7 @@ help=no
target=OLIMEX_STM32_H103
verbose=no
with_dfu=default
with_fsij=no
with_fixed_serial=no
debug=no
pinpad=no
@@ -62,10 +62,10 @@ for option; do
with_dfu=yes ;;
--without-dfu)
with_dfu=no ;;
--with-fsij)
with_fsij=yes ;;
--without-fsij)
with_fsij=no ;;
--with-fixed-serial)
with_fixed_serial=yes ;;
--without-fixed-serial)
with_fixed_serial=no ;;
*)
echo "Unrecognized option \`$option'" >&2
echo "Try \`$0 --help' for more information." >&2
@@ -92,7 +92,7 @@ Configuration:
--enable-pinpad={cir,dial}
PIN input device support [no]
--with-dfu build image for DFU [<target specific>]
--with-fsij Use FSIJ serial number [no: random number]
--with-fixed-serial Use fixed serial number [no: chip unique ID]
EOF
exit 0
fi
@@ -126,19 +126,18 @@ STM8S_DISCOVERY)
;;
esac
# --with-fsij option
if test "$with_fsij" = "no"; then
echo "Using random serial number for card AID"
FSIJ_DEFINE="#undef WITH_FSIJ_SERIAL_NUMBER"
SERIAL_NUMBER_FOUR_BYTES=`od -t u1 -N 4 /dev/random | sed -n -e '/^0000000/s/^0000000 *//' -e 's/ */,/gp'`
# --with-fixed-serial option
if test "$with_fixed_serial" = "no"; then
echo "Using chip unique ID for card AID"
SERIAL_DEFINE="#undef SERIAL_NUMBER_IN_AID"
else
echo "Using FSIJ assigned serial number for card AID"
echo "Using fixed serial number (at compile time) for card AID"
if test "x$MAIL" = "x"; then
echo "ERROR: Please set MAIL shell variable to select FSIJ serial number" >&2
exit 1
fi
FSIJ_DEFINE="#define WITH_FSIJ_SERIAL_NUMBER 1"
SERIAL_NUMBER_FOUR_BYTES=`sed -n -e "/^$MAIL/s/^.* \(..\):\(..\):\(..\):\(..\)/0x\1, 0x\2, 0x\3, 0x\4/p" ../FSIJ_SERIAL_NUMBER`
SERIAL=`sed -n -e "/^$MAIL/s/^.* \(..\):\(..\):\(..\):\(..\)/0x\1, 0x\2, 0x\3, 0x\4/p" ../FSIJ_SERIAL_NUMBER`
SERIAL_DEFINE="#define SERIAL_NUMBER_IN_AID $SERIAL"
fi
# --enable-debug option
@@ -193,7 +192,6 @@ sed -e "s/@DEBUG_DEFINE@/$DEBUG_DEFINE/" \
-e "s/@PINPAD_DEFINE@/$PINPAD_DEFINE/" \
-e "s/@PINPAD_MORE_DEFINE@/$PINPAD_MORE_DEFINE/" \
-e "s/@DFU_DEFINE@/$DFU_DEFINE/" \
-e "s/@FSIJ_DEFINE@/$FSIJ_DEFINE/" \
-e "s/@SERIAL_NUMBER_FOUR_BYTES@/$SERIAL_NUMBER_FOUR_BYTES/" \
-e "s/@SERIAL_DEFINE@/$SERIAL_DEFINE/" \
< config.h.in > config.h
exit 0