* compat: use OpenSSL RAND_priv_bytes() for entropy
Use OpenSSL random number generator to seed arc4random() if available,
if it fails fall back to /dev/urandom.
* tests: link eloop-bench against LDADD lib
arc4random might depend on libcrypto so we need to link it.
#include <sys/types.h>
#include <sys/time.h>
+#if defined(HAVE_OPENSSL)
+#include <openssl/rand.h>
+#endif
+
#define KEYSTREAM_ONLY
#include "chacha_private.h"
struct timeval tv;
uint8_t *rand = (uint8_t *)buf;
+#if defined (HAVE_OPENSSL)
+ if (RAND_priv_bytes(buf, (int)length) == 1)
+ return (0);
+#endif
+
if (length < sizeof(tv)) {
gettimeofday(&tv, NULL);
memcpy(buf, &tv, sizeof(tv));
depend:
${PROG}: ${DEPEND} ${OBJS}
- ${CC} ${LDFLAGS} -o $@ ${OBJS}
+ ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
test: ${PROG}
./${PROG}