[package] add rng-tools
authorflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Fri, 30 Sep 2011 12:49:11 +0000 (12:49 +0000)
committerflorian <florian@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Fri, 30 Sep 2011 12:49:11 +0000 (12:49 +0000)
After removal of the network drivers as an entropy source in Linux kernels a
while ago, some routers e.g. in ar71xx family experience lack of hardware
entropy for /dev/random. The device /dev/random can hang due to that. There
are pseudo random numbers available in /dev/urandom, but they do not end up
in /dev/random.

E.g. tickets #9631 and #9999 are related to this problematics.

One tool for adding entropy data from an arbitrary source to the kernel
entropy pool is rngd daemon included in the rng-tools package from
http://sourceforge.net/projects/gkernel/
Manual page: http://linux.die.net/man/8/rngd

The tool can be used to add entropy to the kernel's entropy pool either from
some genuine hardware-based entropy source, or as a quick&dirty patch also
from /dev/urandom. Using urandom isn't a perfect solution, but it will
satisfy those applications looking for input from /dev/random.

As far as I found out, nobody has complied the rngd daemon package for
Openwrt, so far.
I made a try out of it, and succeeded both for Backfire and trunk.

I defined a package that downloads the sources from SF. (This is my first
package definition, so the dependencies and conventions might not be quite
correct, but the package seems to compile and work both in Backfire and trunk.)

Hopefully somebody can figure out a way to connect some real entropy source
in ar71xxx devices through this daemon. The package could be used with real
hardware entropy sources (like the Entropy key), if they provide a suitable
interface for the daemon to the entropy data from them.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
git-svn-id: svn://svn.openwrt.org/openwrt/packages@28332 3c298f89-4303-0410-b956-a3cf2f4a3e73

utils/rng-tools/Makefile [new file with mode: 0644]
utils/rng-tools/files/rngd.init [new file with mode: 0644]

diff --git a/utils/rng-tools/Makefile b/utils/rng-tools/Makefile
new file mode 100644 (file)
index 0000000..9999ad5
--- /dev/null
@@ -0,0 +1,37 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=rng-tools
+PKG_VERSION:=3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://downloads.sourceforge.net/project/gkernel/rng-tools/3/
+PKG_MD5SUM:=fa305916ec101c85c0065aeceb81a38d
+
+PKG_FIXUP:=libtool
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/rng-tools
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+USE_UCLIBC:argp-standalone
+  TITLE:=Daemon for adding entropy to kernel entropy pool
+  URL:=http://sourceforge.net/projects/gkernel/
+endef
+
+ifdef CONFIG_USE_UCLIBC
+CONFIGURE_VARS += \
+    LIBS="-largp"
+endif
+
+define Package/rng-tools/install
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/rngd.init $(1)/etc/init.d/rngd
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/rngtest $(1)/usr/bin/
+       $(INSTALL_DIR) $(1)/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/rngd $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,rng-tools))
diff --git a/utils/rng-tools/files/rngd.init b/utils/rng-tools/files/rngd.init
new file mode 100644 (file)
index 0000000..733444f
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+START=98
+
+RNGD_INTERVAL=30
+RNGD_AMOUNT=4000
+RNGD_DEVICE=/dev/urandom
+
+start() {
+    rngd -r $RNGD_DEVICE -W $RNGD_AMOUNT -t $RNGD_INTERVAL
+}
+
+stop() {
+    killall rngd
+}