xref: /freebsd/contrib/ntp/sntp/m4/ntp_crypto_rand.m4 (revision a466cc55373fc3cf86837f09da729535b57e69a1)
12b15cb3dSCy Schubert# SYNOPSIS						-*- Autoconf -*-
22b15cb3dSCy Schubert#
32b15cb3dSCy Schubert#  NTP_CRYPTO_RAND
42b15cb3dSCy Schubert#
52b15cb3dSCy Schubert# DESCRIPTION
62b15cb3dSCy Schubert#
72b15cb3dSCy Schubert# AUTHOR
82b15cb3dSCy Schubert#
92b15cb3dSCy Schubert#  Harlan Stenn
102b15cb3dSCy Schubert#
112b15cb3dSCy Schubert# LICENSE
122b15cb3dSCy Schubert#
132b15cb3dSCy Schubert#  This file is Copyright (c) 2014 Network Time Foundation
142b15cb3dSCy Schubert#
152b15cb3dSCy Schubert#  Copying and distribution of this file, with or without modification, are
162b15cb3dSCy Schubert#  permitted in any medium without royalty provided the copyright notice,
172b15cb3dSCy Schubert#  author attribution and this notice are preserved.  This file is offered
182b15cb3dSCy Schubert#  as-is, without any warranty.
192b15cb3dSCy Schubert
202b15cb3dSCy SchubertAC_DEFUN([NTP_CRYPTO_RAND], [
21*a466cc55SCy SchubertAC_REQUIRE([NTP_OPENSSL])dnl
222b15cb3dSCy Schubert
232b15cb3dSCy Schubertdnl check for --disable-openssl-random
242b15cb3dSCy Schubertdnl if that's not specified:
252b15cb3dSCy Schubertdnl - Look for RAND_poll and RAND_bytes
262b15cb3dSCy Schubertdnl - if they exist, define USE_OPENSSL_CRYPTO_RAND
272b15cb3dSCy Schubert
282b15cb3dSCy SchubertAC_MSG_CHECKING([if we want to use OpenSSL's crypto random (if available)])
292b15cb3dSCy SchubertAC_ARG_ENABLE(
302b15cb3dSCy Schubert    [openssl-random],
312b15cb3dSCy Schubert    [AS_HELP_STRING(
322b15cb3dSCy Schubert    	[--enable-openssl-random],
332b15cb3dSCy Schubert	[Use OpenSSL's crypto random number functions, if available (default is yes)]
342b15cb3dSCy Schubert    )],
352b15cb3dSCy Schubert    [ntp_use_openssl_random=$enableval],
362b15cb3dSCy Schubert    [ntp_use_openssl_random=yes]
372b15cb3dSCy Schubert)
382b15cb3dSCy SchubertAC_MSG_RESULT([$ntp_use_openssl_random])
392b15cb3dSCy Schubert
402b15cb3dSCy Schubert# The following might need extra libraries
412b15cb3dSCy SchubertNTPO_SAVED_LIBS="$LIBS"
422b15cb3dSCy SchubertLIBS="$NTPO_SAVED_LIBS $LDADD_NTP"
432b15cb3dSCy Schubertdnl AC_MSG_NOTICE([LIBS is <$LIBS>])
442b15cb3dSCy SchubertAC_CHECK_FUNCS([RAND_bytes RAND_poll])
452b15cb3dSCy SchubertLIBS="$NTPO_SAVED_LIBS"
46*a466cc55SCy Schubertcase "$ntp_openssl$ntp_use_openssl_random$ac_cv_func_RAND_bytes$ac_cv_func_RAND_poll" in
47*a466cc55SCy Schubert yesyesyesyes)
482b15cb3dSCy Schubert     AC_DEFINE([USE_OPENSSL_CRYPTO_RAND], [1], [Use OpenSSL's crypto random functions])
492b15cb3dSCy Schubert     ;;
502b15cb3dSCy Schubert *) ntp_use_openssl_random=no ;;
512b15cb3dSCy Schubertesac
522b15cb3dSCy Schubert
532b15cb3dSCy Schubert]) dnl NTP_CRYPTO_RAND
542b15cb3dSCy Schubert
55