Up: Random   [Contents][Index]


7.6.6.1 How to get random bytes

Data type: enum gpgme_random_mode_t

This enum ist used to select special modes of the random generator.

GPGME_RANDOM_MODE_NORMAL

This is the standard mode, you may also use 0 instead of this enum value.

GPGME_RANDOM_MODE_ZBASE32

This mode is used to tell the random function to return a 30 character string with random characters from the zBase32 set of characters. The returned string will be terminated by a Nul.

Function: gpgme_error_t gpgme_op_random_bytes ( gpgme_ctx_t ctx, gpgme_random_mode_t mode, char *buffer, size_t bufsize)

SINCE: 2.0.0

The function gpgme_op_random_bytes returns random bytes. buffer must be provided by the caller with a size of BUFSIZE and will on return be filled with random bytes retrieved from gpg. However, if mode is GPGME_RANDOM_MODE_ZBASE32 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. The caller must provide a context ctx initialized for GPGME_PROTOCOL_OPENPGP. This function has a limit of 1024 bytes to avoid accidental overuse of the random generator

Function: gpgme_error_t gpgme_op_random_values ( gpgme_ctx_t ctx, size_t limit, size_t *retval)

SINCE: 2.0.0

The function gpgme_op_random_value returns an unbiased random value in the range 0 <= value < limit. The value is returned at retval if and only if the function returns with success. The caller must also provide a context ctx initialized for GPGME_PROTOCOL_OPENPGP.


Up: Random   [Contents][Index]