Tuesday, June 21, 2011

Entropy Key to work with Fedora

If you don't know what this device is, it is a small USB key that is inexpensive TRNG (True Random Number Generator) device. If you decide to get one of these things and you are not computer, programmer, linux savvy you may have a little trouble getting it up and running without some clear guidance, so I have put together some reproducible steps for installing:


1) I didn't bother trying the provided RPM packages since none were packages specific to fedora

2) Lua is already installed on most systems but you will also need lua-socket, an add on for lua that provides sockets support. You can't just install the lua-socket from yum- you have to make small changes to lua-socket and install manually. The changes required will (a) install lua to the correct place for fedora, (b) add configuration for UNIX domain sockets for lua, which are not enabled in the fedora package.

I did a google search to find the changes I needed (google: lua socket unix diff). The result I found was for FreeBSD but it works the same:
[1] on freebsd-8 (CURRENT):
/src/localcode/lua/luasocket-2.0.2
0  # hg diff
diff --git a/config b/config
--- a/config
+++ b/config
@@ -51,7 +51,7 @@
# Compiler and linker settings
# for Linux
CC=gcc
-DEF=-DLUASOCKET_DEBUG
+DEF=-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN
CFLAGS= $(LUAINC) $(DEF) -pedantic -Wall -O2 -fpic
LDFLAGS=-O -shared -fpic
LD=gcc
diff --git a/makefile b/makefile
--- a/makefile
+++ b/makefile
@@ -10,6 +10,8 @@
INSTALL_SOCKET_LIB=$(INSTALL_TOP_LIB)/socket
INSTALL_MIME_SHARE=$(INSTALL_TOP_SHARE)/mime
INSTALL_MIME_LIB=$(INSTALL_TOP_LIB)/mime
+#
+INSTALL_UNIX_LIB=$(INSTALL_SOCKET_LIB)

all clean:
      cd src; $(MAKE) $@
@@ -45,6 +47,8 @@
      #cd src; $(INSTALL_DATA) $(TO_MIME_SHARE) $(INSTALL_MIME_SHARE)
      cd src; mkdir -p $(INSTALL_MIME_LIB)
      cd src; $(INSTALL_EXEC) $(MIME_SO) $(INSTALL_MIME_LIB)/core.$(EXT)
+       cd src; mkdir -p $(INSTALL_UNIX_LIB)
+       cd src; $(INSTALL_EXEC) $(UNIX_SO) $(INSTALL_UNIX_LIB)/$(UNIX_SO)

#------
# End of makefile
diff --git a/src/makefile b/src/makefile
--- a/src/makefile
+++ b/src/makefile
@@ -47,7 +47,7 @@
      usocket.o \
      unix.o

-all: $(SOCKET_SO) $(MIME_SO)
+all: $(SOCKET_SO) $(MIME_SO) ${UNIX_SO}

$(SOCKET_SO): $(SOCKET_OBJS)
      $(LD) $(LDFLAGS) -o $@ $(SOCKET_OBJS)



3) Install the patched lua-socket (command: make && make install )

4) Follow the rest of the original instructions for generating a key and running the provided daemon.

To test that your key is working you can run one of the stat tools or just cat /dev/random..

No comments: