Operating Systems: General Notes

Serial readers should work fine on all operating systems. USB needs hotplug support, so that you can plugin some new USB device, and if it is a smart card reader, OpenCT needs to be notified. Unfortunatly hotplug on Linux is currently moving from hotplug to udev or hald, so we document all three systems. FreeBSD has usbd and dev, and no idea about all other systems. Readers in PCMCIA and PC-Card format are experimental and only supported under Linux so far, tested only with the udev setup (but adapting the setup should be easy).

Linux

We will discuss the very old hotplug setup below which nearly noone uses these days, the current udev setup and problems we know with it, and the new hald setup.

Old Hotplug Setup

Serial support needs nothing special (only the serial driver for your serial device), but USB support on Linux has a few requirements:

  • libusb needed during compilation and runtime.
  • CONFIG_HOTPLUG so the kernel can let us know if you plugin a reader or token.
  • hotplug utilities will be called by the kernel and run openct.
  • CONFIG_USB_DEVICEFS so we can talk to USB devices from userspace.
  • mount usbfs (kernel 2.4: usbdevfs) at /proc/bus/usb, to do that put this line into your /etc/fstab:
    usbfs           /proc/bus/usb   usbfs   defaults                0       0
    
    (replace "usbfs" with "usbdevfs" for Linux kernel 2.4.* - will work on kernel 2.6.* too)

Also the hotplug files need to be installed (see QuickStart for full installation instructions):

# cp etc/openct.usermap /etc/hotplug/usb/openct.usermap
# cp etc/openct_usb /etc/hotplug/usb/openct

New udev Setup

Serial support needs nothing special (only the serial driver for your serial device), but USB support on Linux has a few requirements:

  • libusb needed during compilation and runtime.
  • CONFIG_HOTPLUG so the kernel can let us know if you plug in a reader or token.
  • udev needs to be installed. This comes with your distribution, and you are advised not to install or update it yourself.

OpenCT before 0.6.13 also needs:

  • CONFIG_USB_DEVICEFS so we can talk to USB devices from userspace.
  • mount usbfs (kernel 2.4: usbdevfs) at /proc/bus/usb, to do that put this line into your /etc/fstab:
    usbfs           /proc/bus/usb   usbfs   defaults                0       0
    
    (replace "usbfs" with "usbdevfs" for Linux kernel 2.4.* - will work on kernel 2.6.* too)

Also the udev files need to be installed (see QuickStart for full installation instructions):

# cp etc/openct.udev /etc/udev/rules.d/50-openct.rules
# cp etc/openct_usb /lib/udev/openct_usb
# cp etc/openct_pcmcia /lib/udev/openct_pcmcia
# cp etc/openct_serial /lib/udev/openct_serial

Some common problems with udev:

  • kernel versions and udev rules do not fit. Several kernels required new udev versions, so updating the kernel without udev will not work. Updating udev is something you shouldn't do yourself, best use the distribution udev. As a result you cannot update the kernel or need to update your whole distribution.
  • For a long time every distribution had usbfs mounted on /proc/bus/usb. Some stopped doing that and thus broke OpenCT. This is fixed in OpenCT 0.6.13+. Note: OpenSuse uses hal for connecting Linux kernel and OpenCT and thus should work without usbfs mounted on /proc/bus/usb.
  • Ubuntu 7.04 ("feisty") and maybe also older versions had usbfs mounted on /proc/bus/usb/.usbfs and a bind mount from /dev/bus/usb to /proc/bus/usb. This broken OpenCT as the device we wanted to open was always created too late. OpenCT 0.6.12 has added a work around for this. Ubuntu 7.10 will drop this practice (but maybe not have /proc/bus/usb at all).
  • Linux Kernel 2.6.22 has changes to the USB code that result in some uevents missing PRODUCT and TYPE and DEVICE information. This will be fixed in 2.6.23 and 2.6.22.5. Please update your kernel.
  • Linux Kernel 2.6.22+ has a new option CONFIG_USB_DEVICE_CLASS, which is marked deprecated. As long as it is on everything is fine. But if turned off there could be problems. This option doesn't harm OpenCT per se, but might break your udev code to generate /dev/bus/usb/xxx/yyy devices. As a result libusb will not find any device (because /dev/bus/usb exists it doesn't look at /proc/bus/usb even if that one is fine), and thus also our coldplug code run by "/etc/init.d/openct start" breaks.
  • People could compile their kernel without the CONFIG_USB_DEVICEFS option. This option was only needed for usbfs, and some might think with /dev/bus/usb it is no longer needed to have usbfs on /proc/bus/usb. But without this option the kernel also doesn't add the DEVICE information to the kernel events, and thus OpenCT can be notified by udev about new devices, but will not have the name of the new device and thus cannot process this information. OpenCT 0.6.13+ can work without CONFIG_USB_DEVICEFS.
  • udev has a mechanism as alternative to DEVICE, it is called DEVNAME. But it only works with the proper udev rules and on many distributions those are not in place, resulting in DEVNAME like /dev/2-1.7 - something OpenCT can't work with. A proper udev rules looks like this:
      SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
        NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"
    
    OpenCT 0.6.13+ has this rule and a modified script so we can construct the device name from udev information stored from a previous event and read by udevinfo later.

mdev setup

mdev is provided by busybox to handle hotplug events as udev replacement. It is handy for initramfs configurations.

In order to setup configuration:

  • Configure busybox with CONFIG_MDEV, CONFIG_FEATURE_MDEV_CONF, CONFIG_FEATURE_MDEV_EXEC.
  • Copy etc/openct_usb.mdev from build output to your initramfs at /lib/mdev/openct_usb.
  • Create /etc/mdev.conf at your initramfs with the following content:
    .* 0:0 0660 /lib/mdev/openct_usb
    
  • For simple installation, copy the following files into your initramfs, and all dependencies.
    /usr/sbin/openct-control
    /usr/sbin/ifdhandler
    /etc/openct.conf
    

hald setup

Hald needs a fdi config file and a script it runs when something in the fdi config file matches. To install these files:

# mkdir -p /usr/share/hal/fdi/information/10freedesktop/
# cp etc/openct.fdi /usr/share/hal/fdi/information/10freedesktop/10-usb-openct.fdi
# cp etc/openct.hald /usr/bin/hald-addon-openct

OpenSuse ships OpenCT connected via hald to the kernel events. The fdi config file for hald in openct-0.6.12-10 however does not match USB class information and thus will not work with all readers. Also the hald-addon-openct in openct-0.6.12-10 seems to be broken, as it uses /proc/bus/usb/ PATH, but as far as we know OpenSuse only has devices in /dev/bus/usb.

OpenCT 0.6.13+ comes with a hald fdi file and we hope the packages OpenSuse creates for this new version will work.

PCMCIA and PC-Card readers are not yet supported via hald, advice and patches are very welcome.

Hald documentation is available online at http://people.freedesktop.org/~david/hal-spec/hal-spec.html

FreeBSD

Daniel Slezak reports for freebsd 5.4:

I have sold a part of my problem by usbd in FreeBSD 5.4. I add to /etc/usbd.conf:

## Token Rainbow Technologies iKey 3000 Series
device "iKey 3000 Series"
         devname "ugen[0-9]+"
         vendor  0x04b9
         product 0x1300
         attach  "/usr/local/etc/rc.d/openct.sh start"
         detach  "/usr/local/etc/rc.d/openct.sh stop"

# The fallthrough entry: Nothing is specified, nothing is done.  And it isn't
# necessary at all :-) .  Just for pretty printing in debugging mode.
#
device "USB device"
         detach "/usr/local/sbin/openct-control shutdown"

I had to add "detach /usr/local/etc/rc.d/openct.sh stop" in section "USB device" too, else it hasn't any effect. I have to close openct framework before I take out token. Else FreeBSD doesn't detach /dev/ugen0 and writes in logs: usb_detach_wait: ugen0 didn't detach.

And he forwarded a note from Petr Holub for FreeBSD 6.0:

On 6.0-RELEASE:
1) Install from ports
   security/openct
   security/opensc
2) add to /etc/devd.conf:
# USB certificate token
attach 50 {
    match "vendor" "0x04b9";
    match "product" "0x1300";
    action "/usr/local/etc/rc.d/openct.sh start";
};
detach 50 {
    match "vendor" "0x04b9";
    match "product" "0x1300";
    action "/usr/local/etc/rc.d/openct.sh stop";
};
3) /etc/rc.d/devd restart

List of issues for FreeBSD:

  • is devd a replacement of usbd? sorry, I'm confused. Also: above has only examples for one vendor/product each. We could include example files for either or both in openct with all devices listed.
  • above example uses the init script and start/stop. That will not work with several tokens, as it will always end the processes for all of them. it would be better to call openct-control attach or ifdhandler. On Linux the hotplug system calls
    /usr/sbin/openct-control attach /proc/bus/usb/003/002 usb:973/1
    
    which has the device path as parameter and "usb:vendor/product" so OpenCT knows the type (USB) and the information (vendor and product) so it can read the openct.conf, look which driver is used for that, and start an ifdhandler like that:
    /usr/sbin/ifdhandler -H egate /proc/bus/usb/003/003
    
    i.e. "-H" for hotplug, the driver name, and the device file to use. add -v or -vv or even more for debugging. would be nice if FreeBSD could do something similar, or let us know how to deal with this best.

OpenBSD

install from ports
cd /usr/ports/security/openct
make install clean
cd /usr/ports/security/opensc
make install clean

Erase and key generation works so far, but OpenSSL does not: the OpenSSL shell exits after the engine load command for some unknown reason. Note you need to specify the engine shared object file as *.so.0.0 (on Linux it is simply *.so).

Also OpenBSD has a hotplugd, but so far it does not support USB devices. So you need to run

openct-control shutdown
openct-control init

every time you add or remove a USB crypto token.

Now OpenBSD Current (2005-07-20) passes all OpenSC regression tests with an Aladdin eToken PRO.

Other tokens however did not work, these problems need to be investigated, as well as how to get it to work without UGEN_DEBUG.

other BSD

OpenCT should work, but this wasn't tested for sometime. Latest OpenCT seems to not find libusb, we are working on it.

Solaris

Latest OpenCT supports Solaris fine and was tested to work.

Sunray

Sunray including client/server architecture was added to OpenCT (in version 0.6.5).