diff options
author | James Almer <jamrial@gmail.com> | 2023-07-04 19:46:32 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2023-07-05 10:06:05 -0300 |
commit | d694c25b44c319eadfb8039fc917639314cadb08 (patch) | |
tree | 90aee53ca3aa42913026970b043144f5fc38c9a4 /libavutil/random_seed.h | |
parent | 7a1128ca07fa38836775168d002ff6bc55134023 (diff) | |
download | ffmpeg-d694c25b44c319eadfb8039fc917639314cadb08.tar.gz |
avutil/random_seed: add av_random_bytes()
Uses the existing code for av_get_random_seed() to return a buffer with
cryptographically secure random data, or an error if none could be generated.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil/random_seed.h')
-rw-r--r-- | libavutil/random_seed.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h index 0462a048e0..e67e6e38c4 100644 --- a/libavutil/random_seed.h +++ b/libavutil/random_seed.h @@ -37,6 +37,19 @@ uint32_t av_get_random_seed(void); /** + * Generate cryptographically secure random data, i.e. suitable for use as + * encryption keys and similar. + * + * @param buf buffer into which the random data will be written + * @param len size of buf in bytes + * + * @retval 0 success, len bytes of random data was written + * into buf + * @retval "a negative AVERROR code" random data could not be generated + */ +int av_random_bytes(uint8_t *buf, size_t len); + +/** * @} */ |