#
# Sample Script to Pull Entropy from Got Entropy service...
#   and seed it into the linux PRNG...
#
# Erik Heidt
# March 2008
#
#
# Distributed under the Art of Information Security License
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
# More information ? -> http://artofinfosec.com/about/
#

# Use tmp as our base of operations
#
cd /tmp

# Get a entropy sample from gotEntropy.
#
wget -c http://gotentropy.artofinfosec.com/hexEntropy.php 2>> /dev/null

# Pull 2 bytes from the local PRNG
# These are pre-pended to the data from gotEntropy. 
# By doing this, even though gotEntropy may know what data they
# sent, they will have no idea what the hased valued loaded into
# the linux PRNG actually is.
# 
dd if=/dev/random of=seed bs=2 count=1 2>> /dev/null

# Convert the hex stream to binary data, and append it onto seed.
#
xxd -r -p hexEntropy.php >> seed

# /dev/random only uses the first 16 bytes of any input as 
# contributing entropy, so we use the MD5 hash which 
# has a 16 byte output.
#
openssl dgst -binary -md5 seed > /dev/urandom

# Housekeeping
#
rm hexEntropy.php seed
