1 /* A trivial implementation of hcrypto's RAND interface for
6 #include <evp-hcrypto.h>
9 #include <heim_threads.h>
12 * This mutex is used to synchronize hcrypto operations in the kernel.
13 * We cheat and assume that all access into hcrypto comes through routines
14 * in this file, so that we can ensure it is initialized before it is used.
16 afs_kmutex_t hckernel_mutex;
19 * For these platforms, we use the fortuna RNG from heimdal (seeded from afsd
20 * userspace on startup). Otherwise, we rely on osi_readRandom() as the source
23 #if defined(AFS_AIX_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SGI_ENV)
27 /* Called from osi_Init(); will only run once. */
29 init_hckernel_mutex(void)
31 MUTEX_INIT(&hckernel_mutex, "hckernel", MUTEX_DEFAULT, 0);
35 RAND_seed(const void *indata, size_t size)
38 const RAND_METHOD *m = RAND_fortuna_method();
39 m->seed(indata, size);
44 RAND_bytes(void *outdata, size_t size)
49 const RAND_METHOD *m = RAND_fortuna_method();
50 return m->bytes(outdata, size);
52 if (osi_readRandom(outdata, size))