1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

lib:util: prefer size_t for random data generation functions

Prefer 'size_t' over 'int' in generate_random_buffer(),
generate_secret_buffer() and generate_nonce_buffer() to
match an underlying gnutls_rnd() calls.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Dmitry Antipov 2023-05-03 10:32:28 +03:00 committed by Andrew Bartlett
parent 72335e742e
commit cea9b25571
2 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ _NORETURN_ static void genrand_panic(int err,
}
_PUBLIC_ void generate_random_buffer(uint8_t *out, int len)
_PUBLIC_ void generate_random_buffer(uint8_t *out, size_t len)
{
/* Random number generator for temporary keys. */
int ret = gnutls_rnd(GNUTLS_RND_RANDOM, out, len);
@ -54,7 +54,7 @@ _PUBLIC_ void generate_random_buffer(uint8_t *out, int len)
}
}
_PUBLIC_ void generate_secret_buffer(uint8_t *out, int len)
_PUBLIC_ void generate_secret_buffer(uint8_t *out, size_t len)
{
/*
* Random number generator for long term keys.
@ -62,7 +62,7 @@ _PUBLIC_ void generate_secret_buffer(uint8_t *out, int len)
* The key generator, will re-seed after a fixed amount of bytes is
* generated (typically less than the nonce), and will also re-seed
* based on time, i.e., after few hours of operation without reaching
* the limit for a re-seed. For its re-seed it mixes mixes data obtained
* the limit for a re-seed. For its re-seed it mixes data obtained
* from the OS random device with the previous key.
*/
int ret = gnutls_rnd(GNUTLS_RND_KEY, out, len);
@ -71,7 +71,7 @@ _PUBLIC_ void generate_secret_buffer(uint8_t *out, int len)
}
}
_PUBLIC_ void generate_nonce_buffer(uint8_t *out, int len)
_PUBLIC_ void generate_nonce_buffer(uint8_t *out, size_t len)
{
/*
* Random number generator for nonce and initialization vectors.

View File

@ -26,7 +26,7 @@
*
* @param[in] len The size of the buffer to fill.
*/
void generate_random_buffer(uint8_t *out, int len);
void generate_random_buffer(uint8_t *out, size_t len);
/**
* @brief Generate random values for long term keys and passwords.
@ -35,7 +35,7 @@ void generate_random_buffer(uint8_t *out, int len);
*
* @param[in] len The size of the buffer to fill.
*/
void generate_secret_buffer(uint8_t *out, int len);
void generate_secret_buffer(uint8_t *out, size_t len);
/**
* @brief Generate random values for a nonce buffer.
@ -46,4 +46,4 @@ void generate_secret_buffer(uint8_t *out, int len);
*
* @param[in] len The size of the buffer to fill.
*/
void generate_nonce_buffer(uint8_t *out, int len);
void generate_nonce_buffer(uint8_t *out, size_t len);