22 RCSID(
"$Id: 72ac76a8c7bde70a22d475558c047ab9ff5d9640 $")
28 #include <sys/types.h>
39 size_t bytes_read = 0;
43 while (bytes_read < len) {
44 bytes_left = len - bytes_read;
47 n =
sizeof(
r) < bytes_left ?
sizeof(r) : bytes_left;
49 memcpy(rnd_data + bytes_read, &r, n);
72 for (i = 0; i < len; ++i) {
73 challenge[i] =
'0' + rawchallenge[i] % 10;
76 challenge[len] =
'\0';
88 ERROR(
"rlm_otp: %s: pthread_mutex_init: %s",
104 ERROR(
"rlm_otp: %s: pthread_mutex_lock: %s",
118 rc = pthread_mutex_trylock(mutexp);
119 if (rc && rc != EBUSY) {
120 ERROR(
"rlm_otp: %s: pthread_mutex_trylock: %s",
138 ERROR(
"rlm_otp: %s: pthread_mutex_unlock: %s",
#define pthread_mutex_init(_x, _y)
uint32_t fr_rand(void)
Return a 32-bit random number.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
void _otp_pthread_mutex_lock(pthread_mutex_t *mutexp, char const *caller)
Guaranteed lock.
#define pthread_mutex_unlock(_x)
void _otp_pthread_mutex_unlock(pthread_mutex_t *mutexp, char const *caller)
Guaranteed unlock.
void otp_async_challenge(char challenge[OTP_MAX_CHALLENGE_LEN+1], size_t len)
Generate a random challenge (ascii chars 0-9)
#define OTP_MAX_CHALLENGE_LEN
void _otp_pthread_mutex_init(pthread_mutex_t *mutexp, pthread_mutexattr_t const *attr, char const *caller)
Guaranteed initialization.
#define pthread_mutex_lock(_x)
int _otp_pthread_mutex_trylock(pthread_mutex_t *mutexp, char const *caller)
Guaranteed trylock.
void otp_get_random(uint8_t *rnd_data, size_t len)
Generate some random bytes.