DO NOT MERGE - local copy of heimdal pull request

This is https://github.com/heimdal/heimdal/pull/61 ; heimdal needs
to handle the case where gettimeofday() fails in order to avoid
killing the kernel when this code is used.

Change-Id: I1bb63940426b609eda685d390a87e0893ed4c497
Export heimdal's rand-fortuna PRNG to the kernel

Some systems (e.g., AIX, SGI, DFBSD, HPUX) do not supply a useful
implementation of osi_readRandom(), in some cases because the kernel
does not expose a random-number interface to kernel modules.  We want
real random numbers on all systems, because we want to use the for
setting the RX epoch and connection ID in the kernel.

Build hcrypto's rand-fortuna PRNG into the rand-kernel interface we expose,
and implement RAND_bytes using rand-fortuna when osi_ReadRandom()
is not useful.

Add stub routines to config.h as needed, and add a heim_threads.h
with the necessary locking for rand-fortuna.  We use a single (global)
mutex for the hcrypto kernel code, so that we can statically declare
an initializer to be the address of that mutex.  Otherwise the locking
is taken essentially wholesale from rx_kmutex.

Since the rand-fortuna code does not have any actual sources of entropy
available to it during its initialization routines, we must explicitly
seed the in-kernel rand-fortuna using entropy passed in from userland.
(Userland will always have at least /dev/random available, so the
userland hcrypto should always have usable entropy.)  Be sure to do so
early in the afsd startup sequence, before any daemons are started, so
that entropy is available to the core rx code for generating the epoch
and cid -- the rand-fortuna code will (erroneously) always claim that
it has startup entropy even though in this case it may not actually
have any entropy.  The rand-fortuna code does not consider itself
fully seeded until it has 128 bytes of entropy, so be sure to pass
more than that in from userspace.

It is preferrable to always build this code into the kernel, even on
systems when it is not going to be used, to help prevent bitrot.  This
also avoids the possibility of a new system being supported that would
attempt to use the rand-fortuna code but fail to supply any seed entropy,
which would not necessarily be readily apparent.

Change-Id: I614d2bd9ac52803ec3b9572cc694cd836c8427dd
Move epoch and cid generation into the rx core

Now that we have hcrypto available everywhere, we can get real randomness
in the rx core (both uerspace and kernel), and thus can initialize the
RX epoch to a real random value when first initializing a host; there is
no need to rely on rxkad to produce randomness for this purpose.
Initialize a connection ID counter at the same time, and use that in
rx_NewConnection, also supplanting rxkad-specific logic.

The rxkad-specific logic is removed, and in particular there is no longer
a need to export rxkad_EpochWasSet to the rest of the world.
The code in afs_Daemon() to check whether the rxepoch was set can be
removed, as if the epoch is not set, rx initialization fails.

Add libafshcrypto to LIBS in the handful of places it hadn't crept already.

Change-Id: I1dd1015b29a600aaf72b6b4b36f8a17032453c97
Garbage-collect afs_GCUserData's argument

We no longer need the ability to force all rxnull connections to be
reaped, as the epoch is set globally.  Change the prototype and
callers accordingly.

Change-Id: I0815fdd035c3dd9d56f72e43603f9c53f5cec79d
Remove rx_SetEpoch, rx_SetConnectionEpoch, rx_SetConnectionId

The core RX code now manages the Epoch and CID; external callers
should not be modifying them.

Change-Id: Ia517205aa280b2a0bbd2568274be7fb010fba0bc