Difference between revisions of "Smartcard drivers manual installation"
Line 47: | Line 47: | ||
=HID Driver (step 1)= | =HID Driver (step 1)= | ||
− | + | This step is specific to HID hardware. | |
− | |||
− | |||
− | |||
+ | * Download latest stable version from HID http://www.hidglobal.com/drivers | ||
+ | |||
+ | |||
+ | Try to install HID driver | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
tar xzvf ifdokccid_linux_x86_64-v4.0.5.5.tar.gz | tar xzvf ifdokccid_linux_x86_64-v4.0.5.5.tar.gz | ||
cd ifdokccid_linux_x86_64-v4.0.5.5/ | cd ifdokccid_linux_x86_64-v4.0.5.5/ | ||
sudo ./install | sudo ./install | ||
+ | </syntaxhighlight> | ||
− | + | This step should be a '''failure'''... But specifics PCSC libs are now in <code>/usr/lib/pcsc/drivers/ifdokccid_linux_x86_64-v4.0.5.5.bundle</code> | |
− | But PCSC | ||
+ | =PCSC-lite (Linux driver)= | ||
− | + | PCSC lite is the reference Open Source driver on all *nux platforms. | |
− | |||
− | * | ||
+ | |||
+ | * Download "pcsclite-latest.zip" from https://alioth.debian.org/projects/pcsclite/ | ||
+ | |||
+ | |||
+ | ==Install== | ||
+ | |||
+ | Unzip and prepare compilation | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
unzip pcsclite-latest.zip | unzip pcsclite-latest.zip | ||
tar xjvf pcsc-lite-1.8.13.tar.bz2 | tar xjvf pcsc-lite-1.8.13.tar.bz2 | ||
cd pcsc-lite-1.8.13/ | cd pcsc-lite-1.8.13/ | ||
chmod +x configure | chmod +x configure | ||
+ | </syntaxhighlight> | ||
− | + | ||
+ | ♦ NETBOOT trick ♦ You need to perform the following extra-operations in your ''chroot'' environment | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
apt-get install -f | apt-get install -f | ||
apt-get install pkg-config libusb-dev | apt-get install pkg-config libusb-dev | ||
Line 77: | Line 92: | ||
apt-get install -f | apt-get install -f | ||
export LD_LIBRARY_PATH=/usr/local/lib | export LD_LIBRARY_PATH=/usr/local/lib | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Configure, compile and install the driver: | ||
+ | <syntaxhighlight lang="bash"> | ||
./configure --enable-usbdropdir=/usr/lib/pcsc/drivers | ./configure --enable-usbdropdir=/usr/lib/pcsc/drivers | ||
make | make | ||
sudo make install | sudo make install | ||
sudo make fix-rights | sudo make fix-rights | ||
+ | </syntaxhighlight> | ||
+ | ==Start/Stop script== | ||
− | + | Create a new daemon manager, the file must be name ''<code>pcscd</code>''! | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | vim /etc/init.d/pcscd | ||
+ | </syntaxhighlight> | ||
− | |||
− | |||
− | + | Put the following content: | |
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
Line 273: | Line 263: | ||
: | : | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | ==PCSC as a service== | ||
+ | |||
+ | Now you can register PCSC as a service. | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | cd /etc/init.d | ||
+ | update-rc.d pcscd default | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | =CCID= | ||
+ | CCID is a mandatory dependency of PCSC. | ||
+ | * Download "ccid-latest.zip" from https://alioth.debian.org/projects/pcsclite/ | ||
− | |||
+ | ==Install== | ||
− | + | <syntaxhighlight lang="bash"> | |
− | --- | + | unzip ccid-latest.zip |
+ | tar xjvf ccid-1.4.18.tar.bz2 | ||
+ | cd ccid-1.4.18/ | ||
+ | chmod +x configure | ||
+ | ./configure | ||
+ | make | ||
+ | sudo make install | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | ==Setup verification== | ||
+ | |||
+ | Now you can try to start the PCSC daemon manually: | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
sudo pcscd -v | sudo pcscd -v | ||
+ | </syntaxhighlight> | ||
* pcsc-lite version 1.8.13 | * pcsc-lite version 1.8.13 | ||
Line 291: | Line 309: | ||
− | + | ||
− | -------- | + | =HID driver (step 2)= |
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | cd ifdokccid_linux_x86_64-v4.0.5.5/ | ||
+ | sudo ./install | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | This time everything should be OK! :) | ||
+ | |||
+ | |||
+ | |||
+ | =PCSC_SCAN= | ||
+ | |||
+ | PCSC_SCAN is small scan utility, very useful to check your configuration / reader status / cards properties... | ||
+ | |||
+ | * Download latest version of PCSC_SCAN on http://ludovic.rousseau.free.fr/softwares/pcsc-tools/index.html | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
+ | tar xzvf pcsc-tools-1.4.23.tar.gz | ||
+ | make | ||
+ | sudo make install | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | |||
+ | -- | ||
+ | At this point you must REBOOT your computer for the changes to apply on the whole system. | ||
+ | -- | ||
+ | |||
+ | |||
+ | |||
+ | =Test your setup= | ||
+ | |||
+ | Proceed to the following tests to ensure your environment is OK. | ||
+ | |||
+ | <syntaxhighlight lang="bash"> | ||
# Start the PCSC daemon manually | # Start the PCSC daemon manually | ||
sudo pcscd -fd | sudo pcscd -fd | ||
+ | |||
# Run the test | # Run the test | ||
pcsc_scan | pcsc_scan | ||
+ | </syntaxhighlight> | ||
+ | =Sources= | ||
− | |||
− | |||
* HID drivers README file | * HID drivers README file | ||
* Debian project PCSC: https://alioth.debian.org/projects/pcsclite/ | * Debian project PCSC: https://alioth.debian.org/projects/pcsclite/ |
Revision as of 18:34, 11 April 2015
The PCSC library shipped with most distributions is a bit old. Sometimes you might need something more recent.
... In such cases you need to:
- Compile and install PCSC + its dependencies manually
- Register a specific smart-card driver, if any is available
- Manage the start/stop script of PCSC as a service
Contents
Requirements
Packages
sudo apt-get install build-essential
sudo apt-get install libudev-dev
sudo apt-get install libusb-1.0.0 libusb-dev
user/group
Create new user & group
sudo adduser --system --no-create-home pcsc
sudo groupadd --system pcscd
Register existing users to the new group
vim /etc/group
Add PCSC, the local user and target application user to the group
pcscd:x:999:pcsc,myUser,myApplicationUser
HID Driver (step 1)
This step is specific to HID hardware.
- Download latest stable version from HID http://www.hidglobal.com/drivers
Try to install HID driver
tar xzvf ifdokccid_linux_x86_64-v4.0.5.5.tar.gz
cd ifdokccid_linux_x86_64-v4.0.5.5/
sudo ./install
This step should be a failure... But specifics PCSC libs are now in /usr/lib/pcsc/drivers/ifdokccid_linux_x86_64-v4.0.5.5.bundle
PCSC-lite (Linux driver)
PCSC lite is the reference Open Source driver on all *nux platforms.
- Download "pcsclite-latest.zip" from https://alioth.debian.org/projects/pcsclite/
Install
Unzip and prepare compilation
unzip pcsclite-latest.zip
tar xjvf pcsc-lite-1.8.13.tar.bz2
cd pcsc-lite-1.8.13/
chmod +x configure
♦ NETBOOT trick ♦ You need to perform the following extra-operations in your chroot environment
apt-get install -f
apt-get install pkg-config libusb-dev
dpkg --configure -a
apt-get install -f
export LD_LIBRARY_PATH=/usr/local/lib
Configure, compile and install the driver:
./configure --enable-usbdropdir=/usr/lib/pcsc/drivers
make
sudo make install
sudo make fix-rights
Start/Stop script
Create a new daemon manager, the file must be name pcscd
!
vim /etc/init.d/pcscd
Put the following content:
#! /bin/sh
### BEGIN INIT INFO
# Provides: pcscd
# Required-Start: $local_fs $remote_fs $syslog
# Required-Stop: $local_fs $remote_fs $syslog
# Should-Start: udev
# Should-Stop: udev
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemon to access a smart card using PC/SC
# Description: The PC/SC daemon is used to dynamically
# allocate/deallocate reader drivers at runtime and manage
# connections to the readers.
### END INIT INFO
# Authors:
# Carlos Prados Bocos <cprados@debian.org>
# Ludovic Rousseau <rousseau@debian.org>
# Do NOT "set -e"
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/pcsc/
DESC="PCSC Lite resource manager"
NAME=pcscd
DAEMON=/usr/local/sbin/$NAME
IPCDIR=/var/run/pcscd
PIDFILE=$IPCDIR/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# if you need to pass arguments to pcscd you should edit the file
# /etc/default/pcscd and add a line
# DAEMON_ARGS="--your-option"
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
# get LANG variable (code from /etc/init.d/keymap.sh)
ENV_FILE="none"
[ -r /etc/environment ] && ENV_FILE="/etc/environment"
[ -r /etc/default/locale ] && ENV_FILE="/etc/default/locale"
value=$(egrep "^[^#]*LANG=" $ENV_FILE | tail -n1 | cut -d= -f2)
eval LANG=$value
#
# Function that starts the daemon/service
#
do_start()
{
# create $IPCDIR with correct access rights
if [ ! -d $IPCDIR ]
then
rm -rf $IPCDIR
mkdir $IPCDIR
fi
chmod 0755 $IPCDIR
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=3 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:
PCSC as a service
Now you can register PCSC as a service.
cd /etc/init.d
update-rc.d pcscd default
CCID
CCID is a mandatory dependency of PCSC.
- Download "ccid-latest.zip" from https://alioth.debian.org/projects/pcsclite/
Install
unzip ccid-latest.zip
tar xjvf ccid-1.4.18.tar.bz2
cd ccid-1.4.18/
chmod +x configure
./configure
make
sudo make install
Setup verification
Now you can try to start the PCSC daemon manually:
sudo pcscd -v
- pcsc-lite version 1.8.13
- usbdropdir=/usr/lib/pcsc/drivers
HID driver (step 2)
cd ifdokccid_linux_x86_64-v4.0.5.5/
sudo ./install
This time everything should be OK! :)
PCSC_SCAN
PCSC_SCAN is small scan utility, very useful to check your configuration / reader status / cards properties...
- Download latest version of PCSC_SCAN on http://ludovic.rousseau.free.fr/softwares/pcsc-tools/index.html
tar xzvf pcsc-tools-1.4.23.tar.gz
make
sudo make install
-- At this point you must REBOOT your computer for the changes to apply on the whole system. --
Test your setup
Proceed to the following tests to ensure your environment is OK.
# Start the PCSC daemon manually
sudo pcscd -fd
# Run the test
pcsc_scan
Sources
- HID drivers README file
- Debian project PCSC: https://alioth.debian.org/projects/pcsclite/
- Ludovic Rousseau's blog & comments: http://ludovicrousseau.blogspot.se
- Ludovic Rousseau PCSC_TOOLS: http://ludovic.rousseau.free.fr/softwares/pcsc-tools/index.html
- Very good tutorial: http://tech.springcard.com/guides/pcsc-unix-with-pcsclite/