diff options
author | Werner Koch <[email protected]> | 2025-03-14 12:03:46 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2025-03-14 12:08:37 +0000 |
commit | 926b1f1f1e3e382f08cc57fc86d5892649514007 (patch) | |
tree | ddc1bab10152c7de64a9c4167620f0683eac4a7f /doc | |
parent | m4: Update libassuan.m4. (diff) | |
download | gpgme-926b1f1f1e3e382f08cc57fc86d5892649514007.tar.gz gpgme-926b1f1f1e3e382f08cc57fc86d5892649514007.zip |
Add API gpgme_op_random_value.
* src/genrandom.c (getrandom_size_t): New.
(gpgme_op_random_value): New.
* src/gpgme.def: Add new function.
* src/libgpgme.vers: Ditto.
* src/gpgme.h.in: Add prototype.
* tests/run-genrandom.c: Add an option to use the new function.
--
The implementation is not optimized but sufficient for our use case.
Possible improvements for this and gpgme_op_random_bytes are a cache
for random bytes in the context so that we do not need to get out to
gpgme for just a few random bytes.
GnuPG-bug-id: 6694
Diffstat (limited to 'doc')
-rw-r--r-- | doc/gpgme.texi | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/doc/gpgme.texi b/doc/gpgme.texi index a586631e..fa93083c 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -7142,11 +7142,26 @@ The function @code{gpgme_op_random_bytes} returns random bytes. from gpg. However, if @var{mode} is @code{GPGME_RANDOM_MODE_ZBASE32} @var{bufsize} needs to be at least 31 and will be filled with a string of 30 ASCII characters followed by a Nul; the remainder of the buffer -is not changed. This function has a limit of 1024 bytes to avoid -accidental overuse of the random generator +is not changed. The caller must provide a context @var{ctx} +initialized for GPGME_PROTOCOL_OPENPGP. This function has a limit of +1024 bytes to avoid accidental overuse of the random generator @end deftypefun +@deftypefun {gpgme_error_t} gpgme_op_random_values ( @ + @w{gpgme_ctx_t @var{ctx}}, @ + @w{size_t @var{limit}}, @ + @w{size_t *@var{retval}}) + +@since{2.0.0} + +The function @code{gpgme_op_random_value} returns an unbiased random +value in the range 0 <= value < @var{limit}. The value is returned at +@var{retval} if and only if the function returns with success. The +caller must also provide a context @var{ctx} initialized for +GPGME_PROTOCOL_OPENPGP. +@end deftypefun + @node Miscellaneous |