[Gnuk-users] udev rules for Ubuntu 14.04

Julio Lajara ju2wheels at gmail.com
Sun Mar 13 23:23:11 UTC 2016


OK, after racking my head over this and searching a bunch of web pages I 
finally figured out the issue was that my FST-01 was running gnuk and 
not neug since I bought it from Seeed Studio and not FSF.

The documentation is really all over the place amongst a bunch of 
different websites but the steps below worked for me on Ubuntu 14.04 . 
Now after running through all this its working but I realized afterwards 
that I used an old repo link for the binaries.

Does anyone know if its advised for me to upgrade to a newer neug 
version that the one I got from below in step 2.3?

neug firmware installation steps:

1. Identify if your FST-01 is running gnuk or neug by running 'lsusb':

$ lsusb

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 009: ID 234b:0001
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

If your device FST-01 devie shows up as 234b:0001 then its most likely 
already running neug (the random number generator software) and not gnuk 
and you can skip to step 3 below. If you see 234b:0000 then your device 
is probably running gnuk GPG hardware key software (you can confirm this 
by plugging in the FST-01 and running 'gpg --card-status' after 
installing gpg per instructions below).

2. Flashing firmware to overwrite gnuk with neug:

2.1. Setup a udev rule in '/etc/udev/rules.d/90-gnukflash.rules' with 
the following content:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
ENV{ID_USB_INTERFACES}=="*:ff0000:*", GROUP="pcscd"

2.2. Install required software for flashing firmware and reboot:

$ sudo apg-get install gnupg gnupg-agent pcscd python-usb rng-tools
$ sudo groupadd pcscd
$ sudo useradd -G pcscd ${USER}
$ cd /tmp
$ sudo reboot

2.3. Clone gnuk binaries repo with flashing tool:

$ cd /tmp
$ wget 
'https://gitorious.org/gnuk/binaries?p=gnuk:binaries.git;a=snapshot;h=9eaa9933add3a4eda6684757ac367a8abc99b696;sf=tgz' 
-O gnuk_binaries.tar.gz
$ tar xvzf gnuk_binaries.tar.gz
$ cd gnukbinaries*/tool
$ ./upgrade_by_passwd.py ../regnual/regnual.bin ../neug/neug.bin

2.4. Remove the previously created udev rule in 
'/etc/udev/rules.d/90-gnukflash.rules':

$ sudo rm -f /etc/udev/rules.d/90-gnukflash.rules

2.5 Delete the pcscd group we temporarily created (unless you need it 
and are using it for something else):

$ sudo groupdel pcscd

3. neug setup:

3.1. Create a new neug udev rule in '/etc/udev/rules.d/90-neug.rules' 
with the following content:

KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="add", 
ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0001", 
ENV{ID_MM_DEVICE_IGNORE}="1", RUN+="/etc/udev/ctrl_rng.sh"
KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="remove", 
ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0001", 
ENV{ID_MM_DEVICE_IGNORE}="1", RUN+="/etc/udev/ctrl_rng.sh"

3.2. Create the rngd control script in '/etc/udev/ctrl_rng.sh' with the 
following content:

#! /bin/sh

PIDFILE=/var/run/rngd.pid

case "$ACTION" in
add)
   stty -F $DEVNAME raw -echo -parenb
   /usr/sbin/rngd --fill-watermark=90% --rng-device=$DEVNAME
   ;;
remove)
   # This will be called twice, since there are two interfaces for the 
device.
   # Called once for 10/0/0, another for 2/2/1.
   if [ x$INTERFACE = x"2/2/1" -a -f $PIDFILE ]; then
       kill -SIGTERM `cat $PIDFILE`
       rm -f $PIDFILE
   else
       exit 0
   fi
   ;;
esac

exit 0


3.3 Ensure right permissions on rngd control script:

$ sudo chmod 755 /etc/udev/ctrl_rng.sh

3.4 Reboot and then plugin the FST-01 and ensure you see the rngd 
instance running (it may take a few seconds to start after plugging it in):

$ sudo reboot
$ ps aux | grep rngd


Thanks,


On 03/05/2016 05:32 PM, Julio Lajara wrote:
> Hi all, I apologize if this isnt the right list for the question but I 
> couldnt find any other lists or forums for the FST-01.
>
> I just got an FST-01 with device id 234b:0000 and have been trying to 
> follow the guide here: 
> http://www.gniibe.org/FST-01/q_and_a/neug-standalone-device.html
>
> I have tried each of the following udev setups for 
> /etc/udev/rules.d/90-neug.rules (as well as uninstalling modemmanager) 
> but the FST-01 is always being detected as a character device under 
> /dev/char/*:
>
>
> ==============
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="add", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> RUN+="/etc/udev/ctrl_rng.sh"
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="remove", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> RUN+="/etc/udev/ctrl_rng.sh"
> ==============
>
> ==============
> SUBSYSTEMS=="usb", ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> ENV{ID_MM_DEVICE_IGNORE}="1"
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="add", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> RUN+="/etc/udev/ctrl_rng.sh"
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="remove", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> RUN+="/etc/udev/ctrl_rng.sh"
> ==============
>
> ==============
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="add", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> ENV{ID_MM_DEVICE_IGNORE}="1", RUN+="/etc/udev/ctrl_rng.sh"
> KERNEL=="ttyACM[0-9]*", SUBSYSTEMS=="usb", ACTION=="remove", 
> ATTRS{idVendor}=="234b", ATTRS{idProduct}=="0000", 
> ENV{ID_MM_DEVICE_IGNORE}="1", RUN+="/etc/udev/ctrl_rng.sh"
> ==============
>
> Any thoughts on how to get this to properly register under udev on 14.04?
>
> Thanks,




More information about the gnuk-users mailing list