mirror of
https://github.com/rfc1036/whois.git
synced 2026-05-03 06:51:09 +00:00
mkpasswd: let crypt_gensalt collect entropy by itself
Let crypt_gensalt(3) collect entropy by itself instead of having mkpasswd provide it. This is supported by the libxcrypt implementation of crypt_gensalt(3).
This commit is contained in:
parent
8392fd349d
commit
19e44ac2ec
19
mkpasswd.c
19
mkpasswd.c
@ -294,7 +294,8 @@ int main(int argc, char *argv[])
|
|||||||
perror("crypt_gensalt");
|
perror("crypt_gensalt");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
free(entropy);
|
if (entropy)
|
||||||
|
free(entropy);
|
||||||
#else
|
#else
|
||||||
unsigned int salt_len = salt_maxlen;
|
unsigned int salt_len = salt_maxlen;
|
||||||
|
|
||||||
@ -360,9 +361,21 @@ int main(int argc, char *argv[])
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined RANDOM_DEVICE || defined HAVE_ARC4RANDOM_BUF || defined HAVE_GETENTROPY
|
#ifdef CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY
|
||||||
|
|
||||||
void* get_random_bytes(const unsigned int count)
|
/*
|
||||||
|
* If NULL is passed to the libxcrypt version of crypt_gensalt() instead of
|
||||||
|
* the buffer of random bytes then the function will obtain by itself the
|
||||||
|
* required randomness.
|
||||||
|
*/
|
||||||
|
inline void *get_random_bytes(const unsigned int count)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined RANDOM_DEVICE || defined HAVE_ARC4RANDOM_BUF || defined HAVE_GETENTROPY
|
||||||
|
|
||||||
|
void *get_random_bytes(const unsigned int count)
|
||||||
{
|
{
|
||||||
char *buf = NOFAIL(malloc(count));
|
char *buf = NOFAIL(malloc(count));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user