1 # gc-random.m4 serial 1
2 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_GC_RANDOM],
9 # Devices with randomness.
10 # FIXME: Are these the best defaults?
14 NAME_OF_RANDOM_DEVICE="/dev/srandom"
15 NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/prandom"
16 NAME_OF_NONCE_DEVICE="/dev/urandom"
20 NAME_OF_RANDOM_DEVICE="/dev/srandom"
21 NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/urandom"
22 NAME_OF_NONCE_DEVICE="/dev/urandom"
25 *-solaris* | *-irix* | *-dec-osf* )
26 NAME_OF_RANDOM_DEVICE="/dev/random"
27 NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/random"
28 NAME_OF_NONCE_DEVICE="/dev/random"
32 NAME_OF_RANDOM_DEVICE="/dev/random"
33 NAME_OF_PSEUDO_RANDOM_DEVICE="/dev/urandom"
34 NAME_OF_NONCE_DEVICE="/dev/urandom"
38 AC_MSG_CHECKING([device with (strong) random data...])
39 AC_ARG_ENABLE(random-device,
40 AC_HELP_STRING([--enable-random-device],
41 [device with (strong) randomness (for Nettle)]),
42 test "$enableval" != "no" && NAME_OF_RANDOM_DEVICE=$enableval)
43 AC_MSG_RESULT($NAME_OF_RANDOM_DEVICE)
45 AC_MSG_CHECKING([device with pseudo random data...])
46 AC_ARG_ENABLE(pseudo-random-device,
47 AC_HELP_STRING([--enable-pseudo-random-device],
48 [device with pseudo randomness (for Nettle)]),
49 test "$enableval" != "no" && NAME_OF_PSEUDO_RANDOM_DEVICE=$enableval)
50 AC_MSG_RESULT($NAME_OF_PSEUDO_RANDOM_DEVICE)
52 AC_MSG_CHECKING([device with unpredictable data for nonces...])
53 AC_ARG_ENABLE(nonce-device,
54 AC_HELP_STRING([--enable-nonce-device],
55 [device with unpredictable nonces (for Nettle)]),
56 test "$enableval" != "no" && NAME_OF_NONCE_DEVICE=$enableval)
57 AC_MSG_RESULT($NAME_OF_NONCE_DEVICE)
59 if test "$cross_compiling" != yes; then
60 AC_CHECK_FILE($NAME_OF_RANDOM_DEVICE,,
61 AC_MSG_WARN([[device for (strong) random data `$NAME_OF_RANDOM_DEVICE' does not exist]]))
62 AC_CHECK_FILE($NAME_OF_PSEUDO_RANDOM_DEVICE,,
63 AC_MSG_WARN([[device for pseudo-random data `$NAME_OF_PSEUDO_RANDOM_DEVICE' does not exist]]))
64 AC_CHECK_FILE($NAME_OF_NONCE_DEVICE,,
65 AC_MSG_WARN([[device for unpredictable nonces `$NAME_OF_NONCE_DEVICE' does not exist]]))
67 AC_MSG_NOTICE([[Cross compiling, assuming random devices exists on the target host...]])
70 # FIXME?: Open+read 42 bytes+close twice and compare data. Should differ.
72 AC_DEFINE_UNQUOTED(NAME_OF_RANDOM_DEVICE, "$NAME_OF_RANDOM_DEVICE",
73 [defined to the name of the (strong) random device])
74 AC_DEFINE_UNQUOTED(NAME_OF_PSEUDO_RANDOM_DEVICE,
75 "$NAME_OF_PSEUDO_RANDOM_DEVICE",
76 [defined to the name of the pseudo random device])
77 AC_DEFINE_UNQUOTED(NAME_OF_NONCE_DEVICE, "$NAME_OF_NONCE_DEVICE",
78 [defined to the name of the unpredictable nonce device])
80 AC_DEFINE(GC_USE_RANDOM, 1, [Define if you want to support RNG through GC.])