>> > > OTOH, why people don't just read a pile of bytes from /dev/audio

Yep this is what I do.  I have a host with a sound card located in a busy
office.  I grab sound samples from this system at regular intervals.
The script below takes care of the grunt work and may be of use
to others wanting a reasonable source of randomness.  Only works
for *nix - sorry.

--sjg 

[the missing funcs.sh etc are included in 
ftp://ftp.quick.com.au/pub/unix/config-sh.cpio.gz]

:
# NAME:
#       getnoise - get some random noise
#
# DESCRIPTION:
#       Grab some sound bytes from a machine with a sound card. 
#       The random? noise from the sound card is compressed and
#       appended to a big file.
#
#       We then take sequential 1k chunks from the start of the random
#       store to update all the .rand files we know of.   The idea is
#       that it should be difficult to predict when the sound sample
#       in any given .rand file was actually collected.
#
#       Each 1k chunk of random data is used only once and the random
#       storage file is kept from growing too big by stripping of used
#       and excess data at the start of the file.  The skipping of
#       excess data means there is no guarantee that any particular
#       sample will be used.
#
# AUTHOR:
#       Simon J. Gerraty <[EMAIL PROTECTED]>

# RCSid:
#       $Id: getnoise,v 1.8 1998/11/19 14:00:51 sjg Exp $
#
#       @(#) Copyright (c) 1997 Simon J. Gerraty
#
#       This file is provided in the hope that it will
#       be of use.  There is absolutely NO WARRANTY.
#       Permission to copy, redistribute or otherwise
#       use this file is hereby granted provided that 
#       the above copyright notice and this notice are
#       left intact. 
#      
#       Please send copies of changes and bug-fixes to:
#       [EMAIL PROTECTED]
#

Myname=getnoise

# pick up zap()
RC_D=${RC_D:-/etc/rc_d}
. $RC_D/funcs.sh

source .${Myname}rc $Mydir $RC_D /etc

case "$NOISE_HOST" in
""|localhost*|${DEST_HOST:-$HOST}) 
        RSH="/bin/sh -c";;
*)      RSH="${SSHELL:-SSLrsh -zcert=/etc/host.cert} $NOISE_HOST";;
esac

NOISE_STORE=${NOISE_STORE:-/.random}
TF=${TMP:-/tmp}/gn$$

if [ -s $NOISE_STORE ]; then
        # grab a reasonable sample
        count=${NOISE_SAMPLE:-12}
        # Work out how much to skip to keep the file under $NOISE_KEEP
        sz=`du $K -s $NOISE_STORE`
        sz=`set -- $sz; echo $1`
        skip=`expr ${sz:-0} - ${NOISE_KEEP:-120}`
        [ $skip -lt 0 ] && skip=0
else
        # grab a bigger sample to start us off.
        count=${NOISE_SAMPLE1:-32}
fi
# this works whether /dev/audio is local or not
# we compress first so we know how much data we get...
eval $RSH "'compress < ${DEV_AUDIO:-/dev/audio} | dd bs=1k count=$count'" >> 
$NOISE_STORE 2> $TF
egrep -v 'records|bytes' $TF >&2

[ -s $NOISE_STORE ] && (locate .rand; locate .rnd) | grep -v $NOISE_STORE | awk '{ 
print "test -s", $0, "&& dd bs=1k skip=" NR, "count=1 <", NOISE, ">", $0 } END { print 
"mv", NOISE, NOISE ".old && dd bs=1k skip=" NR + SKIP, "<", NOISE ".old >", NOISE }' 
NOISE=$NOISE_STORE SKIP=${skip:-0} - | sh > /dev/null 2>&1

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to