Okay, I’ve written about entropy and the importance of it before. It’s still important, so here is a short guide to generating entropy with a wireless network card on Ubuntu or debian (and possibly others).
Note: before you start doing this, you need a wifi card that supports monitor mode and one (or more) accesspoints – the busier, the better.
So, to generate entropy for the linux kernel by using a wireless network card, we need to capture all the traffic that comes by our network card. We then encrypt the traffic with a random password generated every time you start the script we will use. We encrypt the traffic to make sure, that even when the wireless networks have little or no traffic, the stream of data that the kernel gets will be fairly random.
Now, we need to install some programs:
sudo apt-get install rng-tools wireless-tools tcpdump
Next, you copy and paste this script into a file called /etc/init.d/randomwifi:
#!/bin/sh
# Configuration is here
interface=wlan0
fifo=/tmp/wifirandom.$$
password=`openssl rand -base64 48` # only 48 chars long or a space will fsck up everything.
# find the channel most accesspoints are using, and configure the wireless interface
ifconfig $interface down
iwconfig $interface mode managed
ifconfig $interface up
channel=$(iwlist wlan0 scan | grep Channel\: | uniq -c | sort | head -n 1 | cut -f2 -d\:)
echo Interface $interface is listening on channel $channel
iwconfig $interface channel $channel
ifconfig $interface down
iwconfig $interface mode monitor
ifconfig $interface up
# make a fifo to put our random data in
mkfifo $fifo
tcpdump -KnOSx -vvv -i $interface | openssl enc -aes-256-cbc -pass pass:$password > $fifo &
sleep 1
rngd -r $fifo -o /dev/random -t 1
Make sure this code can run by setting the execute flag on the file and make it start on boot:
chmod u+x /etc/init.d/randomwifi
sudo update-rc.d randomwifi defaults
That’s it! If your computer is located near a busy accesspoint, you should have plenty of entropy.
Did you try this? Share your experiences below.
Related posts:
COMMENT POLICY
There is some simple rules you have to follow, if you want to comment on this page:
- Write comments in the language of the post. I write in both Danish and English, and when I write in English I would appreciate comments in English only.
- Either use your real name or make use of KeywordLuv AND still use your real name.
- No comments less than 20 words (unless it's a REALLY good comment).
- No comments will be approved without a real name. Don't use keywords for your name!
If these rules are not followed, I will probably delete your comment. If not, I might alter it in any way I see fit, including URL's and anchor texts!