DEVRANDOM(1) devrandom DEVRANDOM(1) NAME devrandom SYNOPSIS devrandom [-0apPvVwx] [-b nbits] [-d nwords] [-D nwords] [-m modulus] [-n nbytes] [-o offset] [-s string] DESCRIPTION devrandom reads a number of bytes from the random device (typically /dev/random ) and prints them in a variety of formats. This provides a convenient source of randomness for scripts and the like, as well as a convenient way of generating secure passwords (use devrandom -p ). The program outputs nbytes bytes from the random device, and ensures that the bytes are modulo modulus (that is, they are at least zero, and less than modulus ). Both of these default to 10. Most of the options below manipulate either of these parameters, possibly while adjusting the output format. The options -adDpPswx modify the format of the output, and are mutually incompatible, so that if more than one is specified, it is the last one which wins. These options also modify the default modulus and number of output bytes, so if you wish to adjust the number of output bytes or modulus, you should give options -n or -m after these. Some of the formats require specific values of these options, and prevent you changing them in this case; see below for the specfic cases. OPTIONS -0 Suppress the newline at the end of the output line. This can be useful in some circumstances, when the output of devrandom is being consumed by scripts. -a Output is from the set of printable ASCII characters, rather than numbers. If set, this defaults modulus to the number of printable ASCII characters, and offset to zero. -b nbits Set the number of bits of entropy to generate (depends on the modulus). -d n Produce sets of digits suitable for creating `diceware' pass- words containing n words. Thus it is equivalent to -o 1 -m 6 -n `n*5' with slightly prettier formatting. See http://www.dice- ware.com -D n As for -d n except that the diceware words themselves are pro- duced. These are taken from the alternative (Alan Beale) list. For absolutely maximum security, you should use physical dice as the source of entropy, and look up the word list yourself. How- ever the mechanism is a useful one for producing high-entropy and reasonably memorable passphrases, as long as you trust your machine's /dev/random. Both the -d and -D options set the num- ber of bytes, offset and modulus, and prevent you resetting them later in the option list. -m modulus Modulus of output -- output is in range offset..(offset+modu- lus-1). The sum offset+modulus must be at most 256. -n nbytes Set the number of bytes to output. -o offset Offset added to output (default 0). The sum offset+modulus must be at most 256. -p Output a random password. This has the same effect as -a -m 62 -n 8 (there are 62 characters in the set [a-zA-Z0-9]). This is equivalent to -s "abcd.." for a string containing the above characters. -P As for -p but with a larger set of possible characters. It has the same effect as -a -n 8 except that the modulus is slightly smaller, to take account of there being some characters in the printable set that are probably a poor idea for (unix) pass- words. I've excluded quote characters, for no terribly well- justified reason. -s string Select characters from the characters in the string. Thus the modulus is the length of the string. -v Produce verbose output, including the number of bits of entropy generated. -V Prints the version number and the source of randomness being used (that is, /dev/random or similar device), and exits. -w Prints output as S/Key english words, as specified by RFC 1751. Because of the way in which these are generated, this always rounds the number of bytes up to a multiple of 8, and this option by default sets nbytes to 8. The modulus and offset are fixed as (effectively) 256 and zero respectively, and you cannot use the -o and -m options after this option. -x Prints output as pairs of hex digits. Sets offset to 0 and mod- ulus to 256. BUGS None known. AUTHOR Copyright 2003, 2005-7, Norman Gray This is free software. Distributed under the terms of the GNU General Public Licence. RANDOM DEVICES Starting with Linux, a number of operating systems have random devices, from which a stream of random bytes can be read. These are, in the best cases, cryptographically respectable sources of randomness. The original Linux interface had both /dev/random and /dev/urandom. The former is a source of true randomness, with an `entropy pool' fed by timings of system and keyboard events, which would block if the amount of entropy left fell below a given level. The latter is designed not to block, with the consequence that it will produce lower quality output if the entropy pool drains because of the rate at which bytes are being read from the device. OS X uses the Yarrow algorithm and the random(4) manpage says `With Yarrow, this choice and distinction is not necessary, and the two devices behave identically. You may use either.' OpenBSD adds to these /dev/srandom , /dev/arandom and /dev/prandom (see http://www.openbsd.org/cgi-bin/man.cgi?query=random&sektion=4 for dis- cussion). In its configuration, devrandom by default uses the first device which matches from the list (srandom, arandom, random, urandom), and you can see which device is being used in fact with the -V option. SEE ALSO RFC 1751 specifies the algorithm for converting 64-bit units to `english words'. The diceware system, http://www.diceware.com, is a very robust way of generating secure passwords, and if you don't want to roll actual dice that many times, can usefully be used with the -d n or -D n options of devrandom. Also http://www.leemon.com/crypto/MakePass.html generates a variety of representations of 128 bits of entropy you type in. This doesn't generate anything for you, but it is colourful. 0.7 2007 November 8 DEVRANDOM(1)