diff options
author | defanor <defanor@uberspace.net> | 2023-09-15 21:54:12 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2023-09-15 21:54:12 +0300 |
commit | 27999bd847c95bc85b3e860684fed794867677b4 (patch) | |
tree | 1ee39dedca3658fc24e68fcf1caaa2a10182dd0c /src/rexmpp_random.h | |
parent | 171dd160a5dab054af7096d52d5c970c4dea566f (diff) |
Abstract out random generation
Still depending on gcrypt for hashing, but this is a step towards
making that dependency optional.
Diffstat (limited to 'src/rexmpp_random.h')
-rw-r--r-- | src/rexmpp_random.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/rexmpp_random.h b/src/rexmpp_random.h new file mode 100644 index 0000000..1b21001 --- /dev/null +++ b/src/rexmpp_random.h @@ -0,0 +1,22 @@ +/** + @file rexmpp_random.h + @brief Random generation + @author defanor <defanor@uberspace.net> + @date 2023 + @copyright MIT license. +*/ + +#ifndef REXMPP_RANDOM_H +#define REXMPP_RANDOM_H + +/** + @brief Fills a buffer with cryptographically-secure random data. + @param[out] buf A buffer to write into. + @param[in] len The number of bytes to fill. + + Uses arc4random_buf or gcry_create_nonce, depending on what is + available. +*/ +void rexmpp_random_buf (void *buf, size_t len); + +#endif |